diff --git a/servo/src/components/compositing/compositor.rs b/servo/src/components/compositing/compositor.rs index c2ce7b546f53..affbc4cdda72 100644 --- a/servo/src/components/compositing/compositor.rs +++ b/servo/src/components/compositing/compositor.rs @@ -2,7 +2,7 @@ * 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 compositor_data::CompositorData; +use compositor_data::{CompositorData, WantsScrollEvents}; use compositor_task::{Msg, CompositorTask, Exit, ChangeReadyState, SetIds, LayerProperties}; use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer}; use compositor_task::{SetLayerClipRect, Paint, ScrollFragmentPoint, LoadComplete}; @@ -31,10 +31,9 @@ use layers::layers::LayerBufferSet; use layers::rendergl; use layers::rendergl::RenderContext; use layers::scene::Scene; -use layers::layers::Layer; use opengles::gl2; use png; -use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, IdleRenderState}; +use servo_msg::compositor_msg::{Blank, Epoch, FixedPosition, FinishedLoading, IdleRenderState}; use servo_msg::compositor_msg::{LayerId, ReadyState, RenderState}; use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, LoadUrlMsg, NavigateMsg}; use servo_msg::constellation_msg::{PipelineId, ResizedWindowMsg, WindowSizeData}; @@ -364,13 +363,19 @@ impl IOCompositor { Some(ref root_pipeline) => root_pipeline.clone(), None => fail!("Compositor: Making new layer without initialized pipeline"), }; - let new_compositor_data = CompositorData::new_root(root_pipeline, - layer_properties.epoch, - self.opts.cpu_painting, - layer_properties.background_color); - let new_root = Rc::new(Layer::new(layer_properties.rect, - self.opts.tile_size, - new_compositor_data)); + + let root_properties = LayerProperties { + pipeline_id: root_pipeline.id, + epoch: layer_properties.epoch, + id: LayerId::null(), + rect: layer_properties.rect, + background_color: layer_properties.background_color, + scroll_policy: FixedPosition, + }; + let new_root = CompositorData::new_layer(root_pipeline, + root_properties, + WantsScrollEvents, + self.opts.tile_size); CompositorData::add_child(new_root.clone(), layer_properties); @@ -763,10 +768,10 @@ impl IOCompositor { // Render the scene. match self.scene.root { Some(ref layer) => { - self.scene.background_color.r = layer.extra_data.borrow().unrendered_color.r; - self.scene.background_color.g = layer.extra_data.borrow().unrendered_color.g; - self.scene.background_color.b = layer.extra_data.borrow().unrendered_color.b; - self.scene.background_color.a = layer.extra_data.borrow().unrendered_color.a; + self.scene.background_color.r = layer.extra_data.borrow().background_color.r; + self.scene.background_color.g = layer.extra_data.borrow().background_color.g; + self.scene.background_color.b = layer.extra_data.borrow().background_color.b; + self.scene.background_color.a = layer.extra_data.borrow().background_color.a; rendergl::render_scene(layer.clone(), self.context, &self.scene); } None => {} diff --git a/servo/src/components/compositing/compositor_data.rs b/servo/src/components/compositing/compositor_data.rs index 5beabeb963d3..0efc35853778 100644 --- a/servo/src/components/compositing/compositor_data.rs +++ b/servo/src/components/compositing/compositor_data.rs @@ -13,7 +13,7 @@ use geom::size::{Size2D, TypedSize2D}; use gfx::render_task::{ReRenderRequest, RenderChan, UnusedBufferMsg}; use layers::layers::{Layer, LayerBufferSet}; use layers::platform::surface::NativeSurfaceMethods; -use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId}; +use servo_msg::compositor_msg::{Epoch, LayerId}; use servo_msg::compositor_msg::ScrollPolicy; use servo_msg::constellation_msg::PipelineId; use servo_util::geometry::PagePx; @@ -37,11 +37,8 @@ pub struct CompositorData { /// Whether an ancestor layer that receives scroll events moves this layer. pub scroll_policy: ScrollPolicy, - /// True if CPU rendering is enabled, false if we're using GPU rendering. - pub cpu_painting: bool, - /// The color to use for the unrendered-content void - pub unrendered_color: Color, + pub background_color: Color, /// A monotonically increasing counter that keeps track of the current epoch. /// add_buffer() calls that don't match the current epoch will be ignored. @@ -55,37 +52,21 @@ pub enum WantsScrollEventsFlag { } impl CompositorData { - pub fn new(pipeline: CompositionPipeline, - layer_id: LayerId, - epoch: Epoch, - cpu_painting: bool, - wants_scroll_events: WantsScrollEventsFlag, - scroll_policy: ScrollPolicy, - unrendered_color: Color) - -> CompositorData { - CompositorData { + pub fn new_layer(pipeline: CompositionPipeline, + layer_properties: LayerProperties, + wants_scroll_events: WantsScrollEventsFlag, + tile_size: uint) + -> Rc> { + let new_compositor_data = CompositorData { pipeline: pipeline, - id: layer_id, + id: layer_properties.id, scroll_offset: TypedPoint2D(0f32, 0f32), wants_scroll_events: wants_scroll_events, - scroll_policy: scroll_policy, - cpu_painting: cpu_painting, - unrendered_color: unrendered_color, - epoch: epoch, - } - } - - pub fn new_root(pipeline: CompositionPipeline, - epoch: Epoch, - cpu_painting: bool, - unrendered_color: Color) -> CompositorData { - CompositorData::new(pipeline, - LayerId::null(), - epoch, - cpu_painting, - WantsScrollEvents, - FixedPosition, - unrendered_color) + scroll_policy: layer_properties.scroll_policy, + background_color: layer_properties.background_color, + epoch: layer_properties.epoch, + }; + Rc::new(Layer::new(layer_properties.rect, tile_size, new_compositor_data)) } /// Adds a child layer to the layer with the given ID and the given pipeline, if it doesn't @@ -93,16 +74,10 @@ impl CompositorData { /// painting status as its parent. pub fn add_child(layer: Rc>, layer_properties: LayerProperties) { - let new_compositor_data = CompositorData::new(layer.extra_data.borrow().pipeline.clone(), - layer_properties.id, - layer_properties.epoch, - layer.extra_data.borrow().cpu_painting, - DoesntWantScrollEvents, - layer_properties.scroll_policy, - layer_properties.background_color); - let new_kid = Rc::new(Layer::new(layer_properties.rect, - layer.tile_size, - new_compositor_data)); + let new_kid = CompositorData::new_layer(layer.extra_data.borrow().pipeline.clone(), + layer_properties, + DoesntWantScrollEvents, + layer.tile_size); layer.add_child(new_kid.clone()); } @@ -193,7 +168,7 @@ impl CompositorData { pub fn update_layer(layer: Rc>, layer_properties: LayerProperties) { layer.extra_data.borrow_mut().epoch = layer_properties.epoch; - layer.extra_data.borrow_mut().unrendered_color = layer_properties.background_color; + layer.extra_data.borrow_mut().background_color = layer_properties.background_color; layer.resize(layer_properties.rect.size); layer.contents_changed(); diff --git a/servo/src/components/compositing/compositor_task.rs b/servo/src/components/compositing/compositor_task.rs index 4f803413e7cc..25116b5692be 100644 --- a/servo/src/components/compositing/compositor_task.rs +++ b/servo/src/components/compositing/compositor_task.rs @@ -80,8 +80,8 @@ impl LayerProperties { metadata.position.origin.y as f32), Size2D(metadata.position.size.width as f32, metadata.position.size.height as f32)), - background_color: metadata.background_color, - scroll_policy: metadata.scroll_policy, + background_color: metadata.background_color, + scroll_policy: metadata.scroll_policy, } } }