aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlcanvaselement.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-07-25 01:50:31 -0600
committerbors-servo <metajack+bors@gmail.com>2015-07-25 01:50:31 -0600
commit1764267379a00b96a1df89f3917299a0c6fd325c (patch)
tree15641e7ed77b46ab61bab772fa3c63b7e8e8d619 /components/script/dom/htmlcanvaselement.rs
parent886c08c393f51499490702eaf97fc770273a2600 (diff)
parentbb99b2f3c8813919c476930c709b73d3cfbc8c83 (diff)
downloadservo-1764267379a00b96a1df89f3917299a0c6fd325c.tar.gz
servo-1764267379a00b96a1df89f3917299a0c6fd325c.zip
Auto merge of #6616 - pcwalton:canvas-webgl-ipc, r=jdm
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. r? @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6616) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlcanvaselement.rs')
-rw-r--r--components/script/dom/htmlcanvaselement.rs29
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