Remove saveLayer after clip from dart (#18616)
This is a follow up on https://github.com/flutter/engine/pull/5420 and https://github.com/flutter/flutter/issues/18057 As you can see from the diff, we also mistakenly saveLayer before the clip at some places previously.
This commit is contained in:
@@ -235,8 +235,6 @@ class PaintingContext {
|
||||
_canvas = null;
|
||||
}
|
||||
|
||||
static final Paint _defaultPaint = new Paint();
|
||||
|
||||
/// Hints that the painting in the current layer is complex and would benefit
|
||||
/// from caching.
|
||||
///
|
||||
@@ -351,11 +349,9 @@ class PaintingContext {
|
||||
} else {
|
||||
canvas
|
||||
..save()
|
||||
..clipRRect(offsetClipRRect)
|
||||
..saveLayer(offsetBounds, _defaultPaint);
|
||||
..clipRRect(offsetClipRRect);
|
||||
painter(this, offset);
|
||||
canvas
|
||||
..restore()
|
||||
..restore();
|
||||
}
|
||||
}
|
||||
@@ -380,11 +376,9 @@ class PaintingContext {
|
||||
} else {
|
||||
canvas
|
||||
..save()
|
||||
..clipPath(clipPath.shift(offset))
|
||||
..saveLayer(bounds.shift(offset), _defaultPaint);
|
||||
..clipPath(clipPath.shift(offset));
|
||||
painter(this, offset);
|
||||
canvas
|
||||
..restore()
|
||||
..restore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,13 +355,7 @@ class RenderParagraph extends RenderBox {
|
||||
|
||||
if (_hasVisualOverflow) {
|
||||
final Rect bounds = offset & size;
|
||||
if (_overflowShader != null) {
|
||||
// This layer limits what the shader below blends with to be just the text
|
||||
// (as opposed to the text and its background).
|
||||
canvas.saveLayer(bounds, new Paint());
|
||||
} else {
|
||||
canvas.save();
|
||||
}
|
||||
canvas.clipRect(bounds);
|
||||
}
|
||||
_textPainter.paint(canvas, offset);
|
||||
|
||||
@@ -1487,7 +1487,6 @@ abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> {
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
static final Paint _defaultPaint = new Paint();
|
||||
static final Paint _transparentPaint = new Paint()..color = const Color(0x00000000);
|
||||
|
||||
// On Fuchsia, the system compositor is responsible for drawing shadows
|
||||
@@ -1642,17 +1641,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> {
|
||||
canvas.drawRRect(offsetRRect, new Paint()..color = color);
|
||||
canvas.save();
|
||||
canvas.clipRRect(offsetRRect);
|
||||
// We only use a new layer for non-rectangular clips, on the basis that
|
||||
// rectangular clips won't need antialiasing. This is not really
|
||||
// correct, because if we're e.g. rotated, rectangles will also be
|
||||
// aliased. Unfortunately, it's too much of a performance win to err on
|
||||
// the side of correctness here.
|
||||
// TODO(ianh): Find a better solution.
|
||||
if (!offsetRRect.isRect)
|
||||
canvas.saveLayer(offsetBounds, _RenderPhysicalModelBase._defaultPaint);
|
||||
super.paint(context, offset);
|
||||
if (!offsetRRect.isRect)
|
||||
canvas.restore();
|
||||
canvas.restore();
|
||||
assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false');
|
||||
}
|
||||
@@ -1763,10 +1752,8 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> {
|
||||
);
|
||||
}
|
||||
canvas.drawPath(offsetPath, new Paint()..color = color..style = PaintingStyle.fill);
|
||||
canvas.saveLayer(offsetBounds, _RenderPhysicalModelBase._defaultPaint);
|
||||
canvas.clipPath(offsetPath);
|
||||
super.paint(context, offset);
|
||||
canvas.restore();
|
||||
assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user