Clear tiles before dropping CompositorLayer

This fixes a pixmap leak and task failure (#2069).
This commit is contained in:
Matt Brubeck 2014-04-08 16:13:02 -07:00
parent 6b1799caa3
commit d6dec803fd
2 changed files with 15 additions and 1 deletions

View file

@ -395,6 +395,11 @@ impl IOCompositor {
ContainerLayer::add_child_start(self.root_layer.clone(),
ContainerLayerKind(new_layer.root_layer.clone()));
// Release all tiles from the layer before dropping it.
for layer in self.compositor_layer.mut_iter() {
layer.clear_all_tiles();
}
self.compositor_layer = Some(new_layer);
}

View file

@ -879,7 +879,7 @@ impl CompositorLayer {
}
// Send back all tiles to renderer.
child.get_mut_ref().child.clear();
child.get_mut_ref().child.clear(); // XXX should this be clear_all_tiles?
self.build_layer_tree(graphics_context);
true
@ -951,6 +951,15 @@ impl CompositorLayer {
}
}
/// Destroys tiles for this layer and all descendent layers, sending the buffers back to the
/// renderer to be destroyed or reused.
pub fn clear_all_tiles(&mut self) {
self.clear();
for kid in self.children.mut_iter() {
kid.child.clear_all_tiles();
}
}
/// Destroys all tiles of all layers, including children, *without* sending them back to the
/// renderer. You must call this only when the render task is destined to be going down;
/// otherwise, you will leak tiles.