diff options
-rw-r--r-- | components/compositing/constellation.rs | 44 | ||||
-rw-r--r-- | components/compositing/pipeline.rs | 7 | ||||
-rw-r--r-- | components/gfx/paint_task.rs | 6 | ||||
-rw-r--r-- | components/msg/constellation_msg.rs | 8 |
4 files changed, 50 insertions, 15 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 9e27d446432..002db169222 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -27,6 +27,7 @@ use layout_traits::{LayoutControlChan, LayoutTaskFactory}; use msg::compositor_msg::Epoch; use msg::constellation_msg::AnimationState; use msg::constellation_msg::CompositorMsg as FromCompositorMsg; +use msg::constellation_msg::PaintMsg as FromPaintMsg; use msg::constellation_msg::ScriptMsg as FromScriptMsg; use msg::constellation_msg::WebDriverCommandMsg; use msg::constellation_msg::{FrameId, PipelineId}; @@ -86,12 +87,18 @@ pub struct Constellation<LTF, STF> { /// A channel through which compositor messages can be sent to this object. pub compositor_sender: Sender<FromCompositorMsg>, + /// A channel through which paint task messages can be sent to this object. + pub painter_sender: ConstellationChan<FromPaintMsg>, + /// Receives messages from scripts. pub script_receiver: Receiver<FromScriptMsg>, /// Receives messages from the compositor pub compositor_receiver: Receiver<FromCompositorMsg>, + /// Receives messages from paint task. + pub painter_receiver: Receiver<FromPaintMsg>, + /// A channel (the implementation of which is port-specific) through which messages can be sent /// to the compositor. pub compositor_proxy: Box<CompositorProxy>, @@ -275,16 +282,19 @@ enum ChildProcess { impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { pub fn start(state: InitialConstellationState) -> Sender<FromCompositorMsg> { let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::<FromScriptMsg>::new(); - //let (script_receiver, script_sender) = channel(); let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver); let (compositor_sender, compositor_receiver) = channel(); + let (ipc_painter_receiver, ipc_painter_sender) = ConstellationChan::<FromPaintMsg>::new(); + let painter_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_painter_receiver); let compositor_sender_clone = compositor_sender.clone(); spawn_named("Constellation".to_owned(), move || { let mut constellation: Constellation<LTF, STF> = Constellation { script_sender: ipc_script_sender, compositor_sender: compositor_sender_clone, + painter_sender: ipc_painter_sender, script_receiver: script_receiver, compositor_receiver: compositor_receiver, + painter_receiver: painter_receiver, compositor_proxy: state.compositor_proxy, devtools_chan: state.devtools_chan, resource_task: state.resource_task, @@ -357,6 +367,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { id: pipeline_id, parent_info: parent_info, constellation_chan: self.script_sender.clone(), + painter_chan: self.painter_sender.clone(), scheduler_chan: self.scheduler_chan.clone(), compositor_proxy: self.compositor_proxy.clone_compositor_proxy(), devtools_chan: self.devtools_chan.clone(), @@ -458,17 +469,21 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { fn handle_request(&mut self) -> bool { enum Request { Script(FromScriptMsg), - Compositor(FromCompositorMsg) + Compositor(FromCompositorMsg), + Paint(FromPaintMsg) } let request = { let receiver_from_script = &self.script_receiver; let receiver_from_compositor = &self.compositor_receiver; + let receiver_from_paint = &self.painter_receiver; select! { msg = receiver_from_script.recv() => Request::Script(msg.unwrap()), msg = receiver_from_compositor.recv() => - Request::Compositor(msg.unwrap()) + Request::Compositor(msg.unwrap()), + msg = receiver_from_paint.recv() => + Request::Paint(msg.unwrap()) } }; @@ -548,6 +563,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { Request::Script(FromScriptMsg::Failure(Failure { pipeline_id, parent_info })) => { + debug!("handling script failure message from pipeline {:?}, {:?}", pipeline_id, parent_info); self.handle_failure_msg(pipeline_id, parent_info); } Request::Script(FromScriptMsg::ScriptLoadedURLInIFrame(load_info)) => { @@ -585,11 +601,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { debug!("constellation got navigation message from script"); self.handle_navigate_msg(pipeline_info, direction); } - // Notification that painting has finished and is requesting permission to paint. - Request::Script(FromScriptMsg::PainterReady(pipeline_id)) => { - debug!("constellation got painter ready message"); - self.handle_painter_ready_msg(pipeline_id); - } Request::Script(FromScriptMsg::MozBrowserEvent(pipeline_id, subpage_id, event)) => { @@ -647,6 +658,21 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { debug!("constellation got NodeStatus message"); self.compositor_proxy.send(ToCompositorMsg::Status(message)); } + + + // Messages from paint task + + + // Notification that painting has finished and is requesting permission to paint. + Request::Paint(FromPaintMsg::Ready(pipeline_id)) => { + debug!("constellation got painter ready message"); + self.handle_painter_ready_msg(pipeline_id); + } + Request::Paint(FromPaintMsg::Failure(Failure { pipeline_id, parent_info })) => { + debug!("handling paint failure message from pipeline {:?}, {:?}", pipeline_id, parent_info); + self.handle_failure_msg(pipeline_id, parent_info); + } + } true } @@ -669,8 +695,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { fn handle_failure_msg(&mut self, pipeline_id: PipelineId, parent_info: Option<(PipelineId, SubpageId)>) { - debug!("handling failure message from pipeline {:?}, {:?}", pipeline_id, parent_info); - if opts::get().hard_fail { // It's quite difficult to make Servo exit cleanly if some tasks have failed. // Hard fail exists for test runners so we crash and that's good enough. diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index 2fbc5c6b0a6..14ca16c016f 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -15,6 +15,7 @@ use ipc_channel::router::ROUTER; use layers::geometry::DevicePixel; use layout_traits::{LayoutControlChan, LayoutTaskFactory}; use msg::compositor_msg::ScriptToCompositorMsg; +use msg::constellation_msg::PaintMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId}; use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData}; @@ -81,6 +82,8 @@ pub struct InitialPipelineState { pub parent_info: Option<(PipelineId, SubpageId)>, /// A channel to the associated constellation. pub constellation_chan: ConstellationChan<ConstellationMsg>, + /// A channel to the associated paint task. + pub painter_chan: ConstellationChan<PaintMsg>, /// A channel to schedule timer events. pub scheduler_chan: IpcSender<TimerEventRequest>, /// A channel to the compositor. @@ -226,6 +229,7 @@ impl Pipeline { let privileged_pipeline_content = PrivilegedPipelineContent { id: state.id, constellation_chan: state.constellation_chan, + painter_chan: state.painter_chan, compositor_proxy: state.compositor_proxy, font_cache_task: state.font_cache_task, time_profiler_chan: state.time_profiler_chan, @@ -429,6 +433,7 @@ impl UnprivilegedPipelineContent { pub struct PrivilegedPipelineContent { id: PipelineId, constellation_chan: ConstellationChan<ConstellationMsg>, + painter_chan: ConstellationChan<PaintMsg>, compositor_proxy: Box<CompositorProxy + Send + 'static>, script_to_compositor_port: Option<IpcReceiver<ScriptToCompositorMsg>>, font_cache_task: FontCacheTask, @@ -464,7 +469,7 @@ impl PrivilegedPipelineContent { mem::replace(&mut self.layout_to_paint_port, None).unwrap(), mem::replace(&mut self.chrome_to_paint_port, None).unwrap(), self.compositor_proxy.clone_compositor_proxy(), - self.constellation_chan.clone(), + self.painter_chan.clone(), self.font_cache_task.clone(), self.failure.clone(), self.time_profiler_chan.clone(), diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index d3859e30651..6a91da70089 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -21,7 +21,7 @@ use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet}; use layers::platform::surface::{NativeDisplay, NativeSurface}; use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerKind, LayerProperties}; use msg::compositor_msg::{PaintListener, ScrollPolicy}; -use msg::constellation_msg::ScriptMsg as ConstellationMsg; +use msg::constellation_msg::PaintMsg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use paint_context::PaintContext; use profile_traits::mem::{self, ReportsChan}; @@ -330,7 +330,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static { if !self.paint_permission { debug!("PaintTask: paint ready msg"); let ConstellationChan(ref mut c) = self.constellation_chan; - c.send(ConstellationMsg::PainterReady(self.id)).unwrap(); + c.send(ConstellationMsg::Ready(self.id)).unwrap(); continue; } @@ -345,7 +345,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static { if !self.paint_permission { debug!("PaintTask: paint ready msg"); let ConstellationChan(ref mut c) = self.constellation_chan; - c.send(ConstellationMsg::PainterReady(self.id)).unwrap(); + c.send(ConstellationMsg::Ready(self.id)).unwrap(); continue; } diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index e01ff1c9347..af44eac4c1b 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -294,7 +294,6 @@ pub enum ScriptMsg { NewFavicon(Url), /// Status message to be displayed in the chrome, eg. a link URL on mouseover. NodeStatus(Option<String>), - PainterReady(PipelineId), /// Notification that this iframe should be removed. RemoveIFrame(PipelineId), ScriptLoadedURLInIFrame(IframeLoadInfo), @@ -306,6 +305,13 @@ pub enum ScriptMsg { ViewportConstrained(PipelineId, ViewportConstraints), } +/// Messages from the paint task to the constellation. +#[derive(Deserialize, Serialize)] +pub enum PaintMsg { + Ready(PipelineId), + Failure(Failure), +} + #[derive(Clone, Eq, PartialEq, Deserialize, Serialize, Debug)] pub enum AnimationState { AnimationsPresent, |