Unverified Commit 65069ed4 authored by liyuqian's avatar liyuqian Committed by GitHub

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.
parent d916806a
...@@ -235,8 +235,6 @@ class PaintingContext { ...@@ -235,8 +235,6 @@ class PaintingContext {
_canvas = null; _canvas = null;
} }
static final Paint _defaultPaint = new Paint();
/// Hints that the painting in the current layer is complex and would benefit /// Hints that the painting in the current layer is complex and would benefit
/// from caching. /// from caching.
/// ///
...@@ -351,11 +349,9 @@ class PaintingContext { ...@@ -351,11 +349,9 @@ class PaintingContext {
} else { } else {
canvas canvas
..save() ..save()
..clipRRect(offsetClipRRect) ..clipRRect(offsetClipRRect);
..saveLayer(offsetBounds, _defaultPaint);
painter(this, offset); painter(this, offset);
canvas canvas
..restore()
..restore(); ..restore();
} }
} }
...@@ -380,11 +376,9 @@ class PaintingContext { ...@@ -380,11 +376,9 @@ class PaintingContext {
} else { } else {
canvas canvas
..save() ..save()
..clipPath(clipPath.shift(offset)) ..clipPath(clipPath.shift(offset));
..saveLayer(bounds.shift(offset), _defaultPaint);
painter(this, offset); painter(this, offset);
canvas canvas
..restore()
..restore(); ..restore();
} }
} }
......
...@@ -355,13 +355,7 @@ class RenderParagraph extends RenderBox { ...@@ -355,13 +355,7 @@ class RenderParagraph extends RenderBox {
if (_hasVisualOverflow) { if (_hasVisualOverflow) {
final Rect bounds = offset & size; 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.save();
}
canvas.clipRect(bounds); canvas.clipRect(bounds);
} }
_textPainter.paint(canvas, offset); _textPainter.paint(canvas, offset);
......
...@@ -1487,7 +1487,6 @@ abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> { ...@@ -1487,7 +1487,6 @@ abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> {
markNeedsPaint(); markNeedsPaint();
} }
static final Paint _defaultPaint = new Paint();
static final Paint _transparentPaint = new Paint()..color = const Color(0x00000000); static final Paint _transparentPaint = new Paint()..color = const Color(0x00000000);
// On Fuchsia, the system compositor is responsible for drawing shadows // On Fuchsia, the system compositor is responsible for drawing shadows
...@@ -1642,17 +1641,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> { ...@@ -1642,17 +1641,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> {
canvas.drawRRect(offsetRRect, new Paint()..color = color); canvas.drawRRect(offsetRRect, new Paint()..color = color);
canvas.save(); canvas.save();
canvas.clipRRect(offsetRRect); 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); super.paint(context, offset);
if (!offsetRRect.isRect)
canvas.restore();
canvas.restore(); canvas.restore();
assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false'); assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false');
} }
...@@ -1763,10 +1752,8 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> { ...@@ -1763,10 +1752,8 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> {
); );
} }
canvas.drawPath(offsetPath, new Paint()..color = color..style = PaintingStyle.fill); canvas.drawPath(offsetPath, new Paint()..color = color..style = PaintingStyle.fill);
canvas.saveLayer(offsetBounds, _RenderPhysicalModelBase._defaultPaint);
canvas.clipPath(offsetPath); canvas.clipPath(offsetPath);
super.paint(context, offset); super.paint(context, offset);
canvas.restore();
assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false'); assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false');
} }
} }
......
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