diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2015-07-13 17:02:35 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2015-07-25 00:50:12 -0700 |
commit | bb99b2f3c8813919c476930c709b73d3cfbc8c83 (patch) | |
tree | 15641e7ed77b46ab61bab772fa3c63b7e8e8d619 /components/script/dom/htmlcanvaselement.rs | |
parent | 886c08c393f51499490702eaf97fc770273a2600 (diff) | |
download | servo-bb99b2f3c8813919c476930c709b73d3cfbc8c83.tar.gz servo-bb99b2f3c8813919c476930c709b73d3cfbc8c83.zip |
script: Make most of 2D canvas and WebGL run over IPC.
To actually make the multiprocess communication work, we'll need to
reroute the task creation to the pipeline or the compositor. But this
works as a first step.
Diffstat (limited to 'components/script/dom/htmlcanvaselement.rs')
-rw-r--r-- | components/script/dom/htmlcanvaselement.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index a01a2c4fe26..3c52d99ea4f 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use canvas_traits::CanvasMsg; use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding; @@ -27,12 +26,13 @@ use dom::webglrenderingcontext::{WebGLRenderingContext, LayoutCanvasWebGLRenderi use util::str::{DOMString, parse_unsigned_integer}; use js::jsapi::{JSContext, HandleValue}; use offscreen_gl_context::GLContextAttributes; +use canvas_traits::CanvasMsg; +use ipc_channel::ipc::IpcSender; use euclid::size::Size2D; use std::cell::Cell; use std::default::Default; -use std::sync::mpsc::Sender; const DEFAULT_WIDTH: u32 = 300; const DEFAULT_HEIGHT: u32 = 150; @@ -106,7 +106,9 @@ impl HTMLCanvasElement { pub trait LayoutHTMLCanvasElementHelpers { #[allow(unsafe_code)] - unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>>; + unsafe fn get_renderer_id(&self) -> Option<usize>; + #[allow(unsafe_code)] + unsafe fn get_ipc_renderer(&self) -> Option<IpcSender<CanvasMsg>>; #[allow(unsafe_code)] unsafe fn get_canvas_width(&self) -> u32; #[allow(unsafe_code)] @@ -115,14 +117,25 @@ pub trait LayoutHTMLCanvasElementHelpers { impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> { #[allow(unsafe_code)] - unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>> { + unsafe fn get_renderer_id(&self) -> Option<usize> { + let ref canvas = *self.unsafe_get(); + if let Some(context) = canvas.context.get() { + match context { + CanvasContext::Context2d(context) => Some(context.to_layout().get_renderer_id()), + CanvasContext::WebGL(context) => Some(context.to_layout().get_renderer_id()), + } + } else { + None + } + } + + #[allow(unsafe_code)] + unsafe fn get_ipc_renderer(&self) -> Option<IpcSender<CanvasMsg>> { let ref canvas = *self.unsafe_get(); if let Some(context) = canvas.context.get() { match context { - CanvasContext::Context2d(context) - => Some(context.to_layout().get_renderer()), - CanvasContext::WebGL(context) - => Some(context.to_layout().get_renderer()), + CanvasContext::Context2d(context) => Some(context.to_layout().get_ipc_renderer()), + CanvasContext::WebGL(context) => Some(context.to_layout().get_ipc_renderer()), } } else { None |