mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Always create CompositorData with a new layer
Since it makes no sense to create one without the other, the public interface shouldn't let you do anything else.
This commit is contained in:
parent
31049adc1d
commit
2e40baba09
2 changed files with 17 additions and 20 deletions
|
@ -31,7 +31,6 @@ 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, FixedPosition, FinishedLoading, IdleRenderState};
|
||||
|
@ -369,16 +368,14 @@ impl IOCompositor {
|
|||
pipeline_id: root_pipeline.id,
|
||||
epoch: layer_properties.epoch,
|
||||
id: LayerId::null(),
|
||||
rect: Rect::zero(),
|
||||
rect: layer_properties.rect,
|
||||
background_color: layer_properties.background_color,
|
||||
scroll_policy: FixedPosition,
|
||||
};
|
||||
let new_compositor_data = CompositorData::new(root_pipeline,
|
||||
root_properties,
|
||||
WantsScrollEvents);
|
||||
let new_root = Rc::new(Layer::new(layer_properties.rect,
|
||||
self.opts.tile_size,
|
||||
new_compositor_data));
|
||||
let new_root = CompositorData::new_layer(root_pipeline,
|
||||
root_properties,
|
||||
WantsScrollEvents,
|
||||
self.opts.tile_size);
|
||||
|
||||
CompositorData::add_child(new_root.clone(), layer_properties);
|
||||
|
||||
|
|
|
@ -52,11 +52,12 @@ pub enum WantsScrollEventsFlag {
|
|||
}
|
||||
|
||||
impl CompositorData {
|
||||
pub fn new(pipeline: CompositionPipeline,
|
||||
layer_properties: LayerProperties,
|
||||
wants_scroll_events: WantsScrollEventsFlag)
|
||||
-> CompositorData {
|
||||
CompositorData {
|
||||
pub fn new_layer(pipeline: CompositionPipeline,
|
||||
layer_properties: LayerProperties,
|
||||
wants_scroll_events: WantsScrollEventsFlag,
|
||||
tile_size: uint)
|
||||
-> Rc<Layer<CompositorData>> {
|
||||
let new_compositor_data = CompositorData {
|
||||
pipeline: pipeline,
|
||||
id: layer_properties.id,
|
||||
scroll_offset: TypedPoint2D(0f32, 0f32),
|
||||
|
@ -64,7 +65,8 @@ impl CompositorData {
|
|||
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
|
||||
|
@ -72,12 +74,10 @@ impl CompositorData {
|
|||
/// painting status as its parent.
|
||||
pub fn add_child(layer: Rc<Layer<CompositorData>>,
|
||||
layer_properties: LayerProperties) {
|
||||
let new_compositor_data = CompositorData::new(layer.extra_data.borrow().pipeline.clone(),
|
||||
layer_properties,
|
||||
DoesntWantScrollEvents);
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue