Skip to content

Commit ecbb2b2

Browse files
authored
Call drawPaint instead of drawPath if there's clip (flutter#5937)
If we want to avoid the bleeding edge artifact (flutter#18057 (comment)) using saveLayer, we have to call drawPaint instead of drawPath as anti-aliased drawPath will always have such artifacts. This is discovered when I try to add golden tests for such bleeding artifacts using our new Clip enum. Here's the updated golden files: flutter/goldens@cb1fa8a?short_path=57b30ce#diff-57b30cea9b10b7ca689009854e12d70e
1 parent 597a508 commit ecbb2b2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

flow/layers/physical_shape_layer.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
8787
SkColorGetA(color_) != 0xff, device_pixel_ratio_);
8888
}
8989

90-
SkPaint paint;
91-
paint.setColor(color_);
92-
context.canvas.drawPath(path_, paint);
93-
9490
int saveCount = context.canvas.save();
9591
switch (clip_behavior_) {
9692
case Clip::hardEdge:
@@ -107,6 +103,18 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
107103
break;
108104
}
109105

106+
SkPaint paint;
107+
paint.setColor(color_);
108+
if (clip_behavior_ == Clip::none) {
109+
context.canvas.drawPath(path_, paint);
110+
} else {
111+
// If we want to avoid the bleeding edge artifact
112+
// (https://github.com/flutter/flutter/issues/18057#issue-328003931)
113+
// using saveLayer, we have to call drawPaint instead of drawPath as
114+
// anti-aliased drawPath will always have such artifacts.
115+
context.canvas.drawPaint(paint);
116+
}
117+
110118
PaintChildren(context);
111119

112120
context.canvas.restoreToCount(saveCount);

0 commit comments

Comments
 (0)