diff options
author | Martin Robinson <mrobinson@igalia.com> | 2015-06-30 16:32:14 -0700 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2015-07-08 08:05:11 -0700 |
commit | e115c3d3c4996dd9014f0314be3f03f6ba106ee9 (patch) | |
tree | bd9983cb03eb5cab17fb0a475aa878a71a59ac1a /components/compositing/compositor_layer.rs | |
parent | 2e1c9785dc5725f809c56b7bafb7a3a68fb1dca0 (diff) | |
download | servo-e115c3d3c4996dd9014f0314be3f03f6ba106ee9.tar.gz servo-e115c3d3c4996dd9014f0314be3f03f6ba106ee9.zip |
Move LayerBuffer cache to the compositor
Now that NativeDisplay can be shared between the compositor and the
paint task, we can move the LayerBuffer cache to the compositor. This
allows surfaces to be potentially reused between different paint tasks
and will eventually allow OpenGL contexts to be preserved between
instances of GL rasterization.
Diffstat (limited to 'components/compositing/compositor_layer.rs')
-rw-r--r-- | components/compositing/compositor_layer.rs | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/components/compositing/compositor_layer.rs b/components/compositing/compositor_layer.rs index 1be9df64ca9..707b7ce06b6 100644 --- a/components/compositing/compositor_layer.rs +++ b/components/compositing/compositor_layer.rs @@ -10,7 +10,6 @@ use euclid::length::Length; use euclid::point::{Point2D, TypedPoint2D}; use euclid::size::TypedSize2D; use euclid::rect::Rect; -use gfx::paint_task::Msg as PaintMsg; use layers::color::Color; use layers::geometry::LayerPixel; use layers::layers::{Layer, LayerBufferSet}; @@ -76,25 +75,25 @@ pub trait CompositorLayer { fn update_layer(&self, layer_properties: LayerProperties); fn add_buffers<Window>(&self, - compositor: &IOCompositor<Window>, + compositor: &mut IOCompositor<Window>, new_buffers: Box<LayerBufferSet>, epoch: Epoch) where Window: WindowMethods; /// Destroys all layer tiles, sending the buffers back to the painter to be destroyed or /// reused. - fn clear<Window>(&self, compositor: &IOCompositor<Window>) where Window: WindowMethods; + fn clear<Window>(&self, compositor: &mut IOCompositor<Window>) where Window: WindowMethods; /// Destroys tiles for this layer and all descendent layers, sending the buffers back to the /// painter to be destroyed or reused. - fn clear_all_tiles<Window>(&self, compositor: &IOCompositor<Window>) + fn clear_all_tiles<Window>(&self, compositor: &mut IOCompositor<Window>) where Window: WindowMethods; /// Removes the root layer (and any children) for a given pipeline from the /// compositor. Buffers that the compositor is holding are returned to the /// owning paint task. fn remove_root_layer_with_pipeline_id<Window>(&self, - compositor: &IOCompositor<Window>, + compositor: &mut IOCompositor<Window>, pipeline_id: PipelineId) where Window: WindowMethods; @@ -214,7 +213,7 @@ impl CompositorLayer for Layer<CompositorData> { // If the epoch of the message does not match the layer's epoch, the message is ignored, the // layer buffer set is consumed, and None is returned. fn add_buffers<Window>(&self, - compositor: &IOCompositor<Window>, + compositor: &mut IOCompositor<Window>, new_buffers: Box<LayerBufferSet>, epoch: Epoch) where Window: WindowMethods { @@ -225,33 +224,21 @@ impl CompositorLayer for Layer<CompositorData> { self.add_buffer(buffer); } - let unused_buffers = self.collect_unused_buffers(); - if !unused_buffers.is_empty() { // send back unused buffers - let pipeline = compositor.get_pipeline(self.pipeline_id()); - let _ = pipeline.paint_chan.send(PaintMsg::UnusedBuffer(unused_buffers)); - } + compositor.cache_unused_buffers(self.collect_unused_buffers()) } - fn clear<Window>(&self, compositor: &IOCompositor<Window>) where Window: WindowMethods { - let mut buffers = self.collect_buffers(); + fn clear<Window>(&self, compositor: &mut IOCompositor<Window>) where Window: WindowMethods { + let buffers = self.collect_buffers(); if !buffers.is_empty() { - // We have no way of knowing without a race whether the paint task is even up and - // running, but mark the buffers as not leaking. If the paint task died, then the - // buffers are going to be cleaned up. - for buffer in buffers.iter_mut() { - buffer.mark_wont_leak() - } - - let pipeline = compositor.get_pipeline(self.pipeline_id()); - let _ = pipeline.paint_chan.send(PaintMsg::UnusedBuffer(buffers)); + compositor.cache_unused_buffers(buffers); } } /// Destroys tiles for this layer and all descendent layers, sending the buffers back to the /// painter to be destroyed or reused. fn clear_all_tiles<Window>(&self, - compositor: &IOCompositor<Window>) + compositor: &mut IOCompositor<Window>) where Window: WindowMethods { self.clear(compositor); for kid in self.children().iter() { @@ -260,7 +247,7 @@ impl CompositorLayer for Layer<CompositorData> { } fn remove_root_layer_with_pipeline_id<Window>(&self, - compositor: &IOCompositor<Window>, + compositor: &mut IOCompositor<Window>, pipeline_id: PipelineId) where Window: WindowMethods { // Find the child that is the root layer for this pipeline. |