Commit 91551c79 authored by Adam Barth's avatar Adam Barth

Merge pull request #1180 from abarth/always_be_compositing

Rename RenderObject.hasLayer to isRepaintBoundary
parents e20ef502 0b775984
...@@ -256,7 +256,7 @@ class RenderBlockViewport extends RenderBlockBase { ...@@ -256,7 +256,7 @@ class RenderBlockViewport extends RenderBlockBase {
super(children: children, direction: direction, itemExtent: itemExtent, minExtent: minExtent); super(children: children, direction: direction, itemExtent: itemExtent, minExtent: minExtent);
bool _inCallback = false; bool _inCallback = false;
bool get hasLayer => true; bool get isRepaintBoundary => true;
/// Called during [layout] to determine the block's children. /// Called during [layout] to determine the block's children.
/// ///
......
...@@ -67,7 +67,7 @@ class PaintingContext { ...@@ -67,7 +67,7 @@ class PaintingContext {
/// painting. The render object's layer is re-used, along with any layers in /// painting. The render object's layer is re-used, along with any layers in
/// the subtree that don't need to be repainted. /// the subtree that don't need to be repainted.
static void repaintCompositedChild(RenderObject child) { static void repaintCompositedChild(RenderObject child) {
assert(child.hasLayer); assert(child.isRepaintBoundary);
assert(child.needsPaint); assert(child.needsPaint);
child._layer ??= new ContainerLayer(); child._layer ??= new ContainerLayer();
child._layer.removeAllChildren(); child._layer.removeAllChildren();
...@@ -86,7 +86,7 @@ class PaintingContext { ...@@ -86,7 +86,7 @@ class PaintingContext {
/// into the layer subtree associated with this painting context. Otherwise, /// into the layer subtree associated with this painting context. Otherwise,
/// the child will be painted into the current PictureLayer for this context. /// the child will be painted into the current PictureLayer for this context.
void paintChild(RenderObject child, Offset offset) { void paintChild(RenderObject child, Offset offset) {
if (child.hasLayer) { if (child.isRepaintBoundary) {
_stopRecordingIfNeeded(); _stopRecordingIfNeeded();
_compositeChild(child, offset); _compositeChild(child, offset);
} else { } else {
...@@ -96,7 +96,7 @@ class PaintingContext { ...@@ -96,7 +96,7 @@ class PaintingContext {
void _compositeChild(RenderObject child, Offset offset) { void _compositeChild(RenderObject child, Offset offset) {
assert(!_isRecording); assert(!_isRecording);
assert(child.hasLayer); assert(child.isRepaintBoundary);
assert(_canvas == null || _canvas.getSaveCount() == 1); assert(_canvas == null || _canvas.getSaveCount() == 1);
// Create a layer for our child, and paint the child into it. // Create a layer for our child, and paint the child into it.
...@@ -393,7 +393,7 @@ RenderingExceptionHandler debugRenderingExceptionHandler; ...@@ -393,7 +393,7 @@ RenderingExceptionHandler debugRenderingExceptionHandler;
abstract class RenderObject extends AbstractNode implements HitTestTarget { abstract class RenderObject extends AbstractNode implements HitTestTarget {
RenderObject() { RenderObject() {
_needsCompositing = hasLayer; _needsCompositing = isRepaintBoundary || alwaysNeedsCompositing;
} }
// LAYOUT // LAYOUT
...@@ -838,21 +838,31 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -838,21 +838,31 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
static List<RenderObject> _nodesNeedingPaint = <RenderObject>[]; static List<RenderObject> _nodesNeedingPaint = <RenderObject>[];
static List<RenderObject> _nodesNeedingCompositingBitsUpdate = <RenderObject>[]; static List<RenderObject> _nodesNeedingCompositingBitsUpdate = <RenderObject>[];
/// Whether this render object paints using a composited layer. /// Whether this render object repaints separately from its parent.
/// ///
/// Override this in subclasses to indicate that instances of your class need /// Override this in subclasses to indicate that instances of your class ought
/// to have their own compositing layer. For example, videos should return /// to repaint independently. For example, render objects that repaint
/// frequently might want to repaint themselves without requiring their parent
/// to repaint.
///
/// Warning: This getter must not change value over the lifetime of this object.
bool get isRepaintBoundary => false;
/// Whether this render object always needs compositing.
///
/// Override this in subclasses to indicate that your paint function always
/// creates at least one composited layer. For example, videos should return
/// true if they use hardware decoders. /// true if they use hardware decoders.
/// ///
/// Note: This getter must not change value over the lifetime of this object. /// Warning: This getter must not change value over the lifetime of this object.
bool get hasLayer => false; bool get alwaysNeedsCompositing => false;
ContainerLayer _layer; ContainerLayer _layer;
/// The compositing layer that this render object uses to paint. /// The compositing layer that this render object uses to repaint.
/// ///
/// Call only when [hasLayer] is true. /// Call only when [isRepaintBoundary] is true.
ContainerLayer get layer { ContainerLayer get layer {
assert(hasLayer); assert(isRepaintBoundary);
assert(!_needsPaint); assert(!_needsPaint);
return _layer; return _layer;
} }
...@@ -878,7 +888,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -878,7 +888,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
final RenderObject parent = this.parent; final RenderObject parent = this.parent;
if (parent._needsCompositingBitsUpdate) if (parent._needsCompositingBitsUpdate)
return; return;
if (!hasLayer && !parent.hasLayer) { if (!isRepaintBoundary && !parent.isRepaintBoundary) {
parent._markNeedsCompositingBitsUpdate(); parent._markNeedsCompositingBitsUpdate();
return; return;
} }
...@@ -927,7 +937,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -927,7 +937,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
if (child.needsCompositing) if (child.needsCompositing)
_needsCompositing = true; _needsCompositing = true;
}); });
if (hasLayer) if (isRepaintBoundary || alwaysNeedsCompositing)
_needsCompositing = true; _needsCompositing = true;
if (oldNeedsCompositing != _needsCompositing) if (oldNeedsCompositing != _needsCompositing)
markNeedsPaint(); markNeedsPaint();
...@@ -955,7 +965,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -955,7 +965,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
if (_needsPaint) if (_needsPaint)
return; return;
_needsPaint = true; _needsPaint = true;
if (hasLayer) { if (isRepaintBoundary) {
assert(() { assert(() {
if (debugPrintMarkNeedsPaintStacks) if (debugPrintMarkNeedsPaintStacks)
debugPrintStack(); debugPrintStack();
...@@ -1019,7 +1029,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1019,7 +1029,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
assert(attached); assert(attached);
assert(parent is! RenderObject); assert(parent is! RenderObject);
assert(!_debugDoingPaint); assert(!_debugDoingPaint);
assert(hasLayer); assert(isRepaintBoundary);
assert(_layer == null); assert(_layer == null);
_layer = rootLayer; _layer = rootLayer;
assert(_needsPaint); assert(_needsPaint);
...@@ -1034,7 +1044,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1034,7 +1044,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
_debugDoingThisPaint = true; _debugDoingThisPaint = true;
debugLastActivePaint = _debugActivePaint; debugLastActivePaint = _debugActivePaint;
_debugActivePaint = this; _debugActivePaint = this;
assert(!hasLayer || _layer != null); assert(!isRepaintBoundary || _layer != null);
return true; return true;
}); });
_needsPaint = false; _needsPaint = false;
......
...@@ -1287,7 +1287,7 @@ class RenderPointerListener extends RenderProxyBox { ...@@ -1287,7 +1287,7 @@ class RenderPointerListener extends RenderProxyBox {
/// not, we can re-record its display list without re-recording the display list /// not, we can re-record its display list without re-recording the display list
/// for the surround tree. /// for the surround tree.
class RenderRepaintBoundary extends RenderProxyBox { class RenderRepaintBoundary extends RenderProxyBox {
bool get hasLayer => true; bool get isRepaintBoundary => true;
} }
/// Is invisible during hit testing. /// Is invisible during hit testing.
......
...@@ -108,7 +108,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -108,7 +108,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
return true; return true;
} }
bool get hasLayer => true; bool get isRepaintBoundary => true;
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
if (child != null) if (child != null)
......
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