From 0df8b3f48185fb13948968d98739a0d67ef2d0d2 Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Fri, 3 Aug 2018 16:41:34 -0700 Subject: [PATCH] Call drawPaint instead of drawPath if there's clip --- flow/layers/physical_shape_layer.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/flow/layers/physical_shape_layer.cc b/flow/layers/physical_shape_layer.cc index 53a7d29f30df4..ea3e85b36bfeb 100644 --- a/flow/layers/physical_shape_layer.cc +++ b/flow/layers/physical_shape_layer.cc @@ -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);