diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp index e0a27fe118..91172e2e79 100644 --- a/gm/imagefiltersbase.cpp +++ b/gm/imagefiltersbase.cpp @@ -10,7 +10,6 @@ #include "SkCanvas.h" #include "SkColorFilter.h" #include "SkColorPriv.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkShader.h" @@ -33,8 +32,6 @@ public: return sk_sp(new FailImageFilter); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) - protected: FailImageFilter() : INHERITED(nullptr, 0, nullptr) {} @@ -47,6 +44,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(FailImageFilter) + typedef SkImageFilter INHERITED; }; @@ -71,7 +70,6 @@ public: return sk_sp(new IdentityImageFilter(std::move(input))); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter) protected: sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -84,6 +82,7 @@ protected: } private: + SK_FLATTENABLE_HOOKS(IdentityImageFilter) IdentityImageFilter(sk_sp input) : INHERITED(&input, 1, nullptr) {} typedef SkImageFilter INHERITED; diff --git a/include/core/SkDrawable.h b/include/core/SkDrawable.h index 34335a72cc..48cca6df18 100644 --- a/include/core/SkDrawable.h +++ b/include/core/SkDrawable.h @@ -123,6 +123,7 @@ public: } Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } protected: SkDrawable(); diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h index eae0a9782d..2714436e8a 100644 --- a/include/core/SkFlattenable.h +++ b/include/core/SkFlattenable.h @@ -52,21 +52,8 @@ public: /** * Returns the name of the object's class. - * - * Subclasses should override this function if they intend to provide - * support for flattening without using the global registry. - * - * If the flattenable is registered, there is no need to override. */ - virtual const char* getTypeName() const { - #ifdef SK_DISABLE_READBUFFER - // Should not be reachable by PathKit WebAssembly Code. - SkASSERT(false); - return nullptr; - #else - return FactoryToName(getFactory()); - #endif - } + virtual const char* getTypeName() const = 0; static Factory NameToFactory(const char name[]); static const char* FactoryToName(Factory); @@ -110,4 +97,15 @@ private: typedef SkRefCnt INHERITED; }; +#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(type) \ + SkFlattenable::Register(#type, \ + type::CreateProc, \ + type::GetFlattenableType()); + +#define SK_FLATTENABLE_HOOKS(type) \ + static sk_sp CreateProc(SkReadBuffer&); \ + friend class SkFlattenable::PrivateInitializer; \ + Factory getFactory() const override { return type::CreateProc; } \ + const char* getTypeName() const override { return #type; } + #endif diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h index bfaa896309..b767ae5413 100644 --- a/include/effects/Sk1DPathEffect.h +++ b/include/effects/Sk1DPathEffect.h @@ -58,8 +58,6 @@ public: */ static sk_sp Make(const SkPath& path, SkScalar advance, SkScalar phase, Style); - Factory getFactory() const override { return CreateProc; } - protected: SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style); void flatten(SkWriteBuffer&) const override; @@ -70,8 +68,7 @@ protected: SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkPath1DPathEffect) SkPath fPath; // copied from constructor SkScalar fAdvance; // copied from constructor diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h index e29ce1e653..5d7a208db7 100644 --- a/include/effects/Sk2DPathEffect.h +++ b/include/effects/Sk2DPathEffect.h @@ -60,8 +60,6 @@ public: } - Factory getFactory() const override { return CreateProc; } - protected: SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) : Sk2DPathEffect(matrix), fWidth(width) { @@ -73,8 +71,7 @@ protected: void nextSpan(int u, int v, int ucount, SkPath*) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkLine2DPathEffect) SkScalar fWidth; @@ -91,8 +88,6 @@ public: return sk_sp(new SkPath2DPathEffect(matrix, path)); } - Factory getFactory() const override { return CreateProc; } - protected: SkPath2DPathEffect(const SkMatrix&, const SkPath&); void flatten(SkWriteBuffer&) const override; @@ -100,8 +95,7 @@ protected: void next(const SkPoint&, int u, int v, SkPath*) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkPath2DPathEffect) SkPath fPath; diff --git a/include/effects/SkColorFilterImageFilter.h b/include/effects/SkColorFilterImageFilter.h index 8f83827825..99be9edd9a 100644 --- a/include/effects/SkColorFilterImageFilter.h +++ b/include/effects/SkColorFilterImageFilter.h @@ -17,8 +17,6 @@ public: sk_sp input, const CropRect* cropRect = nullptr); - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -29,11 +27,11 @@ protected: bool affectsTransparentBlack() const override; private: + SK_FLATTENABLE_HOOKS(SkColorFilterImageFilter) + SkColorFilterImageFilter(sk_sp cf, sk_sp input, const CropRect* cropRect); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; sk_sp fColorFilter; diff --git a/include/effects/SkComposeImageFilter.h b/include/effects/SkComposeImageFilter.h index acde1d65aa..ab3ce637d6 100644 --- a/include/effects/SkComposeImageFilter.h +++ b/include/effects/SkComposeImageFilter.h @@ -17,8 +17,6 @@ public: SkRect computeFastBounds(const SkRect& src) const override; - Factory getFactory() const override { return CreateProc; } - protected: explicit SkComposeImageFilter(sk_sp inputs[2]) : INHERITED(inputs, 2, nullptr) { SkASSERT(inputs[0].get()); @@ -32,8 +30,7 @@ protected: bool onCanHandleComplexCTM() const override { return true; } private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkComposeImageFilter) typedef SkImageFilter INHERITED; }; diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h index f35f32e790..b4807f582e 100644 --- a/include/effects/SkCornerPathEffect.h +++ b/include/effects/SkCornerPathEffect.h @@ -25,22 +25,20 @@ public: return radius > 0 ? sk_sp(new SkCornerPathEffect(radius)) : nullptr; } - Factory getFactory() const override { return CreateProc; } - #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK bool exposedInAndroidJavaAPI() const override { return true; } #endif protected: ~SkCornerPathEffect() override; - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; explicit SkCornerPathEffect(SkScalar radius); void flatten(SkWriteBuffer&) const override; bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; private: + SK_FLATTENABLE_HOOKS(SkCornerPathEffect) + SkScalar fRadius; typedef SkPathEffect INHERITED; diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h index 99bfb3a4b6..aa043dbece 100644 --- a/include/effects/SkDiscretePathEffect.h +++ b/include/effects/SkDiscretePathEffect.h @@ -32,8 +32,6 @@ public: */ static sk_sp Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist = 0); - Factory getFactory() const override { return CreateProc; } - #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK bool exposedInAndroidJavaAPI() const override { return true; } #endif @@ -46,8 +44,7 @@ protected: bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkDiscretePathEffect) SkScalar fSegLength, fPerterb; diff --git a/include/effects/SkDisplacementMapEffect.h b/include/effects/SkDisplacementMapEffect.h index 1790e4735d..a5fd1bd3ed 100644 --- a/include/effects/SkDisplacementMapEffect.h +++ b/include/effects/SkDisplacementMapEffect.h @@ -39,8 +39,6 @@ public: SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm, MapDirection, const SkIRect* inputRect) const override; - Factory getFactory() const override { return CreateProc; } - protected: sk_sp onFilterImage(SkSpecialImage* source, const Context&, SkIPoint* offset) const override; @@ -52,8 +50,7 @@ protected: void flatten(SkWriteBuffer&) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkDisplacementMapEffect) ChannelSelectorType fXChannelSelector; ChannelSelectorType fYChannelSelector; diff --git a/include/effects/SkDropShadowImageFilter.h b/include/effects/SkDropShadowImageFilter.h index c86550d178..b28d244453 100644 --- a/include/effects/SkDropShadowImageFilter.h +++ b/include/effects/SkDropShadowImageFilter.h @@ -31,8 +31,6 @@ public: SkRect computeFastBounds(const SkRect&) const override; - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -42,11 +40,11 @@ protected: MapDirection, const SkIRect* inputRect) const override; private: + SK_FLATTENABLE_HOOKS(SkDropShadowImageFilter) + SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor, ShadowMode shadowMode, sk_sp input, const CropRect* cropRect); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; SkScalar fDx, fDy, fSigmaX, fSigmaY; SkColor fColor; diff --git a/include/effects/SkImageSource.h b/include/effects/SkImageSource.h index 11bc7ed690..13aede1b3b 100644 --- a/include/effects/SkImageSource.h +++ b/include/effects/SkImageSource.h @@ -22,8 +22,6 @@ public: SkRect computeFastBounds(const SkRect& src) const override; - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; @@ -35,13 +33,13 @@ protected: MapDirection, const SkIRect* inputRect) const override; private: + SK_FLATTENABLE_HOOKS(SkImageSource) + explicit SkImageSource(sk_sp); SkImageSource(sk_sp, const SkRect& srcRect, const SkRect& dstRect, SkFilterQuality); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; sk_sp fImage; SkRect fSrcRect, fDstRect; diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h index 18a9b93991..b18b32c4fc 100644 --- a/include/effects/SkLayerDrawLooper.h +++ b/include/effects/SkLayerDrawLooper.h @@ -75,9 +75,6 @@ public: bool asABlurShadow(BlurShadowRec* rec) const override; - Factory getFactory() const override { return CreateProc; } - static sk_sp CreateProc(SkReadBuffer& buffer); - protected: sk_sp onMakeColorSpace(SkColorSpaceXformer*) const override; @@ -86,6 +83,8 @@ protected: void flatten(SkWriteBuffer&) const override; private: + SK_FLATTENABLE_HOOKS(SkLayerDrawLooper) + struct Rec { Rec* fNext; SkPaint fPaint; diff --git a/include/effects/SkLumaColorFilter.h b/include/effects/SkLumaColorFilter.h index 38886f80c2..500dae9ece 100644 --- a/include/effects/SkLumaColorFilter.h +++ b/include/effects/SkLumaColorFilter.h @@ -36,17 +36,15 @@ public: GrContext*, const GrColorSpaceInfo&) const override; #endif - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; private: + SK_FLATTENABLE_HOOKS(SkLumaColorFilter) + SkLumaColorFilter(); void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool shaderIsOpaque) const override; - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; typedef SkColorFilter INHERITED; }; diff --git a/include/effects/SkMagnifierImageFilter.h b/include/effects/SkMagnifierImageFilter.h index 5a383dc140..f060b480a3 100644 --- a/include/effects/SkMagnifierImageFilter.h +++ b/include/effects/SkMagnifierImageFilter.h @@ -18,8 +18,6 @@ public: sk_sp input, const CropRect* cropRect = nullptr); - Factory getFactory() const override { return CreateProc; } - protected: SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, @@ -32,8 +30,7 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer*) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkMagnifierImageFilter) SkRect fSrcRect; SkScalar fInset; diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h index ccee2fd2f3..bde0863f86 100644 --- a/include/effects/SkMatrixConvolutionImageFilter.h +++ b/include/effects/SkMatrixConvolutionImageFilter.h @@ -68,8 +68,6 @@ public: sk_sp input, const CropRect* cropRect = nullptr); - Factory getFactory() const override { return CreateProc; } - protected: SkMatrixConvolutionImageFilter(const SkISize& kernelSize, const SkScalar* kernel, @@ -90,8 +88,7 @@ protected: bool affectsTransparentBlack() const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkMatrixConvolutionImageFilter) SkISize fKernelSize; SkScalar* fKernel; diff --git a/include/effects/SkMergeImageFilter.h b/include/effects/SkMergeImageFilter.h index 978c07ecbe..ed665968c2 100644 --- a/include/effects/SkMergeImageFilter.h +++ b/include/effects/SkMergeImageFilter.h @@ -25,8 +25,6 @@ public: return Make(array, 2, cropRect); } - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -35,9 +33,9 @@ protected: bool onCanHandleComplexCTM() const override { return true; } private: + SK_FLATTENABLE_HOOKS(SkMergeImageFilter) + SkMergeImageFilter(sk_sp* const filters, int count, const CropRect* cropRect); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; typedef SkImageFilter INHERITED; }; diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h index aa9edfd155..5ed624fc78 100644 --- a/include/effects/SkMorphologyImageFilter.h +++ b/include/effects/SkMorphologyImageFilter.h @@ -62,18 +62,16 @@ public: sk_sp input, const CropRect* cropRect = nullptr); - Factory getFactory() const override { return CreateProc; } - protected: Op op() const override { return kDilate_Op; } private: + SK_FLATTENABLE_HOOKS(SkDilateImageFilter) + SkDilateImageFilter(int radiusX, int radiusY, sk_sp input, const CropRect* cropRect) : INHERITED(radiusX, radiusY, input, cropRect) {} - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; typedef SkMorphologyImageFilter INHERITED; }; @@ -85,17 +83,15 @@ public: sk_sp input, const CropRect* cropRect = nullptr); - Factory getFactory() const override { return CreateProc; } - protected: Op op() const override { return kErode_Op; } private: + SK_FLATTENABLE_HOOKS(SkErodeImageFilter) + SkErodeImageFilter(int radiusX, int radiusY, sk_sp input, const CropRect* cropRect) : INHERITED(radiusX, radiusY, input, cropRect) {} - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; typedef SkMorphologyImageFilter INHERITED; }; diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h index bbf19a9199..e9a771cd2d 100644 --- a/include/effects/SkOffsetImageFilter.h +++ b/include/effects/SkOffsetImageFilter.h @@ -20,8 +20,6 @@ public: SkRect computeFastBounds(const SkRect& src) const override; - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -31,9 +29,9 @@ protected: MapDirection, const SkIRect* inputRect) const override; private: + SK_FLATTENABLE_HOOKS(SkOffsetImageFilter) + SkOffsetImageFilter(SkScalar dx, SkScalar dy, sk_sp input, const CropRect*); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; SkVector fOffset; diff --git a/include/effects/SkOverdrawColorFilter.h b/include/effects/SkOverdrawColorFilter.h index 37aa81332b..d678f26e61 100644 --- a/include/effects/SkOverdrawColorFilter.h +++ b/include/effects/SkOverdrawColorFilter.h @@ -32,14 +32,14 @@ public: GrContext*, const GrColorSpaceInfo&) const override; #endif - static sk_sp CreateProc(SkReadBuffer& buffer); - Factory getFactory() const override { return CreateProc; } static void InitializeFlattenables(); protected: void flatten(SkWriteBuffer& buffer) const override; private: + SK_FLATTENABLE_HOOKS(SkOverdrawColorFilter) + SkOverdrawColorFilter(const SkPMColor colors[kNumColors]) { memcpy(fColors, colors, kNumColors * sizeof(SkPMColor)); } diff --git a/include/effects/SkPaintImageFilter.h b/include/effects/SkPaintImageFilter.h index 8765665fbf..4b6772ebb2 100644 --- a/include/effects/SkPaintImageFilter.h +++ b/include/effects/SkPaintImageFilter.h @@ -27,8 +27,6 @@ public: bool affectsTransparentBlack() const override; - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -36,9 +34,9 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; private: + SK_FLATTENABLE_HOOKS(SkPaintImageFilter) + SkPaintImageFilter(const SkPaint& paint, const CropRect* rect); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; SkPaint fPaint; diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h index f3011ad274..a1a5b383fd 100644 --- a/include/effects/SkPictureImageFilter.h +++ b/include/effects/SkPictureImageFilter.h @@ -26,8 +26,6 @@ public: static sk_sp Make(sk_sp picture, const SkRect& cropRect); - Factory getFactory() const override { return CreateProc; } - protected: /* Constructs an SkPictureImageFilter object from an SkReadBuffer. * Note: If the SkPictureImageFilter object construction requires bitmap @@ -41,10 +39,10 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer*) const override; private: + SK_FLATTENABLE_HOOKS(SkPictureImageFilter) + explicit SkPictureImageFilter(sk_sp picture); SkPictureImageFilter(sk_sp picture, const SkRect& cropRect, sk_sp); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; sk_sp fPicture; SkRect fCropRect; diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h index 2310da3881..bcd2f5bb35 100644 --- a/include/effects/SkTileImageFilter.h +++ b/include/effects/SkTileImageFilter.h @@ -28,8 +28,6 @@ public: MapDirection, const SkIRect* inputRect) const override; SkRect computeFastBounds(const SkRect& src) const override; - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer& buffer) const override; @@ -38,10 +36,10 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer*) const override; private: + SK_FLATTENABLE_HOOKS(SkTileImageFilter) + SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, sk_sp input) : INHERITED(&input, 1, nullptr), fSrcRect(srcRect), fDstRect(dstRect) {} - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; SkRect fSrcRect; SkRect fDstRect; diff --git a/include/effects/SkToSRGBColorFilter.h b/include/effects/SkToSRGBColorFilter.h index 20264aa3e5..f577fb9519 100644 --- a/include/effects/SkToSRGBColorFilter.h +++ b/include/effects/SkToSRGBColorFilter.h @@ -27,15 +27,13 @@ public: GrContext*, const GrColorSpaceInfo&) const override; #endif - Factory getFactory() const override { return CreateProc; } - private: + SK_FLATTENABLE_HOOKS(SkToSRGBColorFilter) + void flatten(SkWriteBuffer&) const override; SkToSRGBColorFilter(sk_sp); void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool shaderIsOpaque) const override; - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; sk_sp fSrcColorSpace; diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index 2841210326..5eb7ade541 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -40,8 +40,6 @@ public: Dot2DPathEffect(SkScalar radius, const SkMatrix& matrix) : Sk2DPathEffect(matrix), fRadius(radius) {} - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Dot2DPathEffect) - protected: void next(const SkPoint& loc, int u, int v, SkPath* dst) const override { dst->addCircle(loc.fX, loc.fY, fRadius); @@ -53,6 +51,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(Dot2DPathEffect) + SkScalar fRadius; typedef Sk2DPathEffect INHERITED; diff --git a/samplecode/SampleTextEffects.cpp b/samplecode/SampleTextEffects.cpp index 4e580d8be0..c43462ec6c 100644 --- a/samplecode/SampleTextEffects.cpp +++ b/samplecode/SampleTextEffects.cpp @@ -29,7 +29,6 @@ public: SkTDArray* pts) : Sk2DPathEffect(matrix), fRadius(radius), fPts(pts) {} - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Dot2DPathEffect) class Registrar { public: Registrar() { @@ -60,6 +59,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(Dot2DPathEffect) + SkScalar fRadius; SkTDArray* fPts; @@ -84,9 +85,9 @@ public: return true; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) - private: + SK_FLATTENABLE_HOOKS(InverseFillPE) + typedef SkPathEffect INHERITED; }; diff --git a/site/dev/contrib/flatten.md b/site/dev/contrib/flatten.md index 1787931bd7..8ea8eed9a4 100644 --- a/site/dev/contrib/flatten.md +++ b/site/dev/contrib/flatten.md @@ -34,9 +34,9 @@ We have a macro for this: ~~~~ -public: +private: -SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNewClass) +SK_FLATTENABLE_HOOKS(SkNewClass) ~~~~ 4: If your class is declared in a `.cpp` file or in a private header file, create a diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index db4a325532..d3f01779e3 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -859,14 +859,14 @@ public: typedef Context INHERITED; }; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader) - protected: void flatten(SkWriteBuffer& buffer) const override { buffer.writeFlattenable(fProxy.get()); } private: + SK_FLATTENABLE_HOOKS(Sk3DShader) + sk_sp fProxy; typedef SkShaderBase INHERITED; diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp index f4907b99d2..61fe3f5a09 100644 --- a/src/core/SkBlurMF.cpp +++ b/src/core/SkBlurMF.cpp @@ -70,7 +70,6 @@ public: void computeFastBounds(const SkRect&, SkRect*) const override; bool asABlur(BlurRec*) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) protected: FilterReturn filterRectsToNine(const SkRect[], int count, const SkMatrix&, @@ -89,6 +88,7 @@ protected: bool ignoreXform() const { return !fRespectCTM; } private: + SK_FLATTENABLE_HOOKS(SkBlurMaskFilterImpl) // To avoid unseemly allocation requests (esp. for finite platforms like // handset) we limit the radius so something manageable. (as opposed to // a request like 10,000) diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp index 1b0b9c2176..ffa2a00935 100644 --- a/src/core/SkColorFilter.cpp +++ b/src/core/SkColorFilter.cpp @@ -121,8 +121,6 @@ public: } #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeColorFilter) - protected: void flatten(SkWriteBuffer& buffer) const override { buffer.writeFlattenable(fOuter.get()); @@ -130,6 +128,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(SkComposeColorFilter) + SkComposeColorFilter(sk_sp outer, sk_sp inner, int composedFilterCount) : fOuter(std::move(outer)) @@ -216,8 +216,6 @@ public: } #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSRGBGammaColorFilter) - void onAppendStages(SkRasterPipeline* p, SkColorSpace*, SkArenaAlloc* alloc, bool shaderIsOpaque) const override { if (!shaderIsOpaque) { @@ -242,6 +240,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(SkSRGBGammaColorFilter) + const Direction fDir; friend class SkColorFilter; diff --git a/src/core/SkColorMatrixFilterRowMajor255.h b/src/core/SkColorMatrixFilterRowMajor255.h index 968c4c847d..837c6304f8 100644 --- a/src/core/SkColorMatrixFilterRowMajor255.h +++ b/src/core/SkColorMatrixFilterRowMajor255.h @@ -28,16 +28,14 @@ public: GrContext*, const GrColorSpaceInfo&) const override; #endif - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; private: + SK_FLATTENABLE_HOOKS(SkColorMatrixFilterRowMajor255) + void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool shaderIsOpaque) const override; - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; SkScalar fMatrix[20]; float fTranspose[20]; // for Sk4s diff --git a/src/core/SkDraw_vertices.cpp b/src/core/SkDraw_vertices.cpp index 31860d4256..f1f9ad7cd3 100644 --- a/src/core/SkDraw_vertices.cpp +++ b/src/core/SkDraw_vertices.cpp @@ -77,8 +77,6 @@ public: bool isOpaque() const override { return fIsOpaque; } - // For serialization. This will never be called. - Factory getFactory() const override { SK_ABORT("not reached"); return nullptr; } protected: #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT @@ -93,6 +91,10 @@ protected: } private: + // For serialization. This will never be called. + Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } + Matrix43 fM43; const bool fIsOpaque; diff --git a/src/core/SkFlattenablePriv.h b/src/core/SkFlattenablePriv.h deleted file mode 100644 index a5228feac3..0000000000 --- a/src/core/SkFlattenablePriv.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkFlattenablePriv_DEFINED -#define SkFlattenablePriv_DEFINED - -#include "SkFlattenable.h" - -/* - * Flattening is straight-forward: - * 1. call getFactory() so we have a function-ptr to recreate the subclass - * 2. call flatten(buffer) to write out enough data for the factory to read - * - * Unflattening is easy for the caller: new_instance = factory(buffer) - * - * The complexity of supporting this is as follows. - * - * If your subclass wants to control unflattening, use this macro in your declaration: - * SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS - * This will provide a getFactory(), and require that the subclass implements CreateProc. - */ - -#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ - SkFlattenable::Register(#flattenable, \ - flattenable::CreateProc, \ - flattenable::GetFlattenableType()); - -#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ - private: \ - static sk_sp CreateProc(SkReadBuffer&); \ - friend class SkFlattenable::PrivateInitializer; \ - public: \ - Factory getFactory() const override { return flattenable::CreateProc; } - -#endif diff --git a/src/core/SkGlobalInitialization_core.cpp b/src/core/SkGlobalInitialization_core.cpp index 27f801d6c1..ece1009382 100644 --- a/src/core/SkGlobalInitialization_core.cpp +++ b/src/core/SkGlobalInitialization_core.cpp @@ -11,7 +11,6 @@ #include "SkColorShader.h" #include "SkComposeShader.h" #include "SkEmptyShader.h" -#include "SkFlattenablePriv.h" #include "SkImageShader.h" #include "SkLocalMatrixShader.h" #include "SkMatrixImageFilter.h" diff --git a/src/core/SkLocalMatrixImageFilter.h b/src/core/SkLocalMatrixImageFilter.h index 8a3ee2cb03..abdadbfa3d 100644 --- a/src/core/SkLocalMatrixImageFilter.h +++ b/src/core/SkLocalMatrixImageFilter.h @@ -19,8 +19,6 @@ class SkLocalMatrixImageFilter : public SkImageFilter { public: static sk_sp Make(const SkMatrix& localM, sk_sp input); - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -30,9 +28,9 @@ protected: MapDirection, const SkIRect* inputRect) const override; private: + SK_FLATTENABLE_HOOKS(SkLocalMatrixImageFilter) + SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp input); - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; SkMatrix fLocalM; diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp index dfd6a55b5f..3d49dfa283 100644 --- a/src/core/SkMaskFilter.cpp +++ b/src/core/SkMaskFilter.cpp @@ -394,7 +394,6 @@ public: } SkMask::Format getFormat() const override { return SkMask::kA8_Format; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeMF) protected: #if SK_SUPPORT_GPU @@ -415,6 +414,8 @@ protected: #endif private: + SK_FLATTENABLE_HOOKS(SkComposeMF) + sk_sp fOuter; sk_sp fInner; @@ -482,7 +483,7 @@ public: SkMask::Format getFormat() const override { return SkMask::kA8_Format; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCombineMF) + SK_FLATTENABLE_HOOKS(SkCombineMF) protected: #if SK_SUPPORT_GPU @@ -631,7 +632,7 @@ public: SkMask::Format getFormat() const override { return as_MFB(fFilter)->getFormat(); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixMF) + SK_FLATTENABLE_HOOKS(SkMatrixMF) protected: #if SK_SUPPORT_GPU diff --git a/src/core/SkMatrixImageFilter.h b/src/core/SkMatrixImageFilter.h index a100aecddb..6c336c8f9a 100644 --- a/src/core/SkMatrixImageFilter.h +++ b/src/core/SkMatrixImageFilter.h @@ -32,8 +32,6 @@ public: SkRect computeFastBounds(const SkRect&) const override; - Factory getFactory() const override { return CreateProc; } - protected: SkMatrixImageFilter(const SkMatrix& transform, SkFilterQuality, @@ -47,8 +45,7 @@ protected: MapDirection, const SkIRect* inputRect) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkMatrixImageFilter) SkMatrix fTransform; SkFilterQuality fFilterQuality; diff --git a/src/core/SkModeColorFilter.h b/src/core/SkModeColorFilter.h index 138b00e30d..ce0b323a50 100644 --- a/src/core/SkModeColorFilter.h +++ b/src/core/SkModeColorFilter.h @@ -20,8 +20,6 @@ public: bool asColorMode(SkColor*, SkBlendMode*) const override; uint32_t getFlags() const override; - Factory getFactory() const override { return CreateProc; } - #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor( GrContext*, const GrColorSpaceInfo&) const override; @@ -38,8 +36,7 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer*) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkModeColorFilter) SkColor fColor; SkBlendMode fMode; diff --git a/src/core/SkNormalFlatSource.h b/src/core/SkNormalFlatSource.h index 9303ba10af..5751b0f3ab 100644 --- a/src/core/SkNormalFlatSource.h +++ b/src/core/SkNormalFlatSource.h @@ -21,12 +21,12 @@ public: SkNormalSource::Provider* asProvider(const SkShaderBase::ContextRec& rec, SkArenaAlloc* alloc) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalFlatSourceImpl) - protected: void flatten(SkWriteBuffer& buf) const override; private: + SK_FLATTENABLE_HOOKS(SkNormalFlatSourceImpl) + class Provider : public SkNormalSource::Provider { public: Provider(); diff --git a/src/core/SkNormalMapSource.h b/src/core/SkNormalMapSource.h index dfedfd35d5..c17a770e60 100644 --- a/src/core/SkNormalMapSource.h +++ b/src/core/SkNormalMapSource.h @@ -23,8 +23,6 @@ public: SkNormalSource::Provider* asProvider(const SkShaderBase::ContextRec& rec, SkArenaAlloc* alloc) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalMapSourceImpl) - protected: void flatten(SkWriteBuffer& buf) const override; @@ -32,6 +30,8 @@ protected: SkMatrix* normTotalInverse) const; private: + SK_FLATTENABLE_HOOKS(SkNormalMapSourceImpl) + class Provider : public SkNormalSource::Provider { public: Provider(const SkNormalMapSourceImpl& source, SkShaderBase::Context* mapContext); diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index 7d75627968..34ea2473d9 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -94,8 +94,6 @@ public: return sk_sp(new SkComposePathEffect(outer, inner)); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) - #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK bool exposedInAndroidJavaAPI() const override { return true; } #endif @@ -116,6 +114,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(SkComposePathEffect) + // illegal SkComposePathEffect(const SkComposePathEffect&); SkComposePathEffect& operator=(const SkComposePathEffect&); @@ -154,7 +154,7 @@ public: return sk_sp(new SkSumPathEffect(first, second)); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) + SK_FLATTENABLE_HOOKS(SkSumPathEffect) #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK bool exposedInAndroidJavaAPI() const override { return true; } diff --git a/src/core/SkRecordedDrawable.h b/src/core/SkRecordedDrawable.h index c7ba74143e..a3fca56731 100644 --- a/src/core/SkRecordedDrawable.h +++ b/src/core/SkRecordedDrawable.h @@ -24,10 +24,6 @@ public: void flatten(SkWriteBuffer& buffer) const override; - static sk_sp CreateProc(SkReadBuffer& buffer); - - Factory getFactory() const override { return CreateProc; } - protected: SkRect onGetBounds() override { return fBounds; } @@ -36,6 +32,8 @@ protected: SkPicture* onNewPictureSnapshot() override; private: + SK_FLATTENABLE_HOOKS(SkRecordedDrawable) + sk_sp fRecord; sk_sp fBBH; std::unique_ptr fDrawableList; diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index c68c47e884..7e04f761b2 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -63,7 +63,7 @@ public: // TODO: might want to remember we're a lighting color filter through serialization? void flatten(SkWriteBuffer& buf) const override { return fMatrixFilter->flatten(buf); } - Factory getFactory() const override { return fMatrixFilter->getFactory(); } + #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor( @@ -73,6 +73,9 @@ public: #endif private: + Factory getFactory() const override { return fMatrixFilter->getFactory(); } + const char* getTypeName() const override { return fMatrixFilter->getTypeName(); } + SkColor fMul, fAdd; sk_sp fMatrixFilter; diff --git a/src/effects/SkDashImpl.h b/src/effects/SkDashImpl.h index c1bf4621bc..c53928ae22 100644 --- a/src/effects/SkDashImpl.h +++ b/src/effects/SkDashImpl.h @@ -14,8 +14,6 @@ class SkDashImpl : public SkPathEffect { public: SkDashImpl(const SkScalar intervals[], int count, SkScalar phase); - Factory getFactory() const override { return CreateProc; } - #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK bool exposedInAndroidJavaAPI() const override { return true; } #endif @@ -31,8 +29,7 @@ protected: DashType onAsADash(DashInfo* info) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkDashImpl) SkScalar* fIntervals; int32_t fCount; diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp index 7f45037ac5..ebb643a29d 100644 --- a/src/effects/SkDashPathEffect.cpp +++ b/src/effects/SkDashPathEffect.cpp @@ -9,7 +9,6 @@ #include "SkDashImpl.h" #include "SkDashPathPriv.h" -#include "SkFlattenablePriv.h" #include "SkReadBuffer.h" #include "SkStrokeRec.h" #include "SkTo.h" diff --git a/src/effects/SkEmbossMaskFilter.h b/src/effects/SkEmbossMaskFilter.h index 7b5878668a..221b81f28d 100644 --- a/src/effects/SkEmbossMaskFilter.h +++ b/src/effects/SkEmbossMaskFilter.h @@ -8,7 +8,6 @@ #ifndef SkEmbossMaskFilter_DEFINED #define SkEmbossMaskFilter_DEFINED -#include "SkFlattenablePriv.h" #include "SkMaskFilterBase.h" /** \class SkEmbossMaskFilter @@ -33,13 +32,13 @@ public: bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkIPoint* margin) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter) - protected: SkEmbossMaskFilter(SkScalar blurSigma, const Light& light); void flatten(SkWriteBuffer&) const override; private: + SK_FLATTENABLE_HOOKS(SkEmbossMaskFilter) + Light fLight; SkScalar fBlurSigma; diff --git a/src/effects/SkHighContrastFilter.cpp b/src/effects/SkHighContrastFilter.cpp index ef863e965b..9c02429453 100644 --- a/src/effects/SkHighContrastFilter.cpp +++ b/src/effects/SkHighContrastFilter.cpp @@ -45,12 +45,12 @@ public: SkArenaAlloc* scratch, bool shaderIsOpaque) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkHighContrast_Filter) - protected: void flatten(SkWriteBuffer&) const override; private: + SK_FLATTENABLE_HOOKS(SkHighContrast_Filter) + SkHighContrastConfig fConfig; friend class SkHighContrastFilter; diff --git a/src/effects/SkOpPE.h b/src/effects/SkOpPE.h index 6f6e114e0b..ea4f811f14 100644 --- a/src/effects/SkOpPE.h +++ b/src/effects/SkOpPE.h @@ -14,15 +14,13 @@ class SkOpPE : public SkPathEffect { public: SkOpPE(sk_sp one, sk_sp two, SkPathOp op); - Factory getFactory() const override { return CreateProc; } protected: void flatten(SkWriteBuffer&) const override; bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkOpPE) sk_sp fOne; sk_sp fTwo; @@ -35,15 +33,12 @@ class SkMatrixPE : public SkPathEffect { public: SkMatrixPE(const SkMatrix&); - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkMatrixPE) SkMatrix fMatrix; @@ -54,16 +49,13 @@ class SkStrokePE : public SkPathEffect { public: SkStrokePE(SkScalar width, SkPaint::Join, SkPaint::Cap, SkScalar miter); - Factory getFactory() const override { return CreateProc; } - protected: void flatten(SkWriteBuffer&) const override; bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; // TODO: override onComputeFastBounds (I think) private: - static sk_sp CreateProc(SkReadBuffer&); - friend class SkFlattenable::PrivateInitializer; + SK_FLATTENABLE_HOOKS(SkStrokePE) SkScalar fWidth, fMiter; diff --git a/src/effects/SkShaderMaskFilter.cpp b/src/effects/SkShaderMaskFilter.cpp index 05940ecec7..48e9d2ec8d 100644 --- a/src/effects/SkShaderMaskFilter.cpp +++ b/src/effects/SkShaderMaskFilter.cpp @@ -27,8 +27,6 @@ public: bool asABlur(BlurRec*) const override { return false; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkShaderMF) - protected: #if SK_SUPPORT_GPU std::unique_ptr onAsFragmentProcessor(const GrFPArgs&) const override; @@ -36,6 +34,8 @@ protected: #endif private: + SK_FLATTENABLE_HOOKS(SkShaderMF) + sk_sp fShader; SkShaderMF(SkReadBuffer&); diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 7e3ad48bd2..619d738705 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -91,8 +91,6 @@ public: GrContext*, const GrColorSpaceInfo&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter) - enum { kA_Flag = 1 << 0, kR_Flag = 1 << 1, @@ -129,6 +127,8 @@ protected: void flatten(SkWriteBuffer&) const override; private: + SK_FLATTENABLE_HOOKS(SkTable_ColorFilter) + mutable const SkBitmap* fBitmap; // lazily allocated uint8_t fStorage[256 * 4]; diff --git a/src/effects/SkTableMaskFilter.cpp b/src/effects/SkTableMaskFilter.cpp index 8ff58ec89d..f1119f8c7c 100644 --- a/src/effects/SkTableMaskFilter.cpp +++ b/src/effects/SkTableMaskFilter.cpp @@ -18,14 +18,14 @@ public: SkMask::Format getFormat() const override; bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilterImpl) - protected: ~SkTableMaskFilterImpl() override; void flatten(SkWriteBuffer&) const override; private: + SK_FLATTENABLE_HOOKS(SkTableMaskFilterImpl) + SkTableMaskFilterImpl(); uint8_t fTable[256]; diff --git a/src/effects/SkTrimPE.h b/src/effects/SkTrimPE.h index cbaab89e5b..c4fc7e0780 100644 --- a/src/effects/SkTrimPE.h +++ b/src/effects/SkTrimPE.h @@ -8,7 +8,6 @@ #ifndef SkTrimImpl_DEFINED #define SkTrimImpl_DEFINED -#include "SkFlattenablePriv.h" #include "SkPathEffect.h" #include "SkTrimPathEffect.h" @@ -17,13 +16,13 @@ class SkTrimPE : public SkPathEffect { public: SkTrimPE(SkScalar startT, SkScalar stopT, SkTrimPathEffect::Mode); - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTrimPE) - protected: void flatten(SkWriteBuffer&) const override; bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; private: + SK_FLATTENABLE_HOOKS(SkTrimPE) + const SkScalar fStartT, fStopT; const SkTrimPathEffect::Mode fMode; diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp index 9cababcc93..b9bd42aad4 100644 --- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp +++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp @@ -31,7 +31,6 @@ public: SkScalar outerThreshold, sk_sp input, const CropRect* cropRect = nullptr); - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterImpl) friend void SkAlphaThresholdFilter::InitializeFlattenables(); protected: @@ -49,6 +48,8 @@ protected: #endif private: + SK_FLATTENABLE_HOOKS(SkAlphaThresholdFilterImpl) + SkRegion fRegion; SkScalar fInnerThreshold; SkScalar fOuterThreshold; diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp index 29df301cb3..c58ff7712e 100644 --- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp +++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp @@ -51,8 +51,6 @@ public: sk_sp inputs[2], const CropRect* cropRect) : INHERITED(inputs, 2, cropRect), fK{k1, k2, k3, k4}, fEnforcePMColor(enforcePMColor) {} - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ArithmeticImageFilterImpl) - protected: sk_sp onFilterImage(SkSpecialImage* source, const Context&, SkIPoint* offset) const override; @@ -83,6 +81,8 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer*) const override; private: + SK_FLATTENABLE_HOOKS(ArithmeticImageFilterImpl) + bool affectsTransparentBlack() const override { return !SkScalarNearlyZero(fK[3]); } const float fK[4]; diff --git a/src/effects/imagefilters/SkBlurImageFilter.cpp b/src/effects/imagefilters/SkBlurImageFilter.cpp index 053a208947..15c7aa6e7f 100644 --- a/src/effects/imagefilters/SkBlurImageFilter.cpp +++ b/src/effects/imagefilters/SkBlurImageFilter.cpp @@ -41,8 +41,6 @@ public: SkRect computeFastBounds(const SkRect&) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilterImpl) - protected: void flatten(SkWriteBuffer&) const override; sk_sp onFilterImage(SkSpecialImage* source, const Context&, @@ -52,6 +50,8 @@ protected: MapDirection, const SkIRect* inputRect) const override; private: + SK_FLATTENABLE_HOOKS(SkBlurImageFilterImpl) + typedef SkImageFilter INHERITED; friend class SkImageFilter; diff --git a/src/effects/imagefilters/SkColorFilterImageFilter.cpp b/src/effects/imagefilters/SkColorFilterImageFilter.cpp index fcbe2261db..9bea7943e3 100644 --- a/src/effects/imagefilters/SkColorFilterImageFilter.cpp +++ b/src/effects/imagefilters/SkColorFilterImageFilter.cpp @@ -10,7 +10,6 @@ #include "SkCanvas.h" #include "SkColorFilter.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkReadBuffer.h" #include "SkSpecialImage.h" diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp index 9a2d054e6a..3d24efa950 100644 --- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp +++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp @@ -9,7 +9,6 @@ #include "SkBitmap.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkReadBuffer.h" #include "SkSpecialImage.h" diff --git a/src/effects/imagefilters/SkDropShadowImageFilter.cpp b/src/effects/imagefilters/SkDropShadowImageFilter.cpp index 36a9d7110d..d19c05fe5d 100644 --- a/src/effects/imagefilters/SkDropShadowImageFilter.cpp +++ b/src/effects/imagefilters/SkDropShadowImageFilter.cpp @@ -10,7 +10,6 @@ #include "SkBlurImageFilter.h" #include "SkCanvas.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkReadBuffer.h" #include "SkSpecialImage.h" diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp index e57504cd69..e105c58de9 100644 --- a/src/effects/imagefilters/SkLightingImageFilter.cpp +++ b/src/effects/imagefilters/SkLightingImageFilter.cpp @@ -9,7 +9,6 @@ #include "SkBitmap.h" #include "SkColorData.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkPoint3.h" #include "SkReadBuffer.h" @@ -529,7 +528,6 @@ public: sk_sp, const CropRect*); - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter) SkScalar kd() const { return fKD; } protected: @@ -550,6 +548,7 @@ protected: #endif private: + SK_FLATTENABLE_HOOKS(SkDiffuseLightingImageFilter) friend class SkLightingImageFilter; SkScalar fKD; @@ -563,8 +562,6 @@ public: SkScalar ks, SkScalar shininess, sk_sp, const CropRect*); - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter) - SkScalar ks() const { return fKS; } SkScalar shininess() const { return fShininess; } @@ -587,6 +584,8 @@ protected: #endif private: + SK_FLATTENABLE_HOOKS(SkSpecularLightingImageFilter) + SkScalar fKS; SkScalar fShininess; friend class SkLightingImageFilter; diff --git a/src/effects/imagefilters/SkMagnifierImageFilter.cpp b/src/effects/imagefilters/SkMagnifierImageFilter.cpp index c17e8fa40f..6c46c4c434 100644 --- a/src/effects/imagefilters/SkMagnifierImageFilter.cpp +++ b/src/effects/imagefilters/SkMagnifierImageFilter.cpp @@ -10,7 +10,6 @@ #include "SkBitmap.h" #include "SkColorData.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkReadBuffer.h" #include "SkSpecialImage.h" diff --git a/src/effects/imagefilters/SkMatrixConvolutionImageFilter.cpp b/src/effects/imagefilters/SkMatrixConvolutionImageFilter.cpp index 9e71ab629e..7668a02849 100644 --- a/src/effects/imagefilters/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/imagefilters/SkMatrixConvolutionImageFilter.cpp @@ -9,7 +9,6 @@ #include "SkBitmap.h" #include "SkColorData.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkReadBuffer.h" #include "SkSpecialImage.h" diff --git a/src/effects/imagefilters/SkMergeImageFilter.cpp b/src/effects/imagefilters/SkMergeImageFilter.cpp index 3225ba8821..633ddd4ae1 100644 --- a/src/effects/imagefilters/SkMergeImageFilter.cpp +++ b/src/effects/imagefilters/SkMergeImageFilter.cpp @@ -9,7 +9,6 @@ #include "SkCanvas.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkReadBuffer.h" #include "SkSpecialImage.h" #include "SkSpecialSurface.h" diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp index 24686f80e2..5b823f165a 100644 --- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp +++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp @@ -10,7 +10,6 @@ #include "SkBitmap.h" #include "SkColorData.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkOpts.h" #include "SkReadBuffer.h" diff --git a/src/effects/imagefilters/SkOffsetImageFilter.cpp b/src/effects/imagefilters/SkOffsetImageFilter.cpp index 8dacc11120..25b7289974 100644 --- a/src/effects/imagefilters/SkOffsetImageFilter.cpp +++ b/src/effects/imagefilters/SkOffsetImageFilter.cpp @@ -8,7 +8,6 @@ #include "SkOffsetImageFilter.h" #include "SkColorSpaceXformer.h" #include "SkCanvas.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkMatrix.h" #include "SkPaint.h" diff --git a/src/effects/imagefilters/SkPictureImageFilter.cpp b/src/effects/imagefilters/SkPictureImageFilter.cpp index a25dee58e6..898f970cc7 100644 --- a/src/effects/imagefilters/SkPictureImageFilter.cpp +++ b/src/effects/imagefilters/SkPictureImageFilter.cpp @@ -10,7 +10,6 @@ #include "SkCanvas.h" #include "SkColorSpaceXformCanvas.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageSource.h" #include "SkPicturePriv.h" #include "SkReadBuffer.h" diff --git a/src/effects/imagefilters/SkTileImageFilter.cpp b/src/effects/imagefilters/SkTileImageFilter.cpp index 7ced09ec6e..eddad2722f 100644 --- a/src/effects/imagefilters/SkTileImageFilter.cpp +++ b/src/effects/imagefilters/SkTileImageFilter.cpp @@ -8,7 +8,6 @@ #include "SkTileImageFilter.h" #include "SkColorSpaceXformer.h" #include "SkCanvas.h" -#include "SkFlattenablePriv.h" #include "SkImage.h" #include "SkImageFilterPriv.h" #include "SkMatrix.h" diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp index 4246bae435..317b5a21a7 100644 --- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp +++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp @@ -10,7 +10,6 @@ #include "SkCanvas.h" #include "SkColorData.h" #include "SkColorSpaceXformer.h" -#include "SkFlattenablePriv.h" #include "SkImageFilterPriv.h" #include "SkReadBuffer.h" #include "SkSpecialImage.h" @@ -35,8 +34,6 @@ public: SkXfermodeImageFilter_Base(SkBlendMode mode, sk_sp inputs[2], const CropRect* cropRect); - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter_Base) - protected: sk_sp onFilterImage(SkSpecialImage* source, const Context&, SkIPoint* offset) const override; @@ -64,6 +61,8 @@ protected: #endif private: + SK_FLATTENABLE_HOOKS(SkXfermodeImageFilter_Base) + static sk_sp LegacyArithmeticCreateProc(SkReadBuffer& buffer); SkBlendMode fMode; diff --git a/src/gpu/GrTestUtils.h b/src/gpu/GrTestUtils.h index ffc48aa63c..2e8eb06550 100644 --- a/src/gpu/GrTestUtils.h +++ b/src/gpu/GrTestUtils.h @@ -73,6 +73,7 @@ public: } Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } protected: bool onFilterPath(SkPath* dst, const SkPath&, SkStrokeRec* , const SkRect*) const override; diff --git a/src/gpu/text/GrSDFMaskFilter.cpp b/src/gpu/text/GrSDFMaskFilter.cpp index b79c7a7811..78fd99e94a 100644 --- a/src/gpu/text/GrSDFMaskFilter.cpp +++ b/src/gpu/text/GrSDFMaskFilter.cpp @@ -26,11 +26,11 @@ public: void computeFastBounds(const SkRect&, SkRect*) const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(GrSDFMaskFilterImpl) - protected: private: + SK_FLATTENABLE_HOOKS(GrSDFMaskFilterImpl) + typedef SkMaskFilter INHERITED; friend void gr_register_sdf_maskfilter_createproc(); }; diff --git a/src/ports/SkGlobalInitialization_default_imagefilters.cpp b/src/ports/SkGlobalInitialization_default_imagefilters.cpp index 5d731778e3..bea559becf 100644 --- a/src/ports/SkGlobalInitialization_default_imagefilters.cpp +++ b/src/ports/SkGlobalInitialization_default_imagefilters.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ -#include "SkFlattenablePriv.h" #include "SkAlphaThresholdFilter.h" #include "SkBlurImageFilter.h" #include "SkColorFilterImageFilter.h" diff --git a/src/shaders/SkColorFilterShader.h b/src/shaders/SkColorFilterShader.h index d97dd063a5..59c7004c95 100644 --- a/src/shaders/SkColorFilterShader.h +++ b/src/shaders/SkColorFilterShader.h @@ -21,14 +21,14 @@ public: std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterShader) - protected: void flatten(SkWriteBuffer&) const override; sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; bool onAppendStages(const StageRec&) const override; private: + SK_FLATTENABLE_HOOKS(SkColorFilterShader) + sk_sp fShader; sk_sp fFilter; diff --git a/src/shaders/SkColorShader.h b/src/shaders/SkColorShader.h index 1b290445f5..6ec7971247 100644 --- a/src/shaders/SkColorShader.h +++ b/src/shaders/SkColorShader.h @@ -50,8 +50,6 @@ public: std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) - protected: SkColorShader(SkReadBuffer&); void flatten(SkWriteBuffer&) const override; @@ -71,6 +69,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(SkColorShader) + SkColor fColor; typedef SkShaderBase INHERITED; @@ -107,8 +107,6 @@ public: std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColor4Shader) - protected: SkColor4Shader(SkReadBuffer&); void flatten(SkWriteBuffer&) const override; @@ -124,6 +122,8 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; private: + SK_FLATTENABLE_HOOKS(SkColor4Shader) + sk_sp fColorSpace; const SkColor4f fColor4; const SkColor fCachedByteColor; diff --git a/src/shaders/SkComposeShader.h b/src/shaders/SkComposeShader.h index c2dc2c3984..7027d3386a 100644 --- a/src/shaders/SkComposeShader.h +++ b/src/shaders/SkComposeShader.h @@ -35,8 +35,6 @@ public: bool asACompose(ComposeRec* rec) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) - protected: SkComposeShader(SkReadBuffer&); void flatten(SkWriteBuffer&) const override; @@ -44,6 +42,8 @@ protected: bool onAppendStages(const StageRec&) const override; private: + SK_FLATTENABLE_HOOKS(SkComposeShader) + sk_sp fDst; sk_sp fSrc; const float fLerpT; diff --git a/src/shaders/SkEmptyShader.h b/src/shaders/SkEmptyShader.h index 673fc27ea7..b0dae052d6 100644 --- a/src/shaders/SkEmptyShader.h +++ b/src/shaders/SkEmptyShader.h @@ -20,8 +20,6 @@ class SkEmptyShader : public SkShaderBase { public: SkEmptyShader() {} - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) - protected: #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override { @@ -40,6 +38,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(SkEmptyShader) + typedef SkShaderBase INHERITED; }; diff --git a/src/shaders/SkImageShader.h b/src/shaders/SkImageShader.h index c790d6335d..0da27606af 100644 --- a/src/shaders/SkImageShader.h +++ b/src/shaders/SkImageShader.h @@ -23,13 +23,13 @@ public: bool isOpaque() const override; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader) - #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif private: + SK_FLATTENABLE_HOOKS(SkImageShader) + SkImageShader(sk_sp, SkShader::TileMode tx, SkShader::TileMode ty, diff --git a/src/shaders/SkLightingShader.cpp b/src/shaders/SkLightingShader.cpp index 73e40bb381..ee09dc9bca 100644 --- a/src/shaders/SkLightingShader.cpp +++ b/src/shaders/SkLightingShader.cpp @@ -80,8 +80,6 @@ public: typedef Context INHERITED; }; - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingShaderImpl) - protected: void flatten(SkWriteBuffer&) const override; #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT @@ -90,6 +88,8 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; private: + SK_FLATTENABLE_HOOKS(SkLightingShaderImpl) + sk_sp fDiffuseShader; sk_sp fNormalSource; sk_sp fLights; diff --git a/src/shaders/SkLightingShader.h b/src/shaders/SkLightingShader.h index f7e63b21df..3350bc1297 100644 --- a/src/shaders/SkLightingShader.h +++ b/src/shaders/SkLightingShader.h @@ -8,7 +8,6 @@ #ifndef SkLightingShader_DEFINED #define SkLightingShader_DEFINED -#include "SkFlattenablePriv.h" #include "SkLights.h" #include "SkShader.h" diff --git a/src/shaders/SkLocalMatrixShader.h b/src/shaders/SkLocalMatrixShader.h index 30efb27064..810220ec58 100644 --- a/src/shaders/SkLocalMatrixShader.h +++ b/src/shaders/SkLocalMatrixShader.h @@ -38,8 +38,6 @@ public: return fProxyShader; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixShader) - protected: void flatten(SkWriteBuffer&) const override; @@ -57,6 +55,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(SkLocalMatrixShader) + sk_sp fProxyShader; typedef SkShaderBase INHERITED; diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp index 357df0ab30..86879f3d47 100644 --- a/src/shaders/SkPerlinNoiseShader.cpp +++ b/src/shaders/SkPerlinNoiseShader.cpp @@ -365,8 +365,6 @@ public: std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShaderImpl) - protected: void flatten(SkWriteBuffer&) const override; #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT @@ -374,6 +372,8 @@ protected: #endif private: + SK_FLATTENABLE_HOOKS(SkPerlinNoiseShaderImpl) + const SkPerlinNoiseShaderImpl::Type fType; const SkScalar fBaseFrequencyX; const SkScalar fBaseFrequencyY; diff --git a/src/shaders/SkPictureShader.h b/src/shaders/SkPictureShader.h index 514d71f772..2dcf2fdbcd 100644 --- a/src/shaders/SkPictureShader.h +++ b/src/shaders/SkPictureShader.h @@ -28,8 +28,6 @@ public: static sk_sp Make(sk_sp, TileMode, TileMode, const SkMatrix*, const SkRect*); - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) - #if SK_SUPPORT_GPU std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif @@ -44,6 +42,8 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; private: + SK_FLATTENABLE_HOOKS(SkPictureShader) + SkPictureShader(sk_sp, TileMode, TileMode, const SkMatrix*, const SkRect*, sk_sp); diff --git a/src/shaders/SkShaderBase.h b/src/shaders/SkShaderBase.h index b607cc8305..0b9bf588e5 100644 --- a/src/shaders/SkShaderBase.h +++ b/src/shaders/SkShaderBase.h @@ -9,7 +9,6 @@ #define SkShaderBase_DEFINED #include "SkFilterQuality.h" -#include "SkFlattenablePriv.h" #include "SkMask.h" #include "SkMatrix.h" #include "SkNoncopyable.h" diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp index 9d00708568..a549fcd739 100644 --- a/src/shaders/gradients/SkGradientShader.cpp +++ b/src/shaders/gradients/SkGradientShader.cpp @@ -10,7 +10,6 @@ #include "SkColorSpacePriv.h" #include "SkColorSpaceXformer.h" #include "SkConvertPixels.h" -#include "SkFlattenablePriv.h" #include "SkFloatBits.h" #include "SkGradientShaderPriv.h" #include "SkHalf.h" diff --git a/src/shaders/gradients/SkLinearGradient.h b/src/shaders/gradients/SkLinearGradient.h index 73af165baf..9950e6de9a 100644 --- a/src/shaders/gradients/SkLinearGradient.h +++ b/src/shaders/gradients/SkLinearGradient.h @@ -19,8 +19,6 @@ public: std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient) - protected: SkLinearGradient(SkReadBuffer& buffer); void flatten(SkWriteBuffer& buffer) const override; @@ -36,6 +34,8 @@ protected: sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; private: + SK_FLATTENABLE_HOOKS(SkLinearGradient) + class LinearGradient4fContext; friend class SkGradientShader; diff --git a/src/shaders/gradients/SkRadialGradient.h b/src/shaders/gradients/SkRadialGradient.h index d6963f6971..caff786529 100644 --- a/src/shaders/gradients/SkRadialGradient.h +++ b/src/shaders/gradients/SkRadialGradient.h @@ -19,8 +19,6 @@ public: std::unique_ptr asFragmentProcessor(const GrFPArgs&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient) - protected: SkRadialGradient(SkReadBuffer& buffer); void flatten(SkWriteBuffer& buffer) const override; @@ -30,6 +28,8 @@ protected: SkRasterPipeline* postPipeline) const override; private: + SK_FLATTENABLE_HOOKS(SkRadialGradient) + const SkPoint fCenter; const SkScalar fRadius; diff --git a/src/shaders/gradients/SkSweepGradient.h b/src/shaders/gradients/SkSweepGradient.h index 8957b47794..7fea967fc3 100644 --- a/src/shaders/gradients/SkSweepGradient.h +++ b/src/shaders/gradients/SkSweepGradient.h @@ -24,8 +24,6 @@ public: SkScalar getTScale() const { return fTScale; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient) - protected: void flatten(SkWriteBuffer& buffer) const override; sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; @@ -34,6 +32,8 @@ protected: SkRasterPipeline* postPipeline) const override; private: + SK_FLATTENABLE_HOOKS(SkSweepGradient) + const SkPoint fCenter; const SkScalar fTBias, fTScale; diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.h b/src/shaders/gradients/SkTwoPointConicalGradient.h index e126054597..f764c0185e 100644 --- a/src/shaders/gradients/SkTwoPointConicalGradient.h +++ b/src/shaders/gradients/SkTwoPointConicalGradient.h @@ -64,8 +64,6 @@ public: Type getType() const { return fType; } const FocalData& getFocalData() const { return fFocalData; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradient) - protected: void flatten(SkWriteBuffer& buffer) const override; sk_sp onMakeColorSpace(SkColorSpaceXformer* xformer) const override; @@ -74,6 +72,8 @@ protected: SkRasterPipeline* postPipeline) const override; private: + SK_FLATTENABLE_HOOKS(SkTwoPointConicalGradient) + SkTwoPointConicalGradient(const SkPoint& c0, SkScalar r0, const SkPoint& c1, SkScalar r1, const Descriptor&, Type, const SkMatrix&, const FocalData&); diff --git a/src/utils/SkShadowUtils.cpp b/src/utils/SkShadowUtils.cpp index 29ac18857d..a382d536c9 100644 --- a/src/utils/SkShadowUtils.cpp +++ b/src/utils/SkShadowUtils.cpp @@ -12,7 +12,6 @@ #include "SkColorData.h" #include "SkDevice.h" #include "SkDrawShadowInfo.h" -#include "SkFlattenablePriv.h" #include "SkMaskFilter.h" #include "SkPath.h" #include "SkRandom.h" @@ -45,8 +44,6 @@ public: GrContext*, const GrColorSpaceInfo&) const override; #endif - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkGaussianColorFilter) - protected: void flatten(SkWriteBuffer&) const override {} void onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* dstCS, SkArenaAlloc* alloc, @@ -54,6 +51,8 @@ protected: pipeline->append(SkRasterPipeline::gauss_a_to_rgba); } private: + SK_FLATTENABLE_HOOKS(SkGaussianColorFilter) + SkGaussianColorFilter() : INHERITED() {} typedef SkColorFilter INHERITED; diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index 08b6df65c6..bf30dd9c55 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -52,7 +52,6 @@ #include "SkClipOp.h" #include "SkClipOpPriv.h" #include "SkColor.h" -#include "SkFlattenablePriv.h" #include "SkImageFilter.h" #include "SkImageInfo.h" #include "SkMalloc.h" @@ -838,8 +837,6 @@ class ZeroBoundsImageFilter : public SkImageFilter { public: static sk_sp Make() { return sk_sp(new ZeroBoundsImageFilter); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ZeroBoundsImageFilter) - protected: sk_sp onFilterImage(SkSpecialImage*, const Context&, SkIPoint*) const override { return nullptr; @@ -851,6 +848,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(ZeroBoundsImageFilter) + ZeroBoundsImageFilter() : INHERITED(nullptr, 0, nullptr) {} typedef SkImageFilter INHERITED; diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp index f9e265987c..5dcf914da7 100644 --- a/tests/GrShapeTest.cpp +++ b/tests/GrShapeTest.cpp @@ -1154,6 +1154,7 @@ void test_path_effect_makes_rrect(skiatest::Reporter* reporter, const Geo& geo) static sk_sp Make() { return sk_sp(new RRectPathEffect); } Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } protected: bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, @@ -1235,6 +1236,7 @@ void test_unknown_path_effect(skiatest::Reporter* reporter, const Geo& geo) { public: static sk_sp Make() { return sk_sp(new AddLineTosPathEffect); } Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } protected: bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, @@ -1281,6 +1283,7 @@ void test_make_hairline_path_effect(skiatest::Reporter* reporter, const Geo& geo return sk_sp(new MakeHairlinePathEffect); } Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } protected: bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* strokeRec, @@ -1363,6 +1366,7 @@ void test_path_effect_makes_empty_shape(skiatest::Reporter* reporter, const Geo& return sk_sp(new EmptyPathEffect(invert)); } Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } protected: bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR) const override { @@ -1448,6 +1452,7 @@ void test_path_effect_fails(skiatest::Reporter* reporter, const Geo& geo) { public: static sk_sp Make() { return sk_sp(new FailurePathEffect); } Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } protected: bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR) const override { diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 0ae8d579f7..16653e25cc 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -57,8 +57,6 @@ public: return sk_sp(new MatrixTestImageFilter(reporter, expectedMatrix)); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) - protected: sk_sp onFilterImage(SkSpecialImage* source, const Context& ctx, SkIPoint* offset) const override { @@ -75,6 +73,8 @@ protected: } private: + SK_FLATTENABLE_HOOKS(MatrixTestImageFilter) + MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expectedMatrix) : INHERITED(nullptr, 0, nullptr) , fReporter(reporter) @@ -100,7 +100,7 @@ public: return nullptr; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) + SK_FLATTENABLE_HOOKS(FailImageFilter) private: typedef SkImageFilter INHERITED; @@ -289,6 +289,7 @@ public: private: Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } sk_sp onFilterImage(SkSpecialImage* src, const Context&, SkIPoint* offset) const override { @@ -1831,6 +1832,7 @@ DEF_TEST(ImageFilterColorSpaceDAG, reporter) { TestFilter() : INHERITED(nullptr, 0, nullptr) {} Factory getFactory() const override { return nullptr; } + const char* getTypeName() const override { return nullptr; } size_t cloneCount() const { return fCloneCount; } diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp index fec03dcbdd..9b97b03c0c 100644 --- a/tests/PDFPrimitivesTest.cpp +++ b/tests/PDFPrimitivesTest.cpp @@ -359,7 +359,6 @@ public: return sk_sp(new DummyImageFilter(visited)); } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter) bool visited() const { return fVisited; } protected: @@ -374,6 +373,7 @@ protected: } private: + SK_FLATTENABLE_HOOKS(DummyImageFilter) DummyImageFilter(bool visited) : INHERITED(nullptr, 0, nullptr), fVisited(visited) {} mutable bool fVisited; diff --git a/tests/QuickRejectTest.cpp b/tests/QuickRejectTest.cpp index ffa012ba35..4bffe1356b 100644 --- a/tests/QuickRejectTest.cpp +++ b/tests/QuickRejectTest.cpp @@ -10,7 +10,6 @@ #include "SkCanvas.h" #include "SkColorSpaceXformer.h" #include "SkDrawLooper.h" -#include "SkFlattenablePriv.h" #include "SkLightingImageFilter.h" #include "SkPoint3.h" #include "SkTypes.h" @@ -30,9 +29,9 @@ public: return nullptr; } - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestLooper) - private: + SK_FLATTENABLE_HOOKS(TestLooper) + class TestDrawLooperContext : public SkDrawLooper::Context { public: TestDrawLooperContext() : fOnce(true) {}