diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index 28b7fec5413..97d3b2d12d1 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::{self, IpcSender}; +use ipc_channel::ipc::{self, IpcSender, IpcReceiver}; use num_traits::ToPrimitive; use std::borrow::ToOwned; use std::mem; @@ -118,9 +118,8 @@ impl<'a> CanvasPaintThread<'a> { /// communicate with it. pub fn start(size: Size2D, webrender_api_sender: webrender_api::RenderApiSender, - antialias: bool) - -> IpcSender { - let (sender, receiver) = ipc::channel::().unwrap(); + antialias: bool, + receiver: IpcReceiver) { let antialias = if antialias { AntialiasMode::Default } else { @@ -216,8 +215,6 @@ 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 2eb19e921a5..75a6b2ad139 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, sender) => { + FromScriptMsg::CreateCanvasPaintThread(size, receiver) => { debug!("constellation got create-canvas-paint-thread message"); - self.handle_create_canvas_paint_thread_msg(&size, sender) + self.handle_create_canvas_paint_thread_msg(&size, receiver) } FromScriptMsg::NodeStatus(message) => { debug!("constellation got NodeStatus message"); @@ -2264,13 +2264,12 @@ impl Constellation fn handle_create_canvas_paint_thread_msg( &mut self, size: &Size2D, - response_sender: IpcSender>) { + receiver: IpcReceiver) { let webrender_api = self.webrender_api_sender.clone(); - 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); - } + CanvasPaintThread::start(*size, + webrender_api, + opts::get().enable_canvas_antialiasing, + receiver); } fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) { diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 93d4981d2bb..1c9dc16c445 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -129,11 +129,10 @@ impl CanvasRenderingContext2D { size: Size2D) -> CanvasRenderingContext2D { debug!("Creating new canvas rendering context."); - let (sender, receiver) = ipc::channel().unwrap(); + let (ipc_renderer, 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, sender)).unwrap(); - let ipc_renderer = receiver.recv().unwrap(); + script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, receiver)).unwrap(); debug!("Done."); CanvasRenderingContext2D { reflector_: Reflector::new(), diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index a9b5f86d8fe..fdef5cf7a17 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, IpcSender>), + CreateCanvasPaintThread(Size2D, IpcReceiver), /// Notifies the constellation that this frame has received focus. Focus, /// Forward an event that was sent to the parent window.