From 2ba424edb79e221c2cad3041b432bd3d9481b307 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 5 Jan 2017 11:08:59 -0800 Subject: [PATCH] Remove Canvas.setMatrix and MaskFilter flags (flutter/engine#3321) The Skia team says these APIs are outdated and should be removed. They do not appear to have any clients. Fixes https://github.com/flutter/flutter/issues/7202 Fixes https://github.com/flutter/flutter/issues/7204 --- engine/src/flutter/lib/ui/painting.dart | 44 +++---------------- engine/src/flutter/lib/ui/painting/canvas.cc | 7 --- engine/src/flutter/lib/ui/painting/canvas.h | 1 - .../flutter/lib/ui/painting/mask_filter.cc | 8 ++-- .../src/flutter/lib/ui/painting/mask_filter.h | 4 +- 5 files changed, 9 insertions(+), 55 deletions(-) diff --git a/engine/src/flutter/lib/ui/painting.dart b/engine/src/flutter/lib/ui/painting.dart index 79907618db..1ce77c6363 100644 --- a/engine/src/flutter/lib/ui/painting.dart +++ b/engine/src/flutter/lib/ui/painting.dart @@ -844,36 +844,11 @@ class MaskFilter extends NativeFieldWrapperClass2 { /// zero. The sigma corresponds to very roughly half the radius of the effect /// in pixels. /// - /// If the `ignoreTransform` argument is set, then the current transform is - /// ignored when computing the blur. This makes the operation cheaper, but - /// lowers the quality of the effect. In particular, it means that the sigma - /// will be relative to the device pixel coordinate space, rather than the - /// logical pixel coordinate space, which means the blur will look different - /// on different devices. - /// - /// If the `highQuality` argument is set, then the quality of the blur may be - /// slightly improved, at the cost of making the operation even more - /// expensive. - /// - /// Even in the best conditions and with the lowest quality settings, a blur - /// is an expensive operation and blurs should therefore be used sparingly. - MaskFilter.blur(BlurStyle style, double sigma, { - bool ignoreTransform: false, - bool highQuality: false - }) { - _constructor(style.index, sigma, _makeBlurFlags(ignoreTransform, highQuality)); - } - void _constructor(int style, double sigma, int flags) native "MaskFilter_constructor"; - - // Convert constructor parameters to the SkBlurMaskFilter::BlurFlags type. - static int _makeBlurFlags(bool ignoreTransform, bool highQuality) { - int flags = 0; - if (ignoreTransform) - flags |= 0x01; - if (highQuality) - flags |= 0x02; - return flags; + /// A blur is an expensive operation and should therefore be used sparingly. + MaskFilter.blur(BlurStyle style, double sigma) { + _constructor(style.index, sigma); } + void _constructor(int style, double sigma) native "MaskFilter_constructor"; } /// A description of a color filter to apply when drawing a shape or compositing @@ -1116,7 +1091,7 @@ enum PointMode { /// A canvas has a current transformation matrix which is applied to all /// operations. Initially, the transformation matrix is the identity transform. /// It can be modified using the [translate], [scale], [rotate], [skew], -/// [transform], and [setMatrix] methods. +/// and [transform] methods. /// /// A canvas also has a current clip region which is applied to all operations. /// Initially, the clip region is infinite. It can be modified using the @@ -1231,15 +1206,6 @@ class Canvas extends NativeFieldWrapperClass2 { } void _transform(Float64List matrix4) native "Canvas_transform"; - /// Replaces the current transform with the specified 4⨉4 transformation - /// matrix specified as a list of values in column-major order. - void setMatrix(Float64List matrix4) { - if (matrix4.length != 16) - throw new ArgumentError("[matrix4] must have 16 entries."); - _setMatrix(matrix4); - } - void _setMatrix(Float64List matrix4) native "Canvas_setMatrix"; - /// Reduces the clip region to the intersection of the current clip and the /// given rectangle. void clipRect(Rect rect) { diff --git a/engine/src/flutter/lib/ui/painting/canvas.cc b/engine/src/flutter/lib/ui/painting/canvas.cc index 40ddcc0273..f6f03dbae8 100644 --- a/engine/src/flutter/lib/ui/painting/canvas.cc +++ b/engine/src/flutter/lib/ui/painting/canvas.cc @@ -34,7 +34,6 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Canvas); V(Canvas, rotate) \ V(Canvas, skew) \ V(Canvas, transform) \ - V(Canvas, setMatrix) \ V(Canvas, clipRect) \ V(Canvas, clipRRect) \ V(Canvas, clipPath) \ @@ -147,12 +146,6 @@ void Canvas::transform(const tonic::Float64List& matrix4) { canvas_->concat(ToSkMatrix(matrix4)); } -void Canvas::setMatrix(const tonic::Float64List& matrix4) { - if (!canvas_) - return; - canvas_->setMatrix(ToSkMatrix(matrix4)); -} - void Canvas::clipRect(double left, double top, double right, double bottom) { if (!canvas_) return; diff --git a/engine/src/flutter/lib/ui/painting/canvas.h b/engine/src/flutter/lib/ui/painting/canvas.h index d5cbc50804..591c018269 100644 --- a/engine/src/flutter/lib/ui/painting/canvas.h +++ b/engine/src/flutter/lib/ui/painting/canvas.h @@ -53,7 +53,6 @@ class Canvas : public ftl::RefCountedThreadSafe, void rotate(double radians); void skew(double sx, double sy); void transform(const tonic::Float64List& matrix4); - void setMatrix(const tonic::Float64List& matrix4); void clipRect(double left, double top, double right, double bottom); void clipRRect(const RRect& rrect); diff --git a/engine/src/flutter/lib/ui/painting/mask_filter.cc b/engine/src/flutter/lib/ui/painting/mask_filter.cc index bcfa0b5d8f..0e6866ae44 100644 --- a/engine/src/flutter/lib/ui/painting/mask_filter.cc +++ b/engine/src/flutter/lib/ui/painting/mask_filter.cc @@ -22,15 +22,13 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, MaskFilter); void MaskFilter::RegisterNatives(tonic::DartLibraryNatives* natives) { natives->Register({ - {"MaskFilter_constructor", MaskFilter_constructor, 4, true}, + {"MaskFilter_constructor", MaskFilter_constructor, 3, true}, }); } -ftl::RefPtr MaskFilter::Create(unsigned style, - double sigma, - unsigned flags) { +ftl::RefPtr MaskFilter::Create(unsigned style, double sigma) { return ftl::MakeRefCounted( - SkBlurMaskFilter::Make(static_cast(style), sigma, flags)); + SkBlurMaskFilter::Make(static_cast(style), sigma)); } MaskFilter::MaskFilter(sk_sp filter) diff --git a/engine/src/flutter/lib/ui/painting/mask_filter.h b/engine/src/flutter/lib/ui/painting/mask_filter.h index 47846b27d2..902be41c83 100644 --- a/engine/src/flutter/lib/ui/painting/mask_filter.h +++ b/engine/src/flutter/lib/ui/painting/mask_filter.h @@ -23,9 +23,7 @@ class MaskFilter : public ftl::RefCountedThreadSafe, public: ~MaskFilter() override; - static ftl::RefPtr Create(unsigned style, - double sigma, - unsigned flags); + static ftl::RefPtr Create(unsigned style, double sigma); const sk_sp& filter() { return filter_; }