Commit 602dbbee authored by Adam Barth's avatar Adam Barth

Merge pull request #600 from abarth/requires_compositing

Rename createsNewDisplayList to requiresCompositing
parents 5cf3b58f be845407
...@@ -36,15 +36,10 @@ class PaintingContext { ...@@ -36,15 +36,10 @@ class PaintingContext {
PaintingContext(this.canvas); PaintingContext(this.canvas);
List<RenderObject> _descendentsWithPaintingCanvases = new List<RenderObject>(); // used by RenderObject._updatePaintingCanvas() to find out which RenderObjects to ask to paint
void paintChild(RenderObject child, Point point) { void paintChild(RenderObject child, Point point) {
if (child.createNewDisplayList) { // TODO(abarth): Support compositing.
assert(!_descendentsWithPaintingCanvases.contains(child)); assert(!child.requiresCompositing);
_descendentsWithPaintingCanvases.add(child); child._paintWithContext(this, point.toOffset());
canvas.drawPaintingNode(child._paintingNode, point);
} else {
child._paintWithContext(this, point.toOffset());
}
} }
} }
...@@ -320,11 +315,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -320,11 +315,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
static List<RenderObject> _nodesNeedingPaint = new List<RenderObject>(); static List<RenderObject> _nodesNeedingPaint = new List<RenderObject>();
final sky.PaintingNode _paintingNode = new sky.PaintingNode();
sky.PaintingNode get paintingNode {
assert(createNewDisplayList);
return _paintingNode;
}
bool _needsPaint = true; bool _needsPaint = true;
bool get needsPaint => _needsPaint; bool get needsPaint => _needsPaint;
...@@ -332,7 +322,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -332,7 +322,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
assert(!debugDoingPaint); assert(!debugDoingPaint);
if (!attached) return; // Don't try painting things that aren't in the hierarchy if (!attached) return; // Don't try painting things that aren't in the hierarchy
if (_needsPaint) return; if (_needsPaint) return;
if (createNewDisplayList) { if (requiresCompositing) {
_needsPaint = true; _needsPaint = true;
_nodesNeedingPaint.add(this); _nodesNeedingPaint.add(this);
scheduler.ensureVisualUpdate(); scheduler.ensureVisualUpdate();
...@@ -355,7 +345,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -355,7 +345,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
_nodesNeedingPaint = new List<RenderObject>(); _nodesNeedingPaint = new List<RenderObject>();
for (RenderObject node in dirtyNodes..sort((a, b) => a.depth - b.depth)) { for (RenderObject node in dirtyNodes..sort((a, b) => a.depth - b.depth)) {
if (node._needsPaint && node.attached) if (node._needsPaint && node.attached)
node._updatePaintingCanvas(); node._repaint();
}; };
assert(_nodesNeedingPaint.length == 0); assert(_nodesNeedingPaint.length == 0);
} finally { } finally {
...@@ -364,9 +354,9 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -364,9 +354,9 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
} }
} }
void _updatePaintingCanvas() { void _repaint() {
assert(!_needsLayout); assert(!_needsLayout);
assert(createNewDisplayList); assert(requiresCompositing);
sky.PictureRecorder recorder = new sky.PictureRecorder(); sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds); sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
PaintingContext context = new PaintingContext(canvas); PaintingContext context = new PaintingContext(canvas);
...@@ -374,21 +364,13 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -374,21 +364,13 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
try { try {
_paintWithContext(context, Offset.zero); _paintWithContext(context, Offset.zero);
} catch (e) { } catch (e) {
print('Exception raised during _updatePaintingCanvas:\n${e}\nContext:\n${this}'); print('Exception raised during _repaint:\n${e}\nContext:\n${this}');
if (inDebugBuild) if (inDebugBuild)
rethrow; rethrow;
return; return;
} }
assert(!_needsLayout); // check that the paint() method didn't mark us dirty again assert(!_needsLayout); // check that the paint() method didn't mark us dirty again
assert(!_needsPaint); // check that the paint() method didn't mark us dirty again assert(!_needsPaint); // check that the paint() method didn't mark us dirty again
_paintingNode.setBackingDrawable(recorder.endRecordingAsDrawable());
if (context._descendentsWithPaintingCanvases != null) {
for (RenderObject node in context._descendentsWithPaintingCanvases) {
assert(node.attached == attached);
if (node._needsPaint)
node._updatePaintingCanvas();
};
}
} }
void _paintWithContext(PaintingContext context, Offset offset) { void _paintWithContext(PaintingContext context, Offset offset) {
...@@ -417,7 +399,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -417,7 +399,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
assert(!_needsPaint); assert(!_needsPaint);
} }
bool get createNewDisplayList => false; bool get requiresCompositing => false;
Rect get paintBounds; Rect get paintBounds;
void debugPaint(PaintingContext context, Offset offset) { } void debugPaint(PaintingContext context, Offset offset) { }
void paint(PaintingContext context, Offset offset) { } void paint(PaintingContext context, Offset offset) { }
......
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