From 372177ee115d46dfb5bfb881a408e6c37ae83678 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Wed, 30 Mar 2016 07:32:28 -0700 Subject: Switch SkLocalMatrixImageFilter and SkPaintImageFilter over to sk_sp TBR=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842793002 Committed: https://skia.googlesource.com/skia/+/a33cf07a2273315363c0b6fb5d3ce811742f5a85 Review URL: https://codereview.chromium.org/1842793002 --- src/core/SkLocalMatrixImageFilter.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/core/SkLocalMatrixImageFilter.h') diff --git a/src/core/SkLocalMatrixImageFilter.h b/src/core/SkLocalMatrixImageFilter.h index 412b391e18..eb112b0f0d 100644 --- a/src/core/SkLocalMatrixImageFilter.h +++ b/src/core/SkLocalMatrixImageFilter.h @@ -16,11 +16,28 @@ */ class SkLocalMatrixImageFilter : public SkImageFilter { public: - static SkImageFilter* Create(const SkMatrix& localM, SkImageFilter* input); + static sk_sp Make(const SkMatrix& localM, sk_sp input) { + if (!input) { + return nullptr; + } + if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)) { + return nullptr; + } + if (localM.isIdentity()) { + return input; + } + return sk_sp(new SkLocalMatrixImageFilter(localM, input)); + } SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixImageFilter) +#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR + static SkImageFilter* Create(const SkMatrix& localM, SkImageFilter* input) { + return Make(localM, sk_sp(SkSafeRef(input))).release(); + } +#endif + protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -28,7 +45,7 @@ protected: SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override; private: - SkLocalMatrixImageFilter(const SkMatrix& localM, SkImageFilter* input); + SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp input); SkMatrix fLocalM; -- cgit v1.2.3