From ad751e4926246db6f907fb00a1980f7580c75c8f Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 6 Jan 2015 07:23:26 -0800 Subject: [PATCH 1/2] Rename Compositor messages SetIds and Paint These names no longer reflect what the messages do, so rename them to SetFrameTree and AssignPaintedBuffers. --- components/compositing/compositor.rs | 44 +++++++++++------------ components/compositing/compositor_task.rs | 26 +++++++------- components/compositing/constellation.rs | 8 ++--- components/compositing/headless.rs | 6 ++-- components/gfx/paint_task.rs | 2 +- components/msg/compositor_msg.rs | 10 +++--- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 40d0f56dfa7..654bedbf941 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -113,8 +113,8 @@ pub struct IOCompositor { /// many times for a single page. got_load_complete_message: bool, - /// Whether we have gotten a `SetIds` message. - got_set_ids_message: bool, + /// Whether we have received a `SetFrameTree` message. + got_set_frame_tree_message: bool, /// The channel on which messages can be sent to the constellation. constellation_chan: ConstellationChan, @@ -195,7 +195,7 @@ impl IOCompositor { ready_states: HashMap::new(), paint_states: HashMap::new(), got_load_complete_message: false, - got_set_ids_message: false, + got_set_frame_tree_message: false, constellation_chan: constellation_chan, time_profiler_chan: time_profiler_chan, memory_profiler_chan: memory_profiler_chan, @@ -268,7 +268,7 @@ impl IOCompositor { self.remove_outstanding_paint_msg(); } - (Msg::SetIds(frame_tree, response_chan, new_constellation_chan), + (Msg::SetFrameTree(frame_tree, response_chan, new_constellation_chan), ShutdownState::NotShuttingDown) => { self.set_frame_tree(&frame_tree, response_chan, @@ -300,9 +300,9 @@ impl IOCompositor { self.set_layer_origin(pipeline_id, layer_id, origin); } - (Msg::Paint(pipeline_id, epoch, replies), ShutdownState::NotShuttingDown) => { + (Msg::AssignPaintedBuffers(pipeline_id, epoch, replies), ShutdownState::NotShuttingDown) => { for (layer_id, new_layer_buffer_set) in replies.into_iter() { - self.paint(pipeline_id, layer_id, new_layer_buffer_set, epoch); + self.assign_painted_buffers(pipeline_id, layer_id, new_layer_buffer_set, epoch); } self.remove_outstanding_paint_msg(); } @@ -463,7 +463,7 @@ impl IOCompositor { self.constellation_chan = new_constellation_chan; self.send_window_size(); - self.got_set_ids_message = true; + self.got_set_frame_tree_message = true; self.composite_if_necessary(); } @@ -653,13 +653,13 @@ impl IOCompositor { self.send_buffer_requests_for_all_layers(); } - fn paint(&mut self, - pipeline_id: PipelineId, - layer_id: LayerId, - new_layer_buffer_set: Box, - epoch: Epoch) { + fn assign_painted_buffers(&mut self, + pipeline_id: PipelineId, + layer_id: LayerId, + new_layer_buffer_set: Box, + epoch: Epoch) { match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) { - Some(layer) => self.paint_to_layer(layer, new_layer_buffer_set, epoch), + Some(layer) => self.assign_painted_buffers_to_layer(layer, new_layer_buffer_set, epoch), None => { match self.paint_channels.entry(pipeline_id) { Occupied(entry) => { @@ -672,10 +672,10 @@ impl IOCompositor { } } - fn paint_to_layer(&mut self, - layer: Rc>, - new_layer_buffer_set: Box, - epoch: Epoch) { + fn assign_painted_buffers_to_layer(&mut self, + layer: Rc>, + new_layer_buffer_set: Box, + epoch: Epoch) { debug!("compositor received new frame at size {}x{}", self.window_size.width.get(), self.window_size.height.get()); @@ -1037,7 +1037,7 @@ impl IOCompositor { return false; } - if !self.got_set_ids_message { + if !self.got_set_frame_tree_message { return false; } @@ -1294,12 +1294,12 @@ impl CompositorEventListener for IOCompositor where Window: Wind fn repaint_synchronously(&mut self) { while self.shutdown_state != ShutdownState::ShuttingDown { let msg = self.port.recv_compositor_msg(); - let is_paint = match msg { - Msg::Paint(..) => true, + let received_new_buffers = match msg { + Msg::AssignPaintedBuffers(..) => true, _ => false, }; let keep_going = self.handle_browser_message(msg); - if is_paint { + if received_new_buffers { self.composite(); break } @@ -1317,7 +1317,7 @@ impl CompositorEventListener for IOCompositor where Window: Wind } // Drain compositor port, sometimes messages contain channels that are blocking - // another task from finishing (i.e. SetIds) + // another task from finishing (i.e. SetFrameTree). while self.port.try_recv_compositor_msg().is_some() {} // Tell the profiler, memory profiler, and scrolling timer to shut down. diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index 147bbe4b211..969c1ef0c53 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -129,11 +129,11 @@ impl PaintListener for Box { port.recv() } - fn paint(&mut self, - pipeline_id: PipelineId, - epoch: Epoch, - replies: Vec<(LayerId, Box)>) { - self.send(Msg::Paint(pipeline_id, epoch, replies)); + fn assign_painted_buffers(&mut self, + pipeline_id: PipelineId, + epoch: Epoch, + replies: Vec<(LayerId, Box)>) { + self.send(Msg::AssignPaintedBuffers(pipeline_id, epoch, replies)); } fn initialize_layers_for_pipeline(&mut self, @@ -170,8 +170,8 @@ pub enum Msg { Exit(Sender<()>), /// Informs the compositor that the constellation has completed shutdown. - /// Required because the constellation can have pending calls to make (e.g. SetIds) - /// at the time that we send it an ExitMsg. + /// Required because the constellation can have pending calls to make + /// (e.g. SetFrameTree) at the time that we send it an ExitMsg. ShutdownComplete, /// Requests the compositor's graphics metadata. Graphics metadata is what the painter needs @@ -191,8 +191,8 @@ pub enum Msg { SetLayerOrigin(PipelineId, LayerId, Point2D), /// Scroll a page in a window ScrollFragmentPoint(PipelineId, LayerId, Point2D), - /// Requests that the compositor paint the given layer buffer set for the given page size. - Paint(PipelineId, Epoch, Vec<(LayerId, Box)>), + /// Requests that the compositor assign the painted buffers to the given layers. + AssignPaintedBuffers(PipelineId, Epoch, Vec<(LayerId, Box)>), /// Alerts the compositor to the current status of page loading. ChangeReadyState(PipelineId, ReadyState), /// Alerts the compositor to the current status of painting. @@ -203,8 +203,8 @@ pub enum Msg { ChangePageLoadData(FrameId, LoadData), /// Alerts the compositor that a `PaintMsg` has been discarded. PaintMsgDiscarded, - /// Sets the channel to the current layout and paint tasks, along with their ID. - SetIds(SendableFrameTree, Sender<()>, ConstellationChan), + /// Replaces the current frame tree, typically called during main frame navigation. + SetFrameTree(SendableFrameTree, Sender<()>, ConstellationChan), /// Sends an updated version of the frame tree. FrameTreeUpdate(FrameTreeDiff, Sender<()>), /// The load of a page has completed. @@ -230,14 +230,14 @@ impl Show for Msg { Msg::CreateOrUpdateDescendantLayer(..) => write!(f, "CreateOrUpdateDescendantLayer"), Msg::SetLayerOrigin(..) => write!(f, "SetLayerOrigin"), Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"), - Msg::Paint(..) => write!(f, "Paint"), + Msg::AssignPaintedBuffers(..) => write!(f, "AssignPaintedBuffers"), Msg::ChangeReadyState(..) => write!(f, "ChangeReadyState"), Msg::ChangePaintState(..) => write!(f, "ChangePaintState"), Msg::ChangePageTitle(..) => write!(f, "ChangePageTitle"), Msg::ChangePageLoadData(..) => write!(f, "ChangePageLoadData"), Msg::PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"), Msg::FrameTreeUpdate(..) => write!(f, "FrameTreeUpdate"), - Msg::SetIds(..) => write!(f, "SetIds"), + Msg::SetFrameTree(..) => write!(f, "SetFrameTree"), Msg::LoadComplete => write!(f, "LoadComplete"), Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"), Msg::KeyEvent(..) => write!(f, "KeyEvent"), diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 9ec8fb9aaa6..14e5dabcdc1 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -1019,10 +1019,10 @@ impl Constellation { fn set_ids(&mut self, frame_tree: &Rc) { let (chan, port) = channel(); - debug!("Constellation sending SetIds"); - self.compositor_proxy.send(CompositorMsg::SetIds(frame_tree.to_sendable(), - chan, - self.chan.clone())); + debug!("Constellation sending SetFrameTree"); + self.compositor_proxy.send(CompositorMsg::SetFrameTree(frame_tree.to_sendable(), + chan, + self.chan.clone())); match port.recv_opt() { Ok(()) => { let mut iter = frame_tree.iter(); diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index a7464a6723a..1ae584ff5ea 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -86,7 +86,7 @@ impl CompositorEventListener for NullCompositor { chan.send(None); } - Msg::SetIds(_, response_chan, _) => { + Msg::SetFrameTree(_, response_chan, _) => { response_chan.send(()); } @@ -96,12 +96,12 @@ impl CompositorEventListener for NullCompositor { // Explicitly list ignored messages so that when we add a new one, // we'll notice and think about whether it needs a response, like - // SetIds. + // SetFrameTree. Msg::CreateOrUpdateRootLayer(..) | Msg::CreateOrUpdateDescendantLayer(..) | Msg::SetLayerOrigin(..) | - Msg::Paint(..) | + Msg::AssignPaintedBuffers(..) | Msg::ChangeReadyState(..) | Msg::ChangePaintState(..) | Msg::ScrollFragmentPoint(..) | diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 99e1454e945..2ba6a4882c4 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -278,7 +278,7 @@ impl PaintTask where C: PaintListener + Send { } debug!("PaintTask: returning surfaces"); - self.compositor.paint(self.id, self.epoch, replies); + self.compositor.assign_painted_buffers(self.id, self.epoch, replies); } Msg::UnusedBuffer(unused_buffers) => { debug!("PaintTask: Received {} unused buffers", unused_buffers.len()); diff --git a/components/msg/compositor_msg.rs b/components/msg/compositor_msg.rs index 9d280cef673..6c51bf827f5 100644 --- a/components/msg/compositor_msg.rs +++ b/components/msg/compositor_msg.rs @@ -94,11 +94,11 @@ pub trait PaintListener for Sized? { metadata: Vec, epoch: Epoch); - /// Sends new tiles for the given layer to the compositor. - fn paint(&mut self, - pipeline_id: PipelineId, - epoch: Epoch, - replies: Vec<(LayerId, Box)>); + /// Sends new buffers for the given layers to the compositor. + fn assign_painted_buffers(&mut self, + pipeline_id: PipelineId, + epoch: Epoch, + replies: Vec<(LayerId, Box)>); fn paint_msg_discarded(&mut self); fn set_paint_state(&mut self, PipelineId, PaintState); From 9ac759ed80554cc097e0d1c2282edf5d51d28482 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 6 Jan 2015 12:30:01 -0800 Subject: [PATCH 2/2] Fix root layer naming in the compositor The term "root layer" is used in the compositor to refer to both the pipeline root layer and the page background layer. This can be quite confusing. Instead, call the page background layer the "base layer," which is always the first child of the pipeline root layer. --- components/compositing/compositor.rs | 22 +++++++++++----------- components/compositing/compositor_task.rs | 6 +++--- components/compositing/headless.rs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 654bedbf941..3112540c2a9 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -282,8 +282,8 @@ impl IOCompositor { response_channel.send(()); } - (Msg::CreateOrUpdateRootLayer(layer_properties), ShutdownState::NotShuttingDown) => { - self.create_or_update_root_layer(layer_properties); + (Msg::CreateOrUpdateBaseLayer(layer_properties), ShutdownState::NotShuttingDown) => { + self.create_or_update_base_layer(layer_properties); } (Msg::CreateOrUpdateDescendantLayer(layer_properties), @@ -539,24 +539,24 @@ impl IOCompositor { } } - fn create_or_update_root_layer(&mut self, layer_properties: LayerProperties) { - let need_new_root_layer = !self.update_layer_if_exists(layer_properties); - if need_new_root_layer { + fn create_or_update_base_layer(&mut self, layer_properties: LayerProperties) { + let need_new_base_layer = !self.update_layer_if_exists(layer_properties); + if need_new_base_layer { let root_layer = self.find_pipeline_root_layer(layer_properties.pipeline_id); root_layer.update_layer_except_bounds(layer_properties); let root_layer_pipeline = root_layer.extra_data.borrow().pipeline.clone(); - let first_child = CompositorData::new_layer( + let base_layer = CompositorData::new_layer( root_layer_pipeline.clone(), layer_properties, WantsScrollEventsFlag::DoesntWantScrollEvents, opts::get().tile_size); - // Add the first child / base layer to the front of the child list, so that - // child iframe layers are painted on top of the base layer. These iframe - // layers were added previously when creating the layer tree skeleton in - // create_frame_tree_root_layers. - root_layer.children().insert(0, first_child); + // Add the base layer to the front of the child list, so that child + // iframe layers are painted on top of the base layer. These iframe + // layers were added previously when creating the layer tree + // skeleton in create_frame_tree_root_layers. + root_layer.children().insert(0, base_layer); } self.scroll_layer_to_fragment_point_if_necessary(layer_properties.pipeline_id, diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index 969c1ef0c53..6ceda64cbaf 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -147,7 +147,7 @@ impl PaintListener for Box { for metadata in metadata.iter() { let layer_properties = LayerProperties::new(pipeline_id, epoch, metadata); if first { - self.send(Msg::CreateOrUpdateRootLayer(layer_properties)); + self.send(Msg::CreateOrUpdateBaseLayer(layer_properties)); first = false } else { self.send(Msg::CreateOrUpdateDescendantLayer(layer_properties)); @@ -183,7 +183,7 @@ pub enum Msg { /// Tells the compositor to create the root layer for a pipeline if necessary (i.e. if no layer /// with that ID exists). - CreateOrUpdateRootLayer(LayerProperties), + CreateOrUpdateBaseLayer(LayerProperties), /// Tells the compositor to create a descendant layer for a pipeline if necessary (i.e. if no /// layer with that ID exists). CreateOrUpdateDescendantLayer(LayerProperties), @@ -226,7 +226,7 @@ impl Show for Msg { Msg::Exit(..) => write!(f, "Exit"), Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"), Msg::GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"), - Msg::CreateOrUpdateRootLayer(..) => write!(f, "CreateOrUpdateRootLayer"), + Msg::CreateOrUpdateBaseLayer(..) => write!(f, "CreateOrUpdateBaseLayer"), Msg::CreateOrUpdateDescendantLayer(..) => write!(f, "CreateOrUpdateDescendantLayer"), Msg::SetLayerOrigin(..) => write!(f, "SetLayerOrigin"), Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"), diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index 1ae584ff5ea..8b58d727292 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -98,7 +98,7 @@ impl CompositorEventListener for NullCompositor { // we'll notice and think about whether it needs a response, like // SetFrameTree. - Msg::CreateOrUpdateRootLayer(..) | + Msg::CreateOrUpdateBaseLayer(..) | Msg::CreateOrUpdateDescendantLayer(..) | Msg::SetLayerOrigin(..) | Msg::AssignPaintedBuffers(..) |