mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Eliminate ad-hoc recursion in add_buffers
This commit is contained in:
parent
568d4d568a
commit
4b41b68c15
2 changed files with 22 additions and 36 deletions
|
@ -530,14 +530,24 @@ impl IOCompositor {
|
||||||
new_layer_buffer_set.mark_will_leak();
|
new_layer_buffer_set.mark_will_leak();
|
||||||
|
|
||||||
match self.scene.root {
|
match self.scene.root {
|
||||||
Some(ref layer) => {
|
Some(ref root_layer) => {
|
||||||
assert!(CompositorData::add_buffers(layer.clone(),
|
match CompositorData::find_layer_with_pipeline_and_layer_id(root_layer.clone(),
|
||||||
&self.graphics_context,
|
pipeline_id,
|
||||||
pipeline_id,
|
layer_id) {
|
||||||
layer_id,
|
Some(ref layer) => {
|
||||||
new_layer_buffer_set,
|
assert!(CompositorData::add_buffers(layer.clone(),
|
||||||
epoch).is_none());
|
&self.graphics_context,
|
||||||
self.recomposite = true;
|
new_layer_buffer_set,
|
||||||
|
epoch));
|
||||||
|
self.recomposite = true;
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
// FIXME: This may potentially be triggered by a race condition where a
|
||||||
|
// buffers are being rendered but the layer is removed before rendering
|
||||||
|
// completes.
|
||||||
|
fail!("compositor given paint command for non-existent layer");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
fail!("compositor given paint command with no root layer initialized");
|
fail!("compositor given paint command with no root layer initialized");
|
||||||
|
|
|
@ -675,33 +675,9 @@ impl CompositorData {
|
||||||
// layer buffer set is consumed, and None is returned.
|
// layer buffer set is consumed, and None is returned.
|
||||||
pub fn add_buffers(layer: Rc<Layer<CompositorData>>,
|
pub fn add_buffers(layer: Rc<Layer<CompositorData>>,
|
||||||
graphics_context: &NativeCompositingGraphicsContext,
|
graphics_context: &NativeCompositingGraphicsContext,
|
||||||
pipeline_id: PipelineId,
|
new_buffers: Box<LayerBufferSet>,
|
||||||
layer_id: LayerId,
|
|
||||||
mut new_buffers: Box<LayerBufferSet>,
|
|
||||||
epoch: Epoch)
|
epoch: Epoch)
|
||||||
-> Option<Box<LayerBufferSet>> {
|
-> bool {
|
||||||
debug!("compositor_data: starting add_buffers()");
|
|
||||||
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
|
||||||
layer.extra_data.borrow().id != layer_id {
|
|
||||||
// ID does not match ours, so recurse on descendents (including hidden children).
|
|
||||||
for child_layer in layer.children().iter() {
|
|
||||||
match CompositorData::add_buffers(child_layer.clone(),
|
|
||||||
graphics_context,
|
|
||||||
pipeline_id,
|
|
||||||
layer_id,
|
|
||||||
new_buffers,
|
|
||||||
epoch) {
|
|
||||||
None => return None,
|
|
||||||
Some(buffers) => new_buffers = buffers,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not found. Give the caller the buffers back.
|
|
||||||
return Some(new_buffers)
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("compositor_data: layers found for add_buffers()");
|
|
||||||
|
|
||||||
if layer.extra_data.borrow().epoch != epoch {
|
if layer.extra_data.borrow().epoch != epoch {
|
||||||
debug!("add_buffers: compositor epoch mismatch: {:?} != {:?}, id: {:?}",
|
debug!("add_buffers: compositor epoch mismatch: {:?} != {:?}, id: {:?}",
|
||||||
layer.extra_data.borrow().epoch,
|
layer.extra_data.borrow().epoch,
|
||||||
|
@ -709,7 +685,7 @@ impl CompositorData {
|
||||||
layer.extra_data.borrow().pipeline.id);
|
layer.extra_data.borrow().pipeline.id);
|
||||||
let msg = UnusedBufferMsg(new_buffers.buffers);
|
let msg = UnusedBufferMsg(new_buffers.buffers);
|
||||||
let _ = layer.extra_data.borrow().pipeline.render_chan.send_opt(msg);
|
let _ = layer.extra_data.borrow().pipeline.render_chan.send_opt(msg);
|
||||||
return None
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -724,7 +700,7 @@ impl CompositorData {
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositorData::build_layer_tree(layer.clone(), graphics_context);
|
CompositorData::build_layer_tree(layer.clone(), graphics_context);
|
||||||
None
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively sets occluded portions of quadtrees to Hidden, so that they do not ask for
|
// Recursively sets occluded portions of quadtrees to Hidden, so that they do not ask for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue