-
Notifications
You must be signed in to change notification settings - Fork 290
Implement GLContextDispatcher trait for NativeGLContexts #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -42,6 +43,7 @@ pub struct RenderBackend { | |||
webgl_contexts: HashMap<WebGLContextId, GLContextWrapper>, | |||
current_bound_webgl_context_id: Option<WebGLContextId>, | |||
enable_recording: bool, | |||
main_thread_dispatcher: Arc<Mutex<Option<Box<RenderDispatcher>>>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably an option of an arc is a better Idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the same type pattern as the one used in RenderNotifier setter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I see why you need this, but it seems unfortunate.
@@ -261,7 +265,10 @@ impl RenderBackend { | |||
} | |||
ApiMsg::RequestWebGLContext(size, attributes, tx) => { | |||
if let Some(ref wrapper) = self.webrender_context_handle { | |||
let result = wrapper.new_context(size, attributes); | |||
let dispatcher = Box::new(WebRenderGLDispatcher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this only on windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll add a macro. It will avoid unneeded allocations in the platforms that don't use this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I need to review this really carefully. May you open also a PR with your servo-related changes so it's easy to see the code flow? |
Still have to rebase the latest servo master, I'll do tomorrow. In the meantime you can check this: MortimerGoro/servo@64f92be, it will be the same code, just changing Dispatcher name to RenderDispatcher. P.D.: I created another trait called RenderDispatcher in order to not expose internal types of webrender. I assumed that you want that webrender library users don't need to be aware that offscreen_gl_context is used internally. Servo now uses offscreen_gl_context includes, but I thought that might not be true in the future when webrender is set up as default and skia renderer dropped. |
80f97b8
to
62aaa20
Compare
☔ The latest upstream changes (presumably #439) made this pull request unmergeable. Please resolve the merge conflicts. |
3cf4b78
to
a189acc
Compare
Any news on this? I have a another idea to implement this. We could create and pass the dispatcher directly from WebGLPaintThred in servo, in this call.
Let me know what you think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the huge delay.
The other idea is nice too, but I think one global dispatcher is fine for now. Looks good to me with that nit addressed, and optionally that comment moved.
Thanks, and sorry again it took so long :)
let result = wrapper.new_context(size, attributes); | ||
let dispatcher: Option<Box<GLContextDispatcher>>; | ||
if cfg!(target_os = "windows") { | ||
dispatcher = Some(Box::new(WebRenderGLDispatcher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
let dispatcher = if cfg!(target_os = "windows") {
Some(...)
} else {
None
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to specify the type: Option<Box<GLContextDispatcher>>
or rust compiler doesn't have enough magic to coerce
/// Sets the new MainThreadDispatcher. | ||
/// | ||
/// Used to dispatch functions to the main thread's event loop. | ||
/// Required to allow GLContext sharing in some implementations like WGL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably moving the last part of this comment to the main_thread_dispatcher
member definition would make it a bit more helpful.
a189acc
to
027e224
Compare
Done :) |
@bors-servo: r+ |
📌 Commit 027e224 has been approved by |
Implement GLContextDispatcher trait for NativeGLContexts Implement GLContextDispatcher trait for NativeGLContexts. Required to allow GLContext sharing in some implementations like WGL. See servo/surfman#69 for more info. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/432) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
WebGL support on Windows <!-- Please describe your changes on the following line: --> This is the final step to provide WebGL support on Windows ;) Some Related PRs already merged in webrender and offscreen-gl-context: servo/surfman#64 servo/webrender#432 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13840) <!-- Reviewable:end -->
…render_dispatcher); r=emilio <!-- Please describe your changes on the following line: --> This is the final step to provide WebGL support on Windows ;) Some Related PRs already merged in webrender and offscreen-gl-context: servo/surfman#64 servo/webrender#432 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e
…render_dispatcher); r=emilio <!-- Please describe your changes on the following line: --> This is the final step to provide WebGL support on Windows ;) Some Related PRs already merged in webrender and offscreen-gl-context: servo/surfman#64 servo/webrender#432 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e UltraBlame original commit: c57538159933d9eb1840437dfa9c9860220dd805
…render_dispatcher); r=emilio <!-- Please describe your changes on the following line: --> This is the final step to provide WebGL support on Windows ;) Some Related PRs already merged in webrender and offscreen-gl-context: servo/surfman#64 servo/webrender#432 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e UltraBlame original commit: c57538159933d9eb1840437dfa9c9860220dd805
…render_dispatcher); r=emilio <!-- Please describe your changes on the following line: --> This is the final step to provide WebGL support on Windows ;) Some Related PRs already merged in webrender and offscreen-gl-context: servo/surfman#64 servo/webrender#432 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e UltraBlame original commit: c57538159933d9eb1840437dfa9c9860220dd805
Implement GLContextDispatcher trait for NativeGLContexts. Required to allow GLContext sharing in some implementations like WGL.
See servo/surfman#69 for more info.
This change is