mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
auto merge of #3964 : mrobinson/servo/code-duplication, r=larsbergstrom
It is possible to share the code which creates root layers.
This commit is contained in:
commit
9da7f10c3c
1 changed files with 34 additions and 47 deletions
|
@ -439,29 +439,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.ready_states.insert(frame_tree.pipeline.id, Blank);
|
self.ready_states.insert(frame_tree.pipeline.id, Blank);
|
||||||
self.render_states.insert(frame_tree.pipeline.id, RenderingRenderState);
|
self.render_states.insert(frame_tree.pipeline.id, RenderingRenderState);
|
||||||
|
|
||||||
let layer_properties = LayerProperties {
|
let root_layer = create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline, frame_rect);
|
||||||
pipeline_id: frame_tree.pipeline.id,
|
|
||||||
epoch: Epoch(0),
|
|
||||||
id: LayerId::null(),
|
|
||||||
rect: Rect::zero(),
|
|
||||||
background_color: azure_hl::Color::new(0., 0., 0., 0.),
|
|
||||||
scroll_policy: Scrollable,
|
|
||||||
};
|
|
||||||
let root_layer = CompositorData::new_layer(frame_tree.pipeline.clone(),
|
|
||||||
layer_properties,
|
|
||||||
WantsScrollEvents,
|
|
||||||
opts::get().tile_size);
|
|
||||||
|
|
||||||
match frame_rect {
|
|
||||||
Some(ref frame_rect) => {
|
|
||||||
*root_layer.masks_to_bounds.borrow_mut() = true;
|
|
||||||
|
|
||||||
let frame_rect = frame_rect.to_untyped();
|
|
||||||
*root_layer.bounds.borrow_mut() = Rect::from_untyped(&frame_rect);
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
for kid in frame_tree.children.iter() {
|
for kid in frame_tree.children.iter() {
|
||||||
root_layer.add_child(self.create_frame_tree_root_layers(&kid.frame_tree, kid.rect));
|
root_layer.add_child(self.create_frame_tree_root_layers(&kid.frame_tree, kid.rect));
|
||||||
}
|
}
|
||||||
|
@ -469,31 +447,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame_tree(&mut self, frame_tree_diff: &FrameTreeDiff) {
|
fn update_frame_tree(&mut self, frame_tree_diff: &FrameTreeDiff) {
|
||||||
let layer_properties = LayerProperties {
|
|
||||||
pipeline_id: frame_tree_diff.pipeline.id,
|
|
||||||
epoch: Epoch(0),
|
|
||||||
id: LayerId::null(),
|
|
||||||
rect: Rect::zero(),
|
|
||||||
background_color: azure_hl::Color::new(0., 0., 0., 0.),
|
|
||||||
scroll_policy: Scrollable,
|
|
||||||
};
|
|
||||||
let root_layer = CompositorData::new_layer(frame_tree_diff.pipeline.clone(),
|
|
||||||
layer_properties,
|
|
||||||
WantsScrollEvents,
|
|
||||||
opts::get().tile_size);
|
|
||||||
|
|
||||||
match frame_tree_diff.rect {
|
|
||||||
Some(ref frame_rect) => {
|
|
||||||
*root_layer.masks_to_bounds.borrow_mut() = true;
|
|
||||||
|
|
||||||
let frame_rect = frame_rect.to_untyped();
|
|
||||||
*root_layer.bounds.borrow_mut() = Rect::from_untyped(&frame_rect);
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let parent_layer = self.find_pipeline_root_layer(frame_tree_diff.parent_pipeline.id);
|
let parent_layer = self.find_pipeline_root_layer(frame_tree_diff.parent_pipeline.id);
|
||||||
parent_layer.add_child(root_layer);
|
parent_layer.add_child(
|
||||||
|
create_root_layer_for_pipeline_and_rect(&frame_tree_diff.pipeline,
|
||||||
|
frame_tree_diff.rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_pipeline_root_layer(&self, pipeline_id: PipelineId) -> Rc<Layer<CompositorData>> {
|
fn find_pipeline_root_layer(&self, pipeline_id: PipelineId) -> Rc<Layer<CompositorData>> {
|
||||||
|
@ -1178,6 +1135,36 @@ fn find_layer_with_pipeline_and_layer_id_for_layer(layer: Rc<Layer<CompositorDat
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_root_layer_for_pipeline_and_rect(pipeline: &CompositionPipeline,
|
||||||
|
frame_rect: Option<TypedRect<PagePx, f32>>)
|
||||||
|
-> Rc<Layer<CompositorData>> {
|
||||||
|
let layer_properties = LayerProperties {
|
||||||
|
pipeline_id: pipeline.id,
|
||||||
|
epoch: Epoch(0),
|
||||||
|
id: LayerId::null(),
|
||||||
|
rect: Rect::zero(),
|
||||||
|
background_color: azure_hl::Color::new(0., 0., 0., 0.),
|
||||||
|
scroll_policy: Scrollable,
|
||||||
|
};
|
||||||
|
|
||||||
|
let root_layer = CompositorData::new_layer(pipeline.clone(),
|
||||||
|
layer_properties,
|
||||||
|
WantsScrollEvents,
|
||||||
|
opts::get().tile_size);
|
||||||
|
|
||||||
|
match frame_rect {
|
||||||
|
Some(ref frame_rect) => {
|
||||||
|
*root_layer.masks_to_bounds.borrow_mut() = true;
|
||||||
|
|
||||||
|
let frame_rect = frame_rect.to_untyped();
|
||||||
|
*root_layer.bounds.borrow_mut() = Rect::from_untyped(&frame_rect);
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return root_layer;
|
||||||
|
}
|
||||||
|
|
||||||
impl<Window> CompositorEventListener for IOCompositor<Window> where Window: WindowMethods {
|
impl<Window> CompositorEventListener for IOCompositor<Window> where Window: WindowMethods {
|
||||||
fn handle_event(&mut self, msg: WindowEvent) -> bool {
|
fn handle_event(&mut self, msg: WindowEvent) -> bool {
|
||||||
// Check for new messages coming from the other tasks in the system.
|
// Check for new messages coming from the other tasks in the system.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue