diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index 1bcf294d3b6..85d92ee1e8f 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -125,12 +125,12 @@ impl<'a> CanvasPaintThread<'a> { /// sender for it. pub fn start(size: Size2D, webrender_api_sender: Option) - -> (IpcSender, Sender) { + -> IpcSender { // TODO(pcwalton): Ask the pipeline to create this for us instead of spawning it directly. // This will be needed for multiprocess Servo. let (out_of_process_chan, out_of_process_port) = ipc::channel::().unwrap(); let (in_process_chan, in_process_port) = channel(); - ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone()); + ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan); spawn_named("CanvasThread".to_owned(), move || { let mut painter = CanvasPaintThread::new(size, webrender_api_sender); loop { @@ -217,7 +217,7 @@ impl<'a> CanvasPaintThread<'a> { } }); - (out_of_process_chan, in_process_chan) + out_of_process_chan } fn save_context_state(&mut self) { diff --git a/components/canvas/webgl_paint_thread.rs b/components/canvas/webgl_paint_thread.rs index f1bce9343bf..08d8ea2f4b6 100644 --- a/components/canvas/webgl_paint_thread.rs +++ b/components/canvas/webgl_paint_thread.rs @@ -62,7 +62,7 @@ impl WebGLPaintThread { pub fn start(size: Size2D, attrs: GLContextAttributes, webrender_api_sender: Option) - -> Result<(IpcSender, Sender), String> { + -> Result, String> { let (in_process_chan, in_process_port) = channel(); let (result_chan, result_port) = channel(); spawn_named("WebGLThread".to_owned(), move || { @@ -106,8 +106,8 @@ impl WebGLPaintThread { result_port.recv().unwrap().map(|_| { let (out_of_process_chan, out_of_process_port) = ipc::channel::().unwrap(); - ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone()); - (out_of_process_chan, in_process_chan) + ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan); + out_of_process_chan }) } diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index a8d7952efaf..a7a958e3101 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -170,12 +170,6 @@ pub struct Constellation { /// Bits of state used to interact with the webdriver implementation webdriver: WebDriverData, - /// A list of in-process senders to `CanvasPaintThread`s. - canvas_paint_threads: Vec>, - - /// A list of in-process senders to `WebGLPaintThread`s. - webgl_paint_threads: Vec>, - scheduler_chan: IpcSender, /// A list of child content processes. @@ -349,8 +343,6 @@ impl Constellation None }, webdriver: WebDriverData::new(), - canvas_paint_threads: Vec::new(), - webgl_paint_threads: Vec::new(), scheduler_chan: TimerScheduler::start(), child_processes: Vec::new(), document_states: HashMap::new(), @@ -1206,31 +1198,21 @@ impl Constellation fn handle_create_canvas_paint_thread_msg( &mut self, size: &Size2D, - response_sender: IpcSender<(IpcSender, usize)>) { - let id = self.canvas_paint_threads.len(); + response_sender: IpcSender>) { let webrender_api = self.webrender_api_sender.clone(); - let (out_of_process_sender, in_process_sender) = CanvasPaintThread::start(*size, - webrender_api); - self.canvas_paint_threads.push(in_process_sender); - response_sender.send((out_of_process_sender, id)).unwrap() + let sender = CanvasPaintThread::start(*size, webrender_api); + response_sender.send(sender).unwrap() } fn handle_create_webgl_paint_thread_msg( &mut self, size: &Size2D, attributes: GLContextAttributes, - response_sender: IpcSender, usize), String>>) { + response_sender: IpcSender, String>>) { let webrender_api = self.webrender_api_sender.clone(); - let response = match WebGLPaintThread::start(*size, attributes, webrender_api) { - Ok((out_of_process_sender, in_process_sender)) => { - let id = self.webgl_paint_threads.len(); - self.webgl_paint_threads.push(in_process_sender); - Ok((out_of_process_sender, id)) - }, - Err(msg) => Err(msg), - }; + let sender = WebGLPaintThread::start(*size, attributes, webrender_api); - response_sender.send(response).unwrap() + response_sender.send(sender).unwrap() } fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) { diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 4ab2858496c..8c1c54fd282 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -316,7 +316,6 @@ impl InlineAbsoluteFragmentInfo { #[derive(Clone)] pub struct CanvasFragmentInfo { pub replaced_image_fragment_info: ReplacedImageFragmentInfo, - pub renderer_id: Option, pub ipc_renderer: Option>>>, pub dom_width: Au, pub dom_height: Au, @@ -326,7 +325,6 @@ impl CanvasFragmentInfo { pub fn new(node: &N, data: HTMLCanvasData) -> CanvasFragmentInfo { CanvasFragmentInfo { replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node), - renderer_id: data.renderer_id, ipc_renderer: data.ipc_renderer .map(|renderer| Arc::new(Mutex::new(renderer))), dom_width: Au::from_px(data.width as i32), diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 97574187038..aa5c7d9f72b 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -62,7 +62,6 @@ enum CanvasFillOrStrokeStyle { #[dom_struct] pub struct CanvasRenderingContext2D { reflector_: Reflector, - renderer_id: usize, #[ignore_heap_size_of = "Defined in ipc-channel"] ipc_renderer: IpcSender, canvas: JS, @@ -125,10 +124,9 @@ impl CanvasRenderingContext2D { let (sender, receiver) = ipc::channel().unwrap(); let constellation_chan = global.constellation_chan(); constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintThread(size, sender)).unwrap(); - let (ipc_renderer, renderer_id) = receiver.recv().unwrap(); + let ipc_renderer = receiver.recv().unwrap(); CanvasRenderingContext2D { reflector_: Reflector::new(), - renderer_id: renderer_id, ipc_renderer: ipc_renderer, canvas: JS::from_ref(canvas), state: DOMRefCell::new(CanvasContextState::new()), @@ -501,9 +499,6 @@ impl CanvasRenderingContext2D { } } - pub fn get_renderer_id(&self) -> usize { - self.renderer_id - } pub fn get_ipc_renderer(&self) -> IpcSender { self.ipc_renderer.clone() } @@ -518,17 +513,11 @@ impl CanvasRenderingContext2D { } pub trait LayoutCanvasRenderingContext2DHelpers { - #[allow(unsafe_code)] - unsafe fn get_renderer_id(&self) -> usize; #[allow(unsafe_code)] unsafe fn get_ipc_renderer(&self) -> IpcSender; } impl LayoutCanvasRenderingContext2DHelpers for LayoutJS { - #[allow(unsafe_code)] - unsafe fn get_renderer_id(&self) -> usize { - (*self.unsafe_get()).renderer_id - } #[allow(unsafe_code)] unsafe fn get_ipc_renderer(&self) -> IpcSender { (*self.unsafe_get()).ipc_renderer.clone() diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 0288efc206a..b078e87fe45 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -94,7 +94,6 @@ impl HTMLCanvasElement { } pub struct HTMLCanvasData { - pub renderer_id: Option, pub ipc_renderer: Option>, pub width: u32, pub height: u32, @@ -109,22 +108,20 @@ impl LayoutHTMLCanvasElementHelpers for LayoutJS { fn data(&self) -> HTMLCanvasData { unsafe { let canvas = &*self.unsafe_get(); - let (renderer_id, ipc_renderer) = match canvas.context.borrow_for_layout().as_ref() { - Some(&CanvasContext::Context2d(ref context)) => { - let context = context.to_layout(); - (Some(context.get_renderer_id()), Some(context.get_ipc_renderer())) - }, - Some(&CanvasContext::WebGL(ref context)) => { - let context = context.to_layout(); - (Some(context.get_renderer_id()), Some(context.get_ipc_renderer())) - }, - None => (None, None), - }; + let ipc_renderer = canvas.context.borrow_for_layout().as_ref().map(|context| { + match *context { + CanvasContext::Context2d(ref context) => { + context.to_layout().get_ipc_renderer() + }, + CanvasContext::WebGL(ref context) => { + context.to_layout().get_ipc_renderer() + }, + } + }); let width_attr = canvas.upcast::().get_attr_for_layout(&ns!(), &atom!("width")); let height_attr = canvas.upcast::().get_attr_for_layout(&ns!(), &atom!("height")); HTMLCanvasData { - renderer_id: renderer_id, ipc_renderer: ipc_renderer, width: width_attr.map_or(DEFAULT_WIDTH, |val| val.as_uint()), height: height_attr.map_or(DEFAULT_HEIGHT, |val| val.as_uint()), diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index aba9e32b45f..5251585ea94 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -68,7 +68,6 @@ bitflags! { #[dom_struct] pub struct WebGLRenderingContext { reflector_: Reflector, - renderer_id: usize, #[ignore_heap_size_of = "Defined in ipc-channel"] ipc_renderer: IpcSender, canvas: JS, @@ -95,10 +94,9 @@ impl WebGLRenderingContext { .unwrap(); let result = receiver.recv().unwrap(); - result.map(|(ipc_renderer, renderer_id)| { + result.map(|ipc_renderer| { WebGLRenderingContext { reflector_: Reflector::new(), - renderer_id: renderer_id, ipc_renderer: ipc_renderer, canvas: JS::from_ref(canvas), last_error: Cell::new(None), @@ -1194,17 +1192,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } pub trait LayoutCanvasWebGLRenderingContextHelpers { - #[allow(unsafe_code)] - unsafe fn get_renderer_id(&self) -> usize; #[allow(unsafe_code)] unsafe fn get_ipc_renderer(&self) -> IpcSender; } impl LayoutCanvasWebGLRenderingContextHelpers for LayoutJS { - #[allow(unsafe_code)] - unsafe fn get_renderer_id(&self) -> usize { - (*self.unsafe_get()).renderer_id - } #[allow(unsafe_code)] unsafe fn get_ipc_renderer(&self) -> IpcSender { (*self.unsafe_get()).ipc_renderer.clone() diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 73da909cb5f..5b6afa3db1e 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -39,12 +39,12 @@ pub enum ScriptMsg { ChangeRunningAnimationsState(PipelineId, AnimationState), /// Requests that a new 2D canvas thread be created. (This is done in the constellation because /// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.) - CreateCanvasPaintThread(Size2D, IpcSender<(IpcSender, usize)>), + CreateCanvasPaintThread(Size2D, IpcSender>), /// Requests that a new WebGL thread be created. (This is done in the constellation because /// WebGL uses the GPU and we don't want to give untrusted content access to the GPU.) CreateWebGLPaintThread(Size2D, GLContextAttributes, - IpcSender, usize), String>>), + IpcSender, String>>), /// Dispatched after the DOM load event has fired on a document /// Causes a `load` event to be dispatched to any enclosing frame context element /// for the given pipeline.