diff options
Diffstat (limited to 'src/components/msg/compositor_msg.rs')
-rw-r--r-- | src/components/msg/compositor_msg.rs | 82 |
1 files changed, 72 insertions, 10 deletions
diff --git a/src/components/msg/compositor_msg.rs b/src/components/msg/compositor_msg.rs index 847a13d1ab7..1d5307f5f95 100644 --- a/src/components/msg/compositor_msg.rs +++ b/src/components/msg/compositor_msg.rs @@ -2,17 +2,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use azure::azure_hl::Color; use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; -use azure::azure_hl::Color; use layers::platform::surface::{NativeGraphicsMetadata, NativePaintingGraphicsContext}; use layers::platform::surface::{NativeSurface, NativeSurfaceMethods}; +use serialize::{Encoder, Encodable}; +use std::fmt::{Formatter, Show}; +use std::fmt; use constellation_msg::PipelineId; -use serialize::{Encoder, Encodable}; - pub struct LayerBuffer { /// The native surface which can be shared between threads or processes. On Mac this is an /// `IOSurface`; on Linux this is an X Pixmap; on Android this is an `EGLImageKHR`. @@ -76,15 +77,73 @@ impl Epoch { } } +#[deriving(Clone, Eq)] +pub struct LayerId(uint, uint); + +impl Show for LayerId { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + let LayerId(a, b) = *self; + write!(f.buf, "Layer({}, {})", a, b); + Ok(()) + } +} + +impl LayerId { + /// FIXME(pcwalton): This is unfortunate. Maybe remove this in the future. + pub fn null() -> LayerId { + LayerId(0, 0) + } +} + +/// The scrolling policy of a layer. +#[deriving(Eq)] +pub enum ScrollPolicy { + /// These layers scroll when the parent receives a scrolling message. + Scrollable, + /// These layers do not scroll when the parent receives a scrolling message. + FixedPosition, +} + +/// All layer-specific information that the painting task sends to the compositor other than the +/// buffer contents of the layer itself. +pub struct LayerMetadata { + /// An opaque ID. This is usually the address of the flow and index of the box within it. + id: LayerId, + /// The position and size of the layer in pixels. + rect: Rect<uint>, + /// The background color of the layer. + color: Color, + /// The scrolling policy of this layer. + scroll_policy: ScrollPolicy, +} + /// The interface used by the renderer to acquire draw targets for each render frame and /// submit them to be drawn to the display. pub trait RenderListener { fn get_graphics_metadata(&self) -> Option<NativeGraphicsMetadata>; - fn new_layer(&self, PipelineId, Size2D<uint>); - fn set_layer_page_size_and_color(&self, PipelineId, Size2D<uint>, Epoch, Color); - fn set_layer_clip_rect(&self, PipelineId, Rect<uint>); - fn delete_layer(&self, PipelineId); - fn paint(&self, id: PipelineId, layer_buffer_set: ~LayerBufferSet, Epoch); + fn create_layer_group_for_pipeline(&self, PipelineId, Size2D<uint>); + + /// Informs the compositor of the layers for the given pipeline. The compositor responds by + /// creating and/or destroying render layers as necessary. + fn initialize_layers_for_pipeline(&self, + pipeline_id: PipelineId, + metadata: ~[LayerMetadata], + epoch: Epoch); + + fn set_layer_clip_rect(&self, + pipeline_id: PipelineId, + layer_id: LayerId, + new_rect: Rect<uint>); + + fn delete_layer_group(&self, PipelineId); + + /// Sends new tiles for the given layer to the compositor. + fn paint(&self, + pipeline_id: PipelineId, + layer_id: LayerId, + layer_buffer_set: ~LayerBufferSet, + epoch: Epoch); + fn set_render_state(&self, render_state: RenderState); } @@ -92,8 +151,11 @@ pub trait RenderListener { /// which is used in displaying the appropriate message in the window's title. pub trait ScriptListener : Clone { fn set_ready_state(&self, ReadyState); - fn invalidate_rect(&self, PipelineId, Rect<uint>); - fn scroll_fragment_point(&self, PipelineId, Point2D<f32>); + fn invalidate_rect(&self, pipeline_id: PipelineId, layer_id: LayerId, rect: Rect<uint>); + fn scroll_fragment_point(&self, + pipeline_id: PipelineId, + layer_id: LayerId, + point: Point2D<f32>); fn close(&self); fn dup(&self) -> ~ScriptListener; } |