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