From cef37e67288e14002c3617fb241dd027b52572d9 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 12 Oct 2016 18:28:10 -0700 Subject: [PATCH] Use antialiased clips (flutter/engine#3124) The Skia team tells us that these go faster. --- .../flutter/flow/layers/clip_path_layer.cc | 2 +- .../flutter/flow/layers/clip_rrect_layer.cc | 2 +- engine/src/flutter/lib/ui/painting/canvas.cc | 28 +++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/engine/src/flutter/flow/layers/clip_path_layer.cc b/engine/src/flutter/flow/layers/clip_path_layer.cc index 9faf600002..ae63e38bc1 100644 --- a/engine/src/flutter/flow/layers/clip_path_layer.cc +++ b/engine/src/flutter/flow/layers/clip_path_layer.cc @@ -21,7 +21,7 @@ void ClipPathLayer::Paint(PaintContext& context) { TRACE_EVENT0("flutter", "ClipPathLayer::Paint"); SkAutoCanvasRestore save(&context.canvas, false); context.canvas.saveLayer(&paint_bounds(), nullptr); - context.canvas.clipPath(clip_path_); + context.canvas.clipPath(clip_path_, true); PaintChildren(context); } diff --git a/engine/src/flutter/flow/layers/clip_rrect_layer.cc b/engine/src/flutter/flow/layers/clip_rrect_layer.cc index 393da5c3f9..9f8f567303 100644 --- a/engine/src/flutter/flow/layers/clip_rrect_layer.cc +++ b/engine/src/flutter/flow/layers/clip_rrect_layer.cc @@ -21,7 +21,7 @@ void ClipRRectLayer::Paint(PaintContext& context) { TRACE_EVENT0("flutter", "ClipRRectLayer::Paint"); SkAutoCanvasRestore save(&context.canvas, false); context.canvas.saveLayer(&paint_bounds(), nullptr); - context.canvas.clipRRect(clip_rrect_, kIntersect_SkClipOp, true); + context.canvas.clipRRect(clip_rrect_, true); PaintChildren(context); } diff --git a/engine/src/flutter/lib/ui/painting/canvas.cc b/engine/src/flutter/lib/ui/painting/canvas.cc index 7b9fdff3f9..fbdfc63bca 100644 --- a/engine/src/flutter/lib/ui/painting/canvas.cc +++ b/engine/src/flutter/lib/ui/painting/canvas.cc @@ -8,9 +8,9 @@ #include "flutter/lib/ui/painting/image.h" #include "flutter/lib/ui/painting/matrix.h" +#include "lib/tonic/converter/dart_converter.h" #include "lib/tonic/dart_args.h" #include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/converter/dart_converter.h" #include "lib/tonic/dart_library_natives.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" @@ -162,13 +162,13 @@ void Canvas::clipRect(double left, double top, double right, double bottom) { void Canvas::clipRRect(const RRect& rrect) { if (!canvas_) return; - canvas_->clipRRect(rrect.sk_rrect, SkRegion::kIntersect_Op); + canvas_->clipRRect(rrect.sk_rrect, true); } void Canvas::clipPath(const CanvasPath* path) { if (!canvas_) return; - canvas_->clipPath(path->path(), SkRegion::kIntersect_Op); + canvas_->clipPath(path->path(), true); } void Canvas::drawColor(SkColor color, SkXfermode::Mode transfer_mode) { @@ -244,21 +244,19 @@ void Canvas::drawCircle(double x, } void Canvas::drawArc(double left, - double top, - double right, - double bottom, - double startAngle, - double sweepAngle, - bool useCenter, - const Paint& paint, - const PaintData& paint_data) { + double top, + double right, + double bottom, + double startAngle, + double sweepAngle, + bool useCenter, + const Paint& paint, + const PaintData& paint_data) { if (!canvas_) return; canvas_->drawArc(SkRect::MakeLTRB(left, top, right, bottom), - startAngle * 180.0 / M_PI, - sweepAngle* 180.0 / M_PI, - useCenter, - *paint.paint()); + startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI, + useCenter, *paint.paint()); } void Canvas::drawPath(const CanvasPath* path,