diff options
author | reed <reed@google.com> | 2015-10-06 14:05:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-06 14:05:32 -0700 |
commit | 5ea95df02de9cd774d0b84d1341599bbd9c0d8db (patch) | |
tree | 55b4fcd9836726d1cea4fe8fe034d8486c72f49f | |
parent | 95376a0dde3cdf414eb97a20cef3af19ed7e0151 (diff) |
Revert "Revert of factories should return baseclass, allowing the impl to specialize (patchset #4 id:60001 of https://codereview.chromium.org/1390523005/ )"
This reverts commit 95376a0dde3cdf414eb97a20cef3af19ed7e0151.
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/1389083002
-rw-r--r-- | bench/MorphologyBench.cpp | 2 | ||||
-rw-r--r-- | gm/bigtileimagefilter.cpp | 4 | ||||
-rw-r--r-- | gm/filterfastbounds.cpp | 10 | ||||
-rw-r--r-- | gm/pictureimagefilter.cpp | 10 | ||||
-rw-r--r-- | include/effects/SkBlurImageFilter.h | 26 | ||||
-rw-r--r-- | include/effects/SkDropShadowImageFilter.h | 20 | ||||
-rw-r--r-- | include/effects/SkMergeImageFilter.h | 26 | ||||
-rw-r--r-- | include/effects/SkMorphologyImageFilter.h | 16 | ||||
-rw-r--r-- | include/effects/SkOffsetImageFilter.h | 18 | ||||
-rw-r--r-- | include/effects/SkPictureImageFilter.h | 20 | ||||
-rw-r--r-- | include/effects/SkPixelXorXfermode.h | 7 | ||||
-rw-r--r-- | include/effects/SkRectShaderImageFilter.h | 13 | ||||
-rw-r--r-- | include/effects/SkTableMaskFilter.h | 18 | ||||
-rw-r--r-- | include/effects/SkTestImageFilters.h | 12 | ||||
-rw-r--r-- | include/effects/SkTileImageFilter.h | 13 | ||||
-rw-r--r-- | src/effects/SkRectShaderImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkTileImageFilter.cpp | 4 | ||||
-rw-r--r-- | tests/ImageFilterTest.cpp | 21 |
18 files changed, 119 insertions, 125 deletions
diff --git a/bench/MorphologyBench.cpp b/bench/MorphologyBench.cpp index 51da197e15..fd60ebed46 100644 --- a/bench/MorphologyBench.cpp +++ b/bench/MorphologyBench.cpp @@ -63,7 +63,7 @@ protected: r.offset(fRadius, fRadius); if (fRadius > 0) { - SkMorphologyImageFilter* mf = nullptr; + SkImageFilter* mf = nullptr; switch (fStyle) { case kDilate_MT: mf = SkDilateImageFilter::Create(SkScalarFloorToInt(fRadius), diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp index 20c462b744..f2164e8e2f 100644 --- a/gm/bigtileimagefilter.cpp +++ b/gm/bigtileimagefilter.cpp @@ -56,7 +56,7 @@ protected: SkRect bound = SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)); SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fRedImage)); - SkAutoTUnref<SkTileImageFilter> tif(SkTileImageFilter::Create( + SkAutoTUnref<SkImageFilter> tif(SkTileImageFilter::Create( SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)), SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)), imageSource)); @@ -71,7 +71,7 @@ protected: SkRect bound2 = SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)); - SkAutoTUnref<SkTileImageFilter> tif2(SkTileImageFilter::Create( + SkAutoTUnref<SkImageFilter> tif2(SkTileImageFilter::Create( SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)), SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)), nullptr)); diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp index dcff05bfcc..d484c4211c 100644 --- a/gm/filterfastbounds.cpp +++ b/gm/filterfastbounds.cpp @@ -113,7 +113,7 @@ static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) { static const SkDropShadowImageFilter::ShadowMode kBoth = SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode; - SkAutoTUnref<SkDropShadowImageFilter> dsif( + SkAutoTUnref<SkImageFilter> dsif( SkDropShadowImageFilter::Create(10.0f, 10.0f, 3.0f, 3.0f, SK_ColorRED, kBoth, @@ -123,7 +123,7 @@ static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) { } { - SkAutoTUnref<SkDropShadowImageFilter> dsif( + SkAutoTUnref<SkImageFilter> dsif( SkDropShadowImageFilter::Create(27.0f, 27.0f, 3.0f, 3.0f, SK_ColorRED, @@ -134,13 +134,13 @@ static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) { } { - SkAutoTUnref<SkBlurImageFilter> bif(SkBlurImageFilter::Create(3, 3, source)); + SkAutoTUnref<SkImageFilter> bif(SkBlurImageFilter::Create(3, 3, source)); add_paint(bif, paints); } { - SkAutoTUnref<SkOffsetImageFilter> oif(SkOffsetImageFilter::Create(15, 15, source)); + SkAutoTUnref<SkImageFilter> oif(SkOffsetImageFilter::Create(15, 15, source)); add_paint(oif, paints); } @@ -246,7 +246,7 @@ protected: pic.reset(rec.endRecording()); } - SkAutoTUnref<SkPictureImageFilter> pif(SkPictureImageFilter::Create(pic)); + SkAutoTUnref<SkImageFilter> pif(SkPictureImageFilter::Create(pic)); SkTArray<SkPaint> pifPaints; create_paints(pif, &pifPaints); diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp index 7f6cfbdd9a..ad479171fd 100644 --- a/gm/pictureimagefilter.cpp +++ b/gm/pictureimagefilter.cpp @@ -57,16 +57,16 @@ protected: SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30); SkRect emptyRect = SkRect::MakeXYWH(20, 20, 0, 0); SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100); - SkAutoTUnref<SkPictureImageFilter> pictureSource( + SkAutoTUnref<SkImageFilter> pictureSource( SkPictureImageFilter::Create(fPicture)); - SkAutoTUnref<SkPictureImageFilter> pictureSourceSrcRect( + SkAutoTUnref<SkImageFilter> pictureSourceSrcRect( SkPictureImageFilter::Create(fPicture, srcRect)); - SkAutoTUnref<SkPictureImageFilter> pictureSourceEmptyRect( + SkAutoTUnref<SkImageFilter> pictureSourceEmptyRect( SkPictureImageFilter::Create(fPicture, emptyRect)); - SkAutoTUnref<SkPictureImageFilter> pictureSourceResampled( + SkAutoTUnref<SkImageFilter> pictureSourceResampled( SkPictureImageFilter::CreateForLocalSpace(fPicture, fPicture->cullRect(), kLow_SkFilterQuality)); - SkAutoTUnref<SkPictureImageFilter> pictureSourcePixelated( + SkAutoTUnref<SkImageFilter> pictureSourcePixelated( SkPictureImageFilter::CreateForLocalSpace(fPicture, fPicture->cullRect(), kNone_SkFilterQuality)); diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h index b0bd30988f..c7193a435f 100644 --- a/include/effects/SkBlurImageFilter.h +++ b/include/effects/SkBlurImageFilter.h @@ -13,10 +13,8 @@ class SK_API SkBlurImageFilter : public SkImageFilter { public: - static SkBlurImageFilter* Create(SkScalar sigmaX, - SkScalar sigmaY, - SkImageFilter* input = NULL, - const CropRect* cropRect = NULL) { + static SkImageFilter* Create(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input = NULL, + const CropRect* cropRect = NULL) { return new SkBlurImageFilter(sigmaX, sigmaY, input, cropRect); } @@ -26,22 +24,20 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter) protected: + void flatten(SkWriteBuffer&) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, + SkIPoint* offset) const override; + bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override; + bool canFilterImageGPU() const override { return true; } + bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, SkBitmap* result, + SkIPoint* offset) const override; + +private: SkBlurImageFilter(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input, const CropRect* cropRect); - void flatten(SkWriteBuffer&) const override; - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* offset) const override; - virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, - SkIRect* dst) const override; - - bool canFilterImageGPU() const override { return true; } - virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, - SkBitmap* result, SkIPoint* offset) const override; - -private: SkSize fSigma; typedef SkImageFilter INHERITED; }; diff --git a/include/effects/SkDropShadowImageFilter.h b/include/effects/SkDropShadowImageFilter.h index 964a5763d3..bf4425e925 100644 --- a/include/effects/SkDropShadowImageFilter.h +++ b/include/effects/SkDropShadowImageFilter.h @@ -20,11 +20,9 @@ public: static const int kShadowModeCount = kLast_ShadowMode+1; - static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, - SkScalar sigmaX, SkScalar sigmaY, SkColor color, - ShadowMode shadowMode, - SkImageFilter* input = NULL, - const CropRect* cropRect = NULL) { + static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, + SkColor color, ShadowMode shadowMode, SkImageFilter* input = NULL, + const CropRect* cropRect = NULL) { return new SkDropShadowImageFilter(dx, dy, sigmaX, sigmaY, color, shadowMode, input, cropRect); } @@ -34,16 +32,18 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) protected: - SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor, - ShadowMode shadowMode, SkImageFilter* input, const CropRect* cropRect); void flatten(SkWriteBuffer&) const override; - bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result, SkIPoint* loc) const override; - virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, - SkIRect* dst) const override; + bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result, + SkIPoint* loc) const override; + bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override; private: + SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor, + ShadowMode shadowMode, SkImageFilter* input, const CropRect* cropRect); + SkScalar fDx, fDy, fSigmaX, fSigmaY; SkColor fColor; ShadowMode fShadowMode; + typedef SkImageFilter INHERITED; }; diff --git a/include/effects/SkMergeImageFilter.h b/include/effects/SkMergeImageFilter.h index 714a755021..10c29131ed 100644 --- a/include/effects/SkMergeImageFilter.h +++ b/include/effects/SkMergeImageFilter.h @@ -16,16 +16,17 @@ class SK_API SkMergeImageFilter : public SkImageFilter { public: virtual ~SkMergeImageFilter(); - static SkMergeImageFilter* Create(SkImageFilter* first, SkImageFilter* second, - SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode, - const CropRect* cropRect = NULL) { + static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second, + SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode, + const CropRect* cropRect = NULL) { SkImageFilter* inputs[2] = { first, second }; SkXfermode::Mode modes[2] = { mode, mode }; return new SkMergeImageFilter(inputs, 2, modes, cropRect); } - static SkMergeImageFilter* Create(SkImageFilter* filters[], int count, - const SkXfermode::Mode modes[] = NULL, - const CropRect* cropRect = NULL) { + + static SkImageFilter* Create(SkImageFilter* filters[], int count, + const SkXfermode::Mode modes[] = NULL, + const CropRect* cropRect = NULL) { return new SkMergeImageFilter(filters, count, modes, cropRect); } @@ -33,16 +34,15 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) protected: - SkMergeImageFilter(SkImageFilter* filters[], int count, - const SkXfermode::Mode modes[], - const CropRect* cropRect); void flatten(SkWriteBuffer&) const override; - - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* loc) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, + SkIPoint* loc) const override; private: - uint8_t* fModes; // SkXfermode::Mode + SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mode modes[], + const CropRect* cropRect); + + uint8_t* fModes; // SkXfermode::Mode // private storage, to avoid dynamically allocating storage for our copy // of the modes (unless the count is so large we can't fit). diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h index 8d17609e5f..29728fd9f7 100644 --- a/include/effects/SkMorphologyImageFilter.h +++ b/include/effects/SkMorphologyImageFilter.h @@ -51,9 +51,8 @@ private: class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { public: - static SkDilateImageFilter* Create(int radiusX, int radiusY, - SkImageFilter* input = NULL, - const CropRect* cropRect = NULL) { + static SkImageFilter* Create(int radiusX, int radiusY, SkImageFilter* input = NULL, + const CropRect* cropRect = NULL) { if (radiusX < 0 || radiusY < 0) { return NULL; } @@ -62,6 +61,7 @@ public: bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const override; + #if SK_SUPPORT_GPU bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const override; @@ -70,16 +70,16 @@ public: SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) -protected: +private: SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect) : INHERITED(radiusX, radiusY, input, cropRect) {} -private: + typedef SkMorphologyImageFilter INHERITED; }; class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { public: - static SkErodeImageFilter* Create(int radiusX, int radiusY, + static SkImageFilter* Create(int radiusX, int radiusY, SkImageFilter* input = NULL, const CropRect* cropRect = NULL) { if (radiusX < 0 || radiusY < 0) { @@ -90,6 +90,7 @@ public: bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const override; + #if SK_SUPPORT_GPU bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const override; @@ -98,11 +99,10 @@ public: SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) -protected: +private: SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect) : INHERITED(radiusX, radiusY, input, cropRect) {} -private: typedef SkMorphologyImageFilter INHERITED; }; diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h index 30e380d89b..40f2ce3374 100644 --- a/include/effects/SkOffsetImageFilter.h +++ b/include/effects/SkOffsetImageFilter.h @@ -12,30 +12,32 @@ #include "SkPoint.h" class SK_API SkOffsetImageFilter : public SkImageFilter { - typedef SkImageFilter INHERITED; - public: - static SkOffsetImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL, - const CropRect* cropRect = NULL) { + static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL, + const CropRect* cropRect = NULL) { if (!SkScalarIsFinite(dx) || !SkScalarIsFinite(dy)) { return NULL; } return new SkOffsetImageFilter(dx, dy, input, cropRect); } + void computeFastBounds(const SkRect& src, SkRect* dst) const override; + SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter) protected: - SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect* cropRect); void flatten(SkWriteBuffer&) const override; - - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* loc) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, + SkIPoint* loc) const override; bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override; private: + SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect*); + SkVector fOffset; + + typedef SkImageFilter INHERITED; }; #endif diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h index 231a492900..934d1324c0 100644 --- a/include/effects/SkPictureImageFilter.h +++ b/include/effects/SkPictureImageFilter.h @@ -16,7 +16,7 @@ public: /** * Refs the passed-in picture. */ - static SkPictureImageFilter* Create(const SkPicture* picture) { + static SkImageFilter* Create(const SkPicture* picture) { return new SkPictureImageFilter(picture); } @@ -24,7 +24,7 @@ public: * Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.) */ - static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) { + static SkImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) { return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureResolution, kLow_SkFilterQuality); } @@ -36,12 +36,13 @@ public: * expand the destination rect when the picture is drawn. (No scaling is implied by the * dest rect; only the CTM is applied.) */ - static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, + static SkImageFilter* CreateForLocalSpace(const SkPicture* picture, const SkRect& cropRect, SkFilterQuality filterQuality) { return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureResolution, filterQuality); } + SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) @@ -51,10 +52,8 @@ protected: kLocalSpace_PictureResolution }; - explicit SkPictureImageFilter(const SkPicture* picture); - SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, - PictureResolution, SkFilterQuality); virtual ~SkPictureImageFilter(); + /* Constructs an SkPictureImageFilter object from an SkReadBuffer. * Note: If the SkPictureImageFilter object construction requires bitmap * decoding, the decoder must be set on the SkReadBuffer parameter by calling @@ -62,11 +61,13 @@ protected: * @param SkReadBuffer Serialized picture data. */ void flatten(SkWriteBuffer&) const override; - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* offset) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, + SkIPoint* offset) const override; private: - + explicit SkPictureImageFilter(const SkPicture* picture); + SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, + PictureResolution, SkFilterQuality); void drawPictureAtDeviceResolution(SkBaseDevice*, const SkIRect& deviceBounds, const Context&) const; @@ -77,6 +78,7 @@ private: SkRect fCropRect; PictureResolution fPictureResolution; SkFilterQuality fFilterQuality; + typedef SkImageFilter INHERITED; }; diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h index 8b7f3388ff..f2fe47156c 100644 --- a/include/effects/SkPixelXorXfermode.h +++ b/include/effects/SkPixelXorXfermode.h @@ -17,19 +17,18 @@ */ class SK_API SkPixelXorXfermode : public SkXfermode { public: - static SkPixelXorXfermode* Create(SkColor opColor) { return new SkPixelXorXfermode(opColor); } + static SkXfermode* Create(SkColor opColor) { return new SkPixelXorXfermode(opColor); } SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode) protected: - explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {} void flatten(SkWriteBuffer&) const override; - - // override from SkXfermode SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override; private: + explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {} + SkColor fOpColor; typedef SkXfermode INHERITED; diff --git a/include/effects/SkRectShaderImageFilter.h b/include/effects/SkRectShaderImageFilter.h index d78162876f..9798af2d64 100644 --- a/include/effects/SkRectShaderImageFilter.h +++ b/include/effects/SkRectShaderImageFilter.h @@ -26,23 +26,24 @@ public: * primitive's bounds are used instead. */ SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)") - static SkRectShaderImageFilter* Create(SkShader* s, const SkRect& rect); + static SkImageFilter* Create(SkShader* s, const SkRect& rect); + static SkImageFilter* Create(SkShader* s, const CropRect* rect = NULL); - static SkRectShaderImageFilter* Create(SkShader* s, const CropRect* rect = NULL); - virtual ~SkRectShaderImageFilter(); bool affectsTransparentBlack() const override; SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter) protected: - void flatten(SkWriteBuffer&) const override; + virtual ~SkRectShaderImageFilter(); - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* loc) const override; + void flatten(SkWriteBuffer&) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, + SkIPoint* loc) const override; private: SkRectShaderImageFilter(SkShader* s, const CropRect* rect); + SkShader* fShader; typedef SkImageFilter INHERITED; diff --git a/include/effects/SkTableMaskFilter.h b/include/effects/SkTableMaskFilter.h index 1d530877cc..757ddf2084 100644 --- a/include/effects/SkTableMaskFilter.h +++ b/include/effects/SkTableMaskFilter.h @@ -18,8 +18,6 @@ */ class SK_API SkTableMaskFilter : public SkMaskFilter { public: - virtual ~SkTableMaskFilter(); - /** Utility that sets the gamma table */ static void MakeGammaTable(uint8_t table[256], SkScalar gamma); @@ -29,35 +27,37 @@ public: */ static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max); - static SkTableMaskFilter* Create(const uint8_t table[256]) { + static SkMaskFilter* Create(const uint8_t table[256]) { return new SkTableMaskFilter(table); } - static SkTableMaskFilter* CreateGamma(SkScalar gamma) { + static SkMaskFilter* CreateGamma(SkScalar gamma) { uint8_t table[256]; MakeGammaTable(table, gamma); return new SkTableMaskFilter(table); } - static SkTableMaskFilter* CreateClip(uint8_t min, uint8_t max) { + static SkMaskFilter* CreateClip(uint8_t min, uint8_t max) { uint8_t table[256]; MakeClipTable(table, min, max); return new SkTableMaskFilter(table); } SkMask::Format getFormat() const override; - virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&, - SkIPoint*) const override; + bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) const override; SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter) protected: - SkTableMaskFilter(); - explicit SkTableMaskFilter(const uint8_t table[256]); + virtual ~SkTableMaskFilter(); + void flatten(SkWriteBuffer&) const override; private: + SkTableMaskFilter(); + explicit SkTableMaskFilter(const uint8_t table[256]); + uint8_t fTable[256]; typedef SkMaskFilter INHERITED; diff --git a/include/effects/SkTestImageFilters.h b/include/effects/SkTestImageFilters.h index 4fa0c430f3..06a3ff31a1 100644 --- a/include/effects/SkTestImageFilters.h +++ b/include/effects/SkTestImageFilters.h @@ -14,7 +14,7 @@ // Fun mode that scales down (only) and then scales back up to look pixelated class SK_API SkDownSampleImageFilter : public SkImageFilter { public: - static SkDownSampleImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) { + static SkImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) { if (!SkScalarIsFinite(scale)) { return NULL; } @@ -29,14 +29,14 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter) protected: - SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input) - : INHERITED(1, &input), fScale(scale) {} void flatten(SkWriteBuffer&) const override; - - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, - SkBitmap* result, SkIPoint* loc) const override; + bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, + SkIPoint* loc) const override; private: + SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input) + : INHERITED(1, &input), fScale(scale) {} + SkScalar fScale; typedef SkImageFilter INHERITED; diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h index 4dccf852be..a2a1bb0fe1 100644 --- a/include/effects/SkTileImageFilter.h +++ b/include/effects/SkTileImageFilter.h @@ -15,12 +15,11 @@ class SK_API SkTileImageFilter : public SkImageFilter { public: /** Create a tile image filter - @param srcRect Defines the pixels to tile - @param dstRect Defines the pixels where tiles are drawn + @param src Defines the pixels to tile + @param dst Defines the pixels where tiles are drawn @param input Input from which the subregion defined by srcRect will be tiled */ - static SkTileImageFilter* Create(const SkRect& srcRect, const SkRect& dstRect, - SkImageFilter* input); + static SkImageFilter* Create(const SkRect& src, const SkRect& dst, SkImageFilter* input); bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx, SkBitmap* dst, SkIPoint* offset) const override; @@ -32,12 +31,12 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter) protected: - SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input) - : INHERITED(1, &input, NULL), fSrcRect(srcRect), fDstRect(dstRect) {} - void flatten(SkWriteBuffer& buffer) const override; private: + SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input) + : INHERITED(1, &input, NULL), fSrcRect(srcRect), fDstRect(dstRect) {} + SkRect fSrcRect; SkRect fDstRect; }; diff --git a/src/effects/SkRectShaderImageFilter.cpp b/src/effects/SkRectShaderImageFilter.cpp index f9e70705c5..14837d02b1 100644 --- a/src/effects/SkRectShaderImageFilter.cpp +++ b/src/effects/SkRectShaderImageFilter.cpp @@ -13,7 +13,7 @@ #include "SkWriteBuffer.h" #include "SkShader.h" -SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRect& rect) { +SkImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRect& rect) { SkASSERT(s); uint32_t flags = CropRect::kHasAll_CropEdge; if (rect.width() == 0 || rect.height() == 0) { @@ -23,7 +23,7 @@ SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe return s ? new SkRectShaderImageFilter(s, &cropRect) : nullptr; } -SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect) { +SkImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect) { SkASSERT(s); return s ? new SkRectShaderImageFilter(s, cropRect) : nullptr; } diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index 5e633a3556..c3eb2f301a 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -16,8 +16,8 @@ #include "SkShader.h" #include "SkValidationUtils.h" -SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect, - SkImageFilter* input) { +SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect, + SkImageFilter* input) { if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { return nullptr; } diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index b1a017cc52..f83d315c4d 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -354,16 +354,11 @@ static SkBitmap make_gradient_circle(int width, int height) { static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Reporter* reporter) { // Check that SkBlurImageFilter will accept a negative sigma, either in // the given arguments or after CTM application. - int width = 32, height = 32; - SkScalar five = SkIntToScalar(5); + const int width = 32, height = 32; + const SkScalar five = SkIntToScalar(5); - SkAutoTUnref<SkBlurImageFilter> positiveFilter( - SkBlurImageFilter::Create(five, five) - ); - - SkAutoTUnref<SkBlurImageFilter> negativeFilter( - SkBlurImageFilter::Create(-five, five) - ); + SkAutoTUnref<SkImageFilter> positiveFilter(SkBlurImageFilter::Create(five, five)); + SkAutoTUnref<SkImageFilter> negativeFilter(SkBlurImageFilter::Create(-five, five)); SkBitmap gradient = make_gradient_circle(width, height); SkBitmap positiveResult1, negativeResult1; @@ -422,9 +417,9 @@ DEF_TEST(ImageFilterDrawTiled, reporter) { SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), }; - SkISize kernelSize = SkISize::Make(3, 3); - SkScalar gain = SK_Scalar1, bias = 0; - SkScalar five = SkIntToScalar(5); + const SkISize kernelSize = SkISize::Make(3, 3); + const SkScalar gain = SK_Scalar1, bias = 0; + const SkScalar five = SkIntToScalar(5); SkAutoTUnref<SkImage> gradientImage(SkImage::NewFromBitmap(make_gradient_circle(64, 64))); SkAutoTUnref<SkImageFilter> gradientSource(SkImageSource::Create(gradientImage)); @@ -489,7 +484,7 @@ DEF_TEST(ImageFilterDrawTiled, reporter) { }; SkBitmap untiledResult, tiledResult; - int width = 64, height = 64; + const int width = 64, height = 64; untiledResult.allocN32Pixels(width, height); tiledResult.allocN32Pixels(width, height); SkCanvas tiledCanvas(tiledResult); |