diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-08-15 16:00:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 16:00:10 -0500 |
commit | 90f55ea4580e2a15f7d70d0491444f18b972d450 (patch) | |
tree | c85f3cb5d55babab03d56dac8b0d10d588b0a0f9 /components/script/dom/webglframebuffer.rs | |
parent | 2e60b27a2186a8cba4b952960155dfcf3f47d7db (diff) | |
parent | 703962fe61d673536eb982b45795ae13748f0f6a (diff) | |
download | servo-90f55ea4580e2a15f7d70d0491444f18b972d450.tar.gz servo-90f55ea4580e2a15f7d70d0491444f18b972d450.zip |
Auto merge of #17891 - MortimerGoro:webgl_move, r=glennw,emilio
Improved WebGL architecture
<!-- Please describe your changes on the following line: -->
Info about the big picture and the goals of the WebGL refactor in this thread: https://groups.google.com/forum/#!topic/mozilla.dev.servo/0WMGz60kKzQ
I tried to reduce this PR as much as possible as requested in the thread. I'll do separate PRs for other features (e.g.: Batch messages or use shared memory to improve frame times) or fixes.
Some tips to ease the review process:
- Most changes in DOM objects follow the same pattern (remove CanvasMsg wrapper and use the new sender method).
- WebGLCommands are the same ones as before (moved from webrender_api). So those lines are already reviewed.
- See WebGL traits in [components/canvas_traits/webgl.rs](https://github.com/servo/servo/pull/17891/files#diff-8701045d01505418701d0631d4d45562)
- See WebGLThread and WR External Image bridge in [components/canvas/webgl_thread.rs](https://github.com/servo/servo/pull/17891/files#diff-281554879f39a2a041f7a69d442a5d2e)
- The implementation submitted in this PR creates a single `WebGLThread` for all ScriptThread/Pipelines. See that in [components/canvas/webgl_mode/inprocess.rs](https://github.com/servo/servo/pull/17891/files#diff-250070c6c5a38c7f9fa0f5b3c101f68b)
The conformance tests will help to guarantee that we don't miss anything.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [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).
<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- 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/17891)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/webglframebuffer.rs')
-rw-r--r-- | components/script/dom/webglframebuffer.rs | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index bb486c80c38..7a6b1090064 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -3,7 +3,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::CanvasMsg; +use canvas_traits::webgl::{WebGLCommand, WebGLFramebufferBindingRequest, WebGLFramebufferId}; +use canvas_traits::webgl::{WebGLMsgSender, WebGLResult, WebGLError}; +use canvas_traits::webgl::webgl_channel; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::WebGLFramebufferBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -14,10 +16,7 @@ use dom::webglrenderbuffer::WebGLRenderbuffer; use dom::webgltexture::WebGLTexture; use dom::window::Window; use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSender; use std::cell::Cell; -use webrender_api; -use webrender_api::{WebGLCommand, WebGLFramebufferBindingRequest, WebGLFramebufferId, WebGLResult, WebGLError}; #[must_root] #[derive(JSTraceable, Clone, HeapSizeOf)] @@ -36,7 +35,7 @@ pub struct WebGLFramebuffer { size: Cell<Option<(i32, i32)>>, status: Cell<u32>, #[ignore_heap_size_of = "Defined in ipc-channel"] - renderer: IpcSender<CanvasMsg>, + renderer: WebGLMsgSender, // The attachment points for textures and renderbuffers on this // FBO. @@ -47,7 +46,7 @@ pub struct WebGLFramebuffer { } impl WebGLFramebuffer { - fn new_inherited(renderer: IpcSender<CanvasMsg>, + fn new_inherited(renderer: WebGLMsgSender, id: WebGLFramebufferId) -> WebGLFramebuffer { WebGLFramebuffer { @@ -65,17 +64,17 @@ impl WebGLFramebuffer { } } - pub fn maybe_new(window: &Window, renderer: IpcSender<CanvasMsg>) + pub fn maybe_new(window: &Window, renderer: WebGLMsgSender) -> Option<Root<WebGLFramebuffer>> { - let (sender, receiver) = webrender_api::channel::msg_channel().unwrap(); - renderer.send(CanvasMsg::WebGL(WebGLCommand::CreateFramebuffer(sender))).unwrap(); + let (sender, receiver) = webgl_channel().unwrap(); + renderer.send(WebGLCommand::CreateFramebuffer(sender)).unwrap(); let result = receiver.recv().unwrap(); result.map(|fb_id| WebGLFramebuffer::new(window, renderer, fb_id)) } pub fn new(window: &Window, - renderer: IpcSender<CanvasMsg>, + renderer: WebGLMsgSender, id: WebGLFramebufferId) -> Root<WebGLFramebuffer> { reflect_dom_object(box WebGLFramebuffer::new_inherited(renderer, id), @@ -98,13 +97,13 @@ impl WebGLFramebuffer { self.target.set(Some(target)); let cmd = WebGLCommand::BindFramebuffer(target, WebGLFramebufferBindingRequest::Explicit(self.id)); - self.renderer.send(CanvasMsg::WebGL(cmd)).unwrap(); + self.renderer.send(cmd).unwrap(); } pub fn delete(&self) { if !self.is_deleted.get() { self.is_deleted.set(true); - let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteFramebuffer(self.id))); + let _ = self.renderer.send(WebGLCommand::DeleteFramebuffer(self.id)); } } @@ -205,10 +204,10 @@ impl WebGLFramebuffer { } }; - self.renderer.send(CanvasMsg::WebGL(WebGLCommand::FramebufferRenderbuffer(constants::FRAMEBUFFER, - attachment, - constants::RENDERBUFFER, - rb_id))).unwrap(); + self.renderer.send(WebGLCommand::FramebufferRenderbuffer(constants::FRAMEBUFFER, + attachment, + constants::RENDERBUFFER, + rb_id)).unwrap(); self.update_status(); Ok(()) @@ -281,11 +280,11 @@ impl WebGLFramebuffer { } }; - self.renderer.send(CanvasMsg::WebGL(WebGLCommand::FramebufferTexture2D(constants::FRAMEBUFFER, - attachment, - textarget, - tex_id, - level))).unwrap(); + self.renderer.send(WebGLCommand::FramebufferTexture2D(constants::FRAMEBUFFER, + attachment, + textarget, + tex_id, + level)).unwrap(); self.update_status(); Ok(()) |