Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement GLContextDispatcher trait for NativeGLContexts #432
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>>>> | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MortimerGoro
Oct 5, 2016
Author
Contributor
I used the same type pattern as the one used in RenderNotifier setter
This comment has been minimized.
This comment has been minimized.
| @@ -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 { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MortimerGoro
Oct 5, 2016
Author
Contributor
Yeah, I'll add a macro. It will avoid unneeded allocations in the platforms that don't use this.
This comment has been minimized.
This comment has been minimized.
|
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. |
|
|
3cf4b78
to
a189acc
|
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 |
|
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 { |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 18, 2016
Member
nit:
let dispatcher = if cfg!(target_os = "windows") {
Some(...)
} else {
None
};
This comment has been minimized.
This comment has been minimized.
MortimerGoro
Oct 18, 2016
•
Author
Contributor
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. |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 18, 2016
Member
probably moving the last part of this comment to the main_thread_dispatcher member definition would make it a bit more helpful.
|
Done :) |
|
@bors-servo: r+ |
|
|
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 -->
|
|
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
MortimerGoro commentedOct 5, 2016
•
edited by larsbergstrom
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