未验证 提交 ecbb2b28 编写于 作者: L liyuqian 提交者: GitHub

Call drawPaint instead of drawPath if there's clip (#5937)

If we want to avoid the bleeding edge artifact (flutter/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
上级 597a5084
......@@ -87,10 +87,6 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
SkColorGetA(color_) != 0xff, device_pixel_ratio_);
}
SkPaint paint;
paint.setColor(color_);
context.canvas.drawPath(path_, paint);
int saveCount = context.canvas.save();
switch (clip_behavior_) {
case Clip::hardEdge:
......@@ -107,6 +103,18 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
break;
}
SkPaint paint;
paint.setColor(color_);
if (clip_behavior_ == Clip::none) {
context.canvas.drawPath(path_, paint);
} else {
// If we want to avoid the bleeding edge artifact
// (https://github.com/flutter/flutter/issues/18057#issue-328003931)
// using saveLayer, we have to call drawPaint instead of drawPath as
// anti-aliased drawPath will always have such artifacts.
context.canvas.drawPaint(paint);
}
PaintChildren(context);
context.canvas.restoreToCount(saveCount);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册