diff options
author | reed <reed@google.com> | 2014-08-21 07:59:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-21 07:59:51 -0700 |
commit | 9fa60daad4d5f54c0dbe3dbcc7608a8f6d721187 (patch) | |
tree | 59cc3af7f1a48aec372c05ca29a2fbef703bceb8 /include/effects/SkMorphologyImageFilter.h | |
parent | 5d74806b478a884bd763aee7e3e33cff1c506e50 (diff) |
Simplify flattening to just write enough to call the factory/public-constructor for the class. We want to *not* rely on private constructors, and not rely on calling through the inheritance hierarchy for either flattening or unflattening(CreateProc).
Refactoring pattern:
1. guard the existing constructor(readbuffer) with the legacy build-flag
2. If you are a instancable subclass, implement CreateProc(readbuffer) to create a new instances from the buffer params (or return NULL).
If you're a shader subclass
1. You must read/write the local matrix if your class accepts that in its factory/constructor, else ignore it.
R=robertphillips@google.com, mtklein@google.com, senorblanco@google.com, senorblanco@chromium.org, sugoi@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/395603002
Diffstat (limited to 'include/effects/SkMorphologyImageFilter.h')
-rw-r--r-- | include/effects/SkMorphologyImageFilter.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h index 75551b6d8a..499d6a8c26 100644 --- a/include/effects/SkMorphologyImageFilter.h +++ b/include/effects/SkMorphologyImageFilter.h @@ -34,7 +34,9 @@ protected: bool filterImageGeneric(Proc procX, Proc procY, Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const; +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING SkMorphologyImageFilter(SkReadBuffer& buffer); +#endif virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; #if SK_SUPPORT_GPU virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } @@ -55,6 +57,9 @@ public: static SkDilateImageFilter* Create(int radiusX, int radiusY, SkImageFilter* input = NULL, const CropRect* cropRect = NULL) { + if (radiusX < 0 || radiusY < 0) { + return NULL; + } return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect)); } @@ -70,7 +75,9 @@ public: protected: SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect) : INHERITED(radiusX, radiusY, input, cropRect) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING explicit SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif private: typedef SkMorphologyImageFilter INHERITED; @@ -81,6 +88,9 @@ public: static SkErodeImageFilter* Create(int radiusX, int radiusY, SkImageFilter* input = NULL, const CropRect* cropRect = NULL) { + if (radiusX < 0 || radiusY < 0) { + return NULL; + } return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect)); } @@ -96,7 +106,9 @@ public: protected: SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect) : INHERITED(radiusX, radiusY, input, cropRect) {} +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING explicit SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} +#endif private: typedef SkMorphologyImageFilter INHERITED; |