Commit 4e329a67 authored by Adam Barth's avatar Adam Barth

Merge pull request #350 from abarth/dispose_host_objects

Explicitly dispose heavy C++ objects
parents b628ff40 679a423b
......@@ -59,6 +59,10 @@ abstract class Layer {
_nextSibling = null;
_previousSibling = null;
_parent = null;
_dispose();
}
void _dispose() {
}
/// Override this function to upload this layer to the engine
......@@ -84,6 +88,11 @@ class PictureLayer extends Layer {
/// The picture's coodinate system matches this layer's coodinate system
ui.Picture picture;
void _dispose() {
super._dispose();
picture.dispose();
}
void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
builder.addPicture(offset + layerOffset, picture, paintBounds);
}
......@@ -181,6 +190,7 @@ class ContainerLayer extends Layer {
child._previousSibling = null;
child._nextSibling = null;
child._parent = null;
child._dispose();
}
/// Removes all of this layer's children from its child list
......@@ -191,12 +201,23 @@ class ContainerLayer extends Layer {
child._previousSibling = null;
child._nextSibling = null;
child._parent = null;
child._dispose();
child = next;
}
_firstChild = null;
_lastChild = null;
}
void _dispose() {
super._dispose();
Layer child = _firstChild;
while (child != null) {
Layer next = child.nextSibling;
child._dispose();
child = next;
}
}
void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
addChildrenToScene(builder, offset + layerOffset);
}
......
......@@ -122,7 +122,9 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
Rect bounds = Point.origin & (size * ui.window.devicePixelRatio);
ui.SceneBuilder builder = new ui.SceneBuilder(bounds);
layer.addToScene(builder, Offset.zero);
ui.window.render(builder.build());
ui.Scene scene = builder.build();
ui.window.render(scene);
scene.dispose();
} finally {
ui.tracing.end('RenderView.compositeFrame');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment