From 0e211d0d8f297084304860e3181eb21880921333 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Mon, 18 Dec 2017 10:51:00 -0500 Subject: [PATCH] Revert "Send IPC receiver for canvas as part of CreateCanvasPaintThread message" This reverts commit a504c9358b70fcf02bd8f2067fcbd17d16c89439. --- components/canvas/canvas_paint_thread.rs | 9 ++++++--- components/constellation/constellation.rs | 15 ++++++++------- components/script/dom/canvasrenderingcontext2d.rs | 5 +++-- components/script_traits/script_msg.rs | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index a985ac7a999..bb644c60bef 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -11,7 +11,7 @@ use azure::azure_hl::SurfacePattern; use canvas_traits::canvas::*; use cssparser::RGBA; use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D}; -use ipc_channel::ipc::{IpcSender, IpcReceiver}; +use ipc_channel::ipc::{self, IpcSender, IpcReceiver}; use num_traits::ToPrimitive; use std::borrow::ToOwned; use std::mem; @@ -118,8 +118,9 @@ impl<'a> CanvasPaintThread<'a> { /// communicate with it. pub fn start(size: Size2D, webrender_api_sender: webrender_api::RenderApiSender, - antialias: bool, - receiver: IpcReceiver) { + antialias: bool) + -> IpcSender { + let (sender, receiver) = ipc::channel::().unwrap(); let antialias = if antialias { AntialiasMode::Default } else { @@ -215,6 +216,8 @@ impl<'a> CanvasPaintThread<'a> { } } }).expect("Thread spawning failed"); + + sender } fn save_context_state(&mut self) { diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 7539a4f149e..ec023e3971b 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1235,9 +1235,9 @@ impl Constellation self.embedder_proxy.send(EmbedderMsg::HeadParsed(source_top_ctx_id)); } } - FromScriptMsg::CreateCanvasPaintThread(size, receiver) => { + FromScriptMsg::CreateCanvasPaintThread(size, sender) => { debug!("constellation got create-canvas-paint-thread message"); - self.handle_create_canvas_paint_thread_msg(&size, receiver) + self.handle_create_canvas_paint_thread_msg(&size, sender) } FromScriptMsg::NodeStatus(message) => { debug!("constellation got NodeStatus message"); @@ -2264,12 +2264,13 @@ impl Constellation fn handle_create_canvas_paint_thread_msg( &mut self, size: &Size2D, - receiver: IpcReceiver) { + response_sender: IpcSender>) { let webrender_api = self.webrender_api_sender.clone(); - CanvasPaintThread::start(*size, - webrender_api, - opts::get().enable_canvas_antialiasing, - receiver); + let sender = CanvasPaintThread::start(*size, webrender_api, + opts::get().enable_canvas_antialiasing); + if let Err(e) = response_sender.send(sender) { + warn!("Create canvas paint thread response failed ({})", e); + } } fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) { diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 1c9dc16c445..93d4981d2bb 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -129,10 +129,11 @@ impl CanvasRenderingContext2D { size: Size2D) -> CanvasRenderingContext2D { debug!("Creating new canvas rendering context."); - let (ipc_renderer, receiver) = ipc::channel::().unwrap(); + let (sender, receiver) = ipc::channel().unwrap(); let script_to_constellation_chan = global.script_to_constellation_chan(); debug!("Asking constellation to create new canvas thread."); - script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, receiver)).unwrap(); + script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, sender)).unwrap(); + let ipc_renderer = receiver.recv().unwrap(); debug!("Done."); CanvasRenderingContext2D { reflector_: Reflector::new(), diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index fdef5cf7a17..a9b5f86d8fe 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -79,7 +79,7 @@ pub enum ScriptMsg { ChangeRunningAnimationsState(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, IpcReceiver), + CreateCanvasPaintThread(Size2D, IpcSender>), /// Notifies the constellation that this frame has received focus. Focus, /// Forward an event that was sent to the parent window.