diff options
author | reed <reed@google.com> | 2014-07-17 07:03:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-17 07:03:09 -0700 |
commit | b959ec7815ae0f65f2aabdeaf280a2a2ee6db955 (patch) | |
tree | 13ce2f5ee8b884e4310fe19c8b2e70badd8a7c5e /include | |
parent | 3eb258d3f67cb78f3b0045857bb10e0774a55b41 (diff) |
factor out flattening/unflattening of common fields from SkImageFilter
This is a precursor to changing SkImageFilters (and all effects) to unflatten via a factory instead of a constructor. In that world, each subclass of ImageFilter will need to control/initiate the unflattening of the common fields, so they can be extract and passed to their Factory.
R=senorblanco@google.com, robertphillips@google.com, mtklein@google.com, senorblanco@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/395273002
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkImageFilter.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index a571184aa2..cd34ba3f91 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -11,6 +11,7 @@ #include "SkFlattenable.h" #include "SkMatrix.h" #include "SkRect.h" +#include "SkTemplates.h" class SkBitmap; class SkColorFilter; @@ -199,6 +200,31 @@ public: SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter) protected: + class Common { + public: + Common() {} + ~Common(); + + bool unflatten(SkReadBuffer&, int expectedInputs = -1); + + CropRect cropRect() const { return fCropRect; } + int inputCount() const { return fInputs.count(); } + SkImageFilter** inputs() const { return fInputs.get(); } + + // If the caller wants a copy of the inputs, call this and it will transfer ownership + // of the unflattened input filters to the caller. This is just a short-cut for copying + // the inputs, calling ref() on each, and then waiting for Common's destructor to call + // unref() on each. + void detachInputs(SkImageFilter** inputs); + + private: + CropRect fCropRect; + // most filters accept at most 2 input-filters + SkAutoSTArray<2, SkImageFilter*> fInputs; + + void allocInputs(int count); + }; + SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect = NULL); virtual ~SkImageFilter(); |