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 /include | |
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
Diffstat (limited to 'include')
-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 |
11 files changed, 94 insertions, 95 deletions
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; }; |