override getTypeName() instead of using table
This should let getTypeName() and serialization work even
when deserialization factories haven't been registered.
I've made getTypeName() pure virtual like getFactory(),
and moved all the overrides into SK_FLATTENABLE_HOOKS,
cleaning up all the various ways we've done it before.
All the subclasses override getTypeName() and getFactory()
privately, so there should be no need to document them?
Change-Id: I723cb20099d250c2f2a10be266e3aacc6a061937
Reviewed-on: https://skia-review.googlesource.com/c/163543
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp
index e0a27fe..91172e2 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 @@
return sk_sp<SkImageFilter>(new FailImageFilter);
}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
-
protected:
FailImageFilter() : INHERITED(nullptr, 0, nullptr) {}
@@ -47,6 +44,8 @@
}
private:
+ SK_FLATTENABLE_HOOKS(FailImageFilter)
+
typedef SkImageFilter INHERITED;
};
@@ -71,7 +70,6 @@
return sk_sp<SkImageFilter>(new IdentityImageFilter(std::move(input)));
}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -84,6 +82,7 @@
}
private:
+ SK_FLATTENABLE_HOOKS(IdentityImageFilter)
IdentityImageFilter(sk_sp<SkImageFilter> input) : INHERITED(&input, 1, nullptr) {}
typedef SkImageFilter INHERITED;
diff --git a/include/core/SkDrawable.h b/include/core/SkDrawable.h
index 34335a7..48cca6d 100644
--- a/include/core/SkDrawable.h
+++ b/include/core/SkDrawable.h
@@ -123,6 +123,7 @@
}
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 eae0a97..2714436 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -52,21 +52,8 @@
/**
* 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 @@
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<SkFlattenable> 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 bfaa896..b767ae5 100644
--- a/include/effects/Sk1DPathEffect.h
+++ b/include/effects/Sk1DPathEffect.h
@@ -58,8 +58,6 @@
*/
static sk_sp<SkPathEffect> 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 @@
SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const override;
private:
- static sk_sp<SkFlattenable> 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 e29ce1e..5d7a208 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -60,8 +60,6 @@
}
- Factory getFactory() const override { return CreateProc; }
-
protected:
SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
: Sk2DPathEffect(matrix), fWidth(width) {
@@ -73,8 +71,7 @@
void nextSpan(int u, int v, int ucount, SkPath*) const override;
private:
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
+ SK_FLATTENABLE_HOOKS(SkLine2DPathEffect)
SkScalar fWidth;
@@ -91,8 +88,6 @@
return sk_sp<SkPathEffect>(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 @@
void next(const SkPoint&, int u, int v, SkPath*) const override;
private:
- static sk_sp<SkFlattenable> 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 8f83827..99be9ed 100644
--- a/include/effects/SkColorFilterImageFilter.h
+++ b/include/effects/SkColorFilterImageFilter.h
@@ -17,8 +17,6 @@
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
- Factory getFactory() const override { return CreateProc; }
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -29,11 +27,11 @@
bool affectsTransparentBlack() const override;
private:
+ SK_FLATTENABLE_HOOKS(SkColorFilterImageFilter)
+
SkColorFilterImageFilter(sk_sp<SkColorFilter> cf,
sk_sp<SkImageFilter> input,
const CropRect* cropRect);
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
sk_sp<SkColorFilter> fColorFilter;
diff --git a/include/effects/SkComposeImageFilter.h b/include/effects/SkComposeImageFilter.h
index acde1d6..ab3ce63 100644
--- a/include/effects/SkComposeImageFilter.h
+++ b/include/effects/SkComposeImageFilter.h
@@ -17,8 +17,6 @@
SkRect computeFastBounds(const SkRect& src) const override;
- Factory getFactory() const override { return CreateProc; }
-
protected:
explicit SkComposeImageFilter(sk_sp<SkImageFilter> inputs[2]) : INHERITED(inputs, 2, nullptr) {
SkASSERT(inputs[0].get());
@@ -32,8 +30,7 @@
bool onCanHandleComplexCTM() const override { return true; }
private:
- static sk_sp<SkFlattenable> 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 f35f32e..b4807f5 100644
--- a/include/effects/SkCornerPathEffect.h
+++ b/include/effects/SkCornerPathEffect.h
@@ -25,22 +25,20 @@
return radius > 0 ? sk_sp<SkPathEffect>(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<SkFlattenable> 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 99bfb3a..aa043db 100644
--- a/include/effects/SkDiscretePathEffect.h
+++ b/include/effects/SkDiscretePathEffect.h
@@ -32,8 +32,6 @@
*/
static sk_sp<SkPathEffect> 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 @@
bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
private:
- static sk_sp<SkFlattenable> 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 1790e47..a5fd1bd 100644
--- a/include/effects/SkDisplacementMapEffect.h
+++ b/include/effects/SkDisplacementMapEffect.h
@@ -39,8 +39,6 @@
SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const override;
- Factory getFactory() const override { return CreateProc; }
-
protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
@@ -52,8 +50,7 @@
void flatten(SkWriteBuffer&) const override;
private:
- static sk_sp<SkFlattenable> 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 c86550d..b28d244 100644
--- a/include/effects/SkDropShadowImageFilter.h
+++ b/include/effects/SkDropShadowImageFilter.h
@@ -31,8 +31,6 @@
SkRect computeFastBounds(const SkRect&) const override;
- Factory getFactory() const override { return CreateProc; }
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -42,11 +40,11 @@
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<SkImageFilter> input,
const CropRect* cropRect);
- static sk_sp<SkFlattenable> 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 11bc7ed..13aede1 100644
--- a/include/effects/SkImageSource.h
+++ b/include/effects/SkImageSource.h
@@ -22,8 +22,6 @@
SkRect computeFastBounds(const SkRect& src) const override;
- Factory getFactory() const override { return CreateProc; }
-
protected:
void flatten(SkWriteBuffer&) const override;
@@ -35,13 +33,13 @@
MapDirection, const SkIRect* inputRect) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkImageSource)
+
explicit SkImageSource(sk_sp<SkImage>);
SkImageSource(sk_sp<SkImage>,
const SkRect& srcRect,
const SkRect& dstRect,
SkFilterQuality);
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
sk_sp<SkImage> fImage;
SkRect fSrcRect, fDstRect;
diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h
index 18a9b93..b18b32c 100644
--- a/include/effects/SkLayerDrawLooper.h
+++ b/include/effects/SkLayerDrawLooper.h
@@ -75,9 +75,6 @@
bool asABlurShadow(BlurShadowRec* rec) const override;
- Factory getFactory() const override { return CreateProc; }
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
-
protected:
sk_sp<SkDrawLooper> onMakeColorSpace(SkColorSpaceXformer*) const override;
@@ -86,6 +83,8 @@
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 38886f8..500dae9 100644
--- a/include/effects/SkLumaColorFilter.h
+++ b/include/effects/SkLumaColorFilter.h
@@ -36,17 +36,15 @@
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<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
typedef SkColorFilter INHERITED;
};
diff --git a/include/effects/SkMagnifierImageFilter.h b/include/effects/SkMagnifierImageFilter.h
index 5a383dc..f060b48 100644
--- a/include/effects/SkMagnifierImageFilter.h
+++ b/include/effects/SkMagnifierImageFilter.h
@@ -18,8 +18,6 @@
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
- Factory getFactory() const override { return CreateProc; }
-
protected:
SkMagnifierImageFilter(const SkRect& srcRect,
SkScalar inset,
@@ -32,8 +30,7 @@
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
private:
- static sk_sp<SkFlattenable> 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 ccee2fd..bde0863 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -68,8 +68,6 @@
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
- Factory getFactory() const override { return CreateProc; }
-
protected:
SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
const SkScalar* kernel,
@@ -90,8 +88,7 @@
bool affectsTransparentBlack() const override;
private:
- static sk_sp<SkFlattenable> 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 978c07e..ed66596 100644
--- a/include/effects/SkMergeImageFilter.h
+++ b/include/effects/SkMergeImageFilter.h
@@ -25,8 +25,6 @@
return Make(array, 2, cropRect);
}
- Factory getFactory() const override { return CreateProc; }
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -35,9 +33,9 @@
bool onCanHandleComplexCTM() const override { return true; }
private:
+ SK_FLATTENABLE_HOOKS(SkMergeImageFilter)
+
SkMergeImageFilter(sk_sp<SkImageFilter>* const filters, int count, const CropRect* cropRect);
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
typedef SkImageFilter INHERITED;
};
diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h
index aa9edfd..5ed624f 100644
--- a/include/effects/SkMorphologyImageFilter.h
+++ b/include/effects/SkMorphologyImageFilter.h
@@ -62,18 +62,16 @@
sk_sp<SkImageFilter> 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<SkImageFilter> input,
const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
typedef SkMorphologyImageFilter INHERITED;
};
@@ -85,17 +83,15 @@
sk_sp<SkImageFilter> 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<SkImageFilter> input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
typedef SkMorphologyImageFilter INHERITED;
};
diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h
index bbf19a9..e9a771c 100644
--- a/include/effects/SkOffsetImageFilter.h
+++ b/include/effects/SkOffsetImageFilter.h
@@ -20,8 +20,6 @@
SkRect computeFastBounds(const SkRect& src) const override;
- Factory getFactory() const override { return CreateProc; }
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -31,9 +29,9 @@
MapDirection, const SkIRect* inputRect) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkOffsetImageFilter)
+
SkOffsetImageFilter(SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input, const CropRect*);
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
SkVector fOffset;
diff --git a/include/effects/SkOverdrawColorFilter.h b/include/effects/SkOverdrawColorFilter.h
index 37aa813..d678f26 100644
--- a/include/effects/SkOverdrawColorFilter.h
+++ b/include/effects/SkOverdrawColorFilter.h
@@ -32,14 +32,14 @@
GrContext*, const GrColorSpaceInfo&) const override;
#endif
- static sk_sp<SkFlattenable> 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 8765665..4b6772e 100644
--- a/include/effects/SkPaintImageFilter.h
+++ b/include/effects/SkPaintImageFilter.h
@@ -27,8 +27,6 @@
bool affectsTransparentBlack() const override;
- Factory getFactory() const override { return CreateProc; }
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -36,9 +34,9 @@
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkPaintImageFilter)
+
SkPaintImageFilter(const SkPaint& paint, const CropRect* rect);
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
SkPaint fPaint;
diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h
index f3011ad..a1a5b38 100644
--- a/include/effects/SkPictureImageFilter.h
+++ b/include/effects/SkPictureImageFilter.h
@@ -26,8 +26,6 @@
static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> 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 @@
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkPictureImageFilter)
+
explicit SkPictureImageFilter(sk_sp<SkPicture> picture);
SkPictureImageFilter(sk_sp<SkPicture> picture, const SkRect& cropRect, sk_sp<SkColorSpace>);
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
sk_sp<SkPicture> fPicture;
SkRect fCropRect;
diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h
index 2310da3..bcd2f5b 100644
--- a/include/effects/SkTileImageFilter.h
+++ b/include/effects/SkTileImageFilter.h
@@ -28,8 +28,6 @@
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 @@
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkTileImageFilter)
+
SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, sk_sp<SkImageFilter> input)
: INHERITED(&input, 1, nullptr), fSrcRect(srcRect), fDstRect(dstRect) {}
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
SkRect fSrcRect;
SkRect fDstRect;
diff --git a/include/effects/SkToSRGBColorFilter.h b/include/effects/SkToSRGBColorFilter.h
index 20264aa..f577fb9 100644
--- a/include/effects/SkToSRGBColorFilter.h
+++ b/include/effects/SkToSRGBColorFilter.h
@@ -27,15 +27,13 @@
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<SkColorSpace>);
void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
bool shaderIsOpaque) const override;
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
sk_sp<SkColorSpace> fSrcColorSpace;
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 2841210..5eb7ade 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -40,8 +40,6 @@
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 @@
}
private:
+ SK_FLATTENABLE_HOOKS(Dot2DPathEffect)
+
SkScalar fRadius;
typedef Sk2DPathEffect INHERITED;
diff --git a/samplecode/SampleTextEffects.cpp b/samplecode/SampleTextEffects.cpp
index 4e580d8..c43462e 100644
--- a/samplecode/SampleTextEffects.cpp
+++ b/samplecode/SampleTextEffects.cpp
@@ -29,7 +29,6 @@
SkTDArray<SkPoint>* pts)
: Sk2DPathEffect(matrix), fRadius(radius), fPts(pts) {}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Dot2DPathEffect)
class Registrar {
public:
Registrar() {
@@ -60,6 +59,8 @@
}
private:
+ SK_FLATTENABLE_HOOKS(Dot2DPathEffect)
+
SkScalar fRadius;
SkTDArray<SkPoint>* fPts;
@@ -84,9 +85,9 @@
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 1787931..8ea8eed 100644
--- a/site/dev/contrib/flatten.md
+++ b/site/dev/contrib/flatten.md
@@ -34,9 +34,9 @@
<!--?prettify?-->
~~~~
-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 db4a325..d3f0177 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -859,14 +859,14 @@
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<SkShader> fProxy;
typedef SkShaderBase INHERITED;
diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp
index f4907b9..61fe3f5 100644
--- a/src/core/SkBlurMF.cpp
+++ b/src/core/SkBlurMF.cpp
@@ -70,7 +70,6 @@
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 @@
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 1b0b9c2..ffa2a00 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -121,8 +121,6 @@
}
#endif
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeColorFilter)
-
protected:
void flatten(SkWriteBuffer& buffer) const override {
buffer.writeFlattenable(fOuter.get());
@@ -130,6 +128,8 @@
}
private:
+ SK_FLATTENABLE_HOOKS(SkComposeColorFilter)
+
SkComposeColorFilter(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner,
int composedFilterCount)
: fOuter(std::move(outer))
@@ -216,8 +216,6 @@
}
#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 @@
}
private:
+ SK_FLATTENABLE_HOOKS(SkSRGBGammaColorFilter)
+
const Direction fDir;
friend class SkColorFilter;
diff --git a/src/core/SkColorMatrixFilterRowMajor255.h b/src/core/SkColorMatrixFilterRowMajor255.h
index 968c4c8..837c630 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.h
+++ b/src/core/SkColorMatrixFilterRowMajor255.h
@@ -28,16 +28,14 @@
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<SkFlattenable> 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 31860d4..f1f9ad7 100644
--- a/src/core/SkDraw_vertices.cpp
+++ b/src/core/SkDraw_vertices.cpp
@@ -77,8 +77,6 @@
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 @@
}
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 a5228fe..0000000
--- 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<SkFlattenable> 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 27f801d..ece1009 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 8a3ee2c..abdadbf 100644
--- a/src/core/SkLocalMatrixImageFilter.h
+++ b/src/core/SkLocalMatrixImageFilter.h
@@ -19,8 +19,6 @@
public:
static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter> input);
- Factory getFactory() const override { return CreateProc; }
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -30,9 +28,9 @@
MapDirection, const SkIRect* inputRect) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkLocalMatrixImageFilter)
+
SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input);
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
SkMatrix fLocalM;
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index dfd6a55..3d49dfa 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -394,7 +394,6 @@
}
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 @@
#endif
private:
+ SK_FLATTENABLE_HOOKS(SkComposeMF)
+
sk_sp<SkMaskFilter> fOuter;
sk_sp<SkMaskFilter> fInner;
@@ -482,7 +483,7 @@
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 @@
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 a100aec..6c336c8 100644
--- a/src/core/SkMatrixImageFilter.h
+++ b/src/core/SkMatrixImageFilter.h
@@ -32,8 +32,6 @@
SkRect computeFastBounds(const SkRect&) const override;
- Factory getFactory() const override { return CreateProc; }
-
protected:
SkMatrixImageFilter(const SkMatrix& transform,
SkFilterQuality,
@@ -47,8 +45,7 @@
MapDirection, const SkIRect* inputRect) const override;
private:
- static sk_sp<SkFlattenable> 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 138b00e..ce0b323 100644
--- a/src/core/SkModeColorFilter.h
+++ b/src/core/SkModeColorFilter.h
@@ -20,8 +20,6 @@
bool asColorMode(SkColor*, SkBlendMode*) const override;
uint32_t getFlags() const override;
- Factory getFactory() const override { return CreateProc; }
-
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrContext*, const GrColorSpaceInfo&) const override;
@@ -38,8 +36,7 @@
sk_sp<SkColorFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
private:
- static sk_sp<SkFlattenable> 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 9303ba1..5751b0f 100644
--- a/src/core/SkNormalFlatSource.h
+++ b/src/core/SkNormalFlatSource.h
@@ -21,12 +21,12 @@
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 dfedfd3..c17a770 100644
--- a/src/core/SkNormalMapSource.h
+++ b/src/core/SkNormalMapSource.h
@@ -23,8 +23,6 @@
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 @@
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 7d75627..34ea247 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -94,8 +94,6 @@
return sk_sp<SkPathEffect>(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 @@
}
private:
+ SK_FLATTENABLE_HOOKS(SkComposePathEffect)
+
// illegal
SkComposePathEffect(const SkComposePathEffect&);
SkComposePathEffect& operator=(const SkComposePathEffect&);
@@ -154,7 +154,7 @@
return sk_sp<SkPathEffect>(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 c7ba741..a3fca56 100644
--- a/src/core/SkRecordedDrawable.h
+++ b/src/core/SkRecordedDrawable.h
@@ -24,10 +24,6 @@
void flatten(SkWriteBuffer& buffer) const override;
- static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
-
- Factory getFactory() const override { return CreateProc; }
-
protected:
SkRect onGetBounds() override { return fBounds; }
@@ -36,6 +32,8 @@
SkPicture* onNewPictureSnapshot() override;
private:
+ SK_FLATTENABLE_HOOKS(SkRecordedDrawable)
+
sk_sp<SkRecord> fRecord;
sk_sp<SkBBoxHierarchy> fBBH;
std::unique_ptr<SkDrawableList> fDrawableList;
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index c68c47e..7e04f76 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -63,7 +63,7 @@
// 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<GrFragmentProcessor> asFragmentProcessor(
@@ -73,6 +73,9 @@
#endif
private:
+ Factory getFactory() const override { return fMatrixFilter->getFactory(); }
+ const char* getTypeName() const override { return fMatrixFilter->getTypeName(); }
+
SkColor fMul, fAdd;
sk_sp<SkColorFilter> fMatrixFilter;
diff --git a/src/effects/SkDashImpl.h b/src/effects/SkDashImpl.h
index c1bf462..c53928a 100644
--- a/src/effects/SkDashImpl.h
+++ b/src/effects/SkDashImpl.h
@@ -14,8 +14,6 @@
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 @@
DashType onAsADash(DashInfo* info) const override;
private:
- static sk_sp<SkFlattenable> 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 7f45037..ebb643a 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 7b58786..221b81f 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 @@
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 ef863e9..9c02429 100644
--- a/src/effects/SkHighContrastFilter.cpp
+++ b/src/effects/SkHighContrastFilter.cpp
@@ -45,12 +45,12 @@
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 6f6e114..ea4f811 100644
--- a/src/effects/SkOpPE.h
+++ b/src/effects/SkOpPE.h
@@ -14,15 +14,13 @@
public:
SkOpPE(sk_sp<SkPathEffect> one, sk_sp<SkPathEffect> 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<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
+ SK_FLATTENABLE_HOOKS(SkOpPE)
sk_sp<SkPathEffect> fOne;
sk_sp<SkPathEffect> fTwo;
@@ -35,15 +33,12 @@
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<SkFlattenable> CreateProc(SkReadBuffer&);
- friend class SkFlattenable::PrivateInitializer;
+ SK_FLATTENABLE_HOOKS(SkMatrixPE)
SkMatrix fMatrix;
@@ -54,16 +49,13 @@
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<SkFlattenable> 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 05940ec..48e9d2e 100644
--- a/src/effects/SkShaderMaskFilter.cpp
+++ b/src/effects/SkShaderMaskFilter.cpp
@@ -27,8 +27,6 @@
bool asABlur(BlurRec*) const override { return false; }
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkShaderMF)
-
protected:
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> onAsFragmentProcessor(const GrFPArgs&) const override;
@@ -36,6 +34,8 @@
#endif
private:
+ SK_FLATTENABLE_HOOKS(SkShaderMF)
+
sk_sp<SkShader> fShader;
SkShaderMF(SkReadBuffer&);
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 7e3ad48..619d738 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -91,8 +91,6 @@
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 @@
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 8ff58ec..f1119f8 100644
--- a/src/effects/SkTableMaskFilter.cpp
+++ b/src/effects/SkTableMaskFilter.cpp
@@ -18,14 +18,14 @@
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 cbaab89..c4fc7e0 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 @@
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 9cababc..b9bd42a 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -31,7 +31,6 @@
SkScalar outerThreshold, sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterImpl)
friend void SkAlphaThresholdFilter::InitializeFlattenables();
protected:
@@ -49,6 +48,8 @@
#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 29df301..c58ff77 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -51,8 +51,6 @@
sk_sp<SkImageFilter> 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<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
@@ -83,6 +81,8 @@
sk_sp<SkImageFilter> 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 053a208..15c7aa6 100644
--- a/src/effects/imagefilters/SkBlurImageFilter.cpp
+++ b/src/effects/imagefilters/SkBlurImageFilter.cpp
@@ -41,8 +41,6 @@
SkRect computeFastBounds(const SkRect&) const override;
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilterImpl)
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
@@ -52,6 +50,8 @@
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 fcbe226..9bea794 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 9a2d054..3d24efa 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 36a9d71..d19c05f 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 e57504c..e105c58 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 @@
sk_sp<SkImageFilter>,
const CropRect*);
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter)
SkScalar kd() const { return fKD; }
protected:
@@ -550,6 +548,7 @@
#endif
private:
+ SK_FLATTENABLE_HOOKS(SkDiffuseLightingImageFilter)
friend class SkLightingImageFilter;
SkScalar fKD;
@@ -563,8 +562,6 @@
SkScalar ks, SkScalar shininess,
sk_sp<SkImageFilter>, const CropRect*);
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
-
SkScalar ks() const { return fKS; }
SkScalar shininess() const { return fShininess; }
@@ -587,6 +584,8 @@
#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 c17e8fa..6c46c4c 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 9e71ab6..7668a02 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 3225ba8..633ddd4 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 24686f8..5b823f1 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 8dacc11..25b7289 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 a25dee5..898f970 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 7ced09e..eddad27 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 4246bae..317b5a2 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 @@
SkXfermodeImageFilter_Base(SkBlendMode mode, sk_sp<SkImageFilter> inputs[2],
const CropRect* cropRect);
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter_Base)
-
protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
@@ -64,6 +61,8 @@
#endif
private:
+ SK_FLATTENABLE_HOOKS(SkXfermodeImageFilter_Base)
+
static sk_sp<SkFlattenable> LegacyArithmeticCreateProc(SkReadBuffer& buffer);
SkBlendMode fMode;
diff --git a/src/gpu/GrTestUtils.h b/src/gpu/GrTestUtils.h
index ffc48aa..2e8eb06 100644
--- a/src/gpu/GrTestUtils.h
+++ b/src/gpu/GrTestUtils.h
@@ -73,6 +73,7 @@
}
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 b79c7a7..78fd99e 100644
--- a/src/gpu/text/GrSDFMaskFilter.cpp
+++ b/src/gpu/text/GrSDFMaskFilter.cpp
@@ -26,11 +26,11 @@
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 5d73177..bea559b 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 d97dd06..59c7004 100644
--- a/src/shaders/SkColorFilterShader.h
+++ b/src/shaders/SkColorFilterShader.h
@@ -21,14 +21,14 @@
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
#endif
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterShader)
-
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
bool onAppendStages(const StageRec&) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkColorFilterShader)
+
sk_sp<SkShader> fShader;
sk_sp<SkColorFilter> fFilter;
diff --git a/src/shaders/SkColorShader.h b/src/shaders/SkColorShader.h
index 1b29044..6ec7971 100644
--- a/src/shaders/SkColorShader.h
+++ b/src/shaders/SkColorShader.h
@@ -50,8 +50,6 @@
std::unique_ptr<GrFragmentProcessor> 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 @@
}
private:
+ SK_FLATTENABLE_HOOKS(SkColorShader)
+
SkColor fColor;
typedef SkShaderBase INHERITED;
@@ -107,8 +107,6 @@
std::unique_ptr<GrFragmentProcessor> 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 @@
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkColor4Shader)
+
sk_sp<SkColorSpace> fColorSpace;
const SkColor4f fColor4;
const SkColor fCachedByteColor;
diff --git a/src/shaders/SkComposeShader.h b/src/shaders/SkComposeShader.h
index c2dc2c3..7027d33 100644
--- a/src/shaders/SkComposeShader.h
+++ b/src/shaders/SkComposeShader.h
@@ -35,8 +35,6 @@
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 @@
bool onAppendStages(const StageRec&) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkComposeShader)
+
sk_sp<SkShader> fDst;
sk_sp<SkShader> fSrc;
const float fLerpT;
diff --git a/src/shaders/SkEmptyShader.h b/src/shaders/SkEmptyShader.h
index 673fc27..b0dae05 100644
--- a/src/shaders/SkEmptyShader.h
+++ b/src/shaders/SkEmptyShader.h
@@ -20,8 +20,6 @@
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 @@
}
private:
+ SK_FLATTENABLE_HOOKS(SkEmptyShader)
+
typedef SkShaderBase INHERITED;
};
diff --git a/src/shaders/SkImageShader.h b/src/shaders/SkImageShader.h
index c790d63..0da2760 100644
--- a/src/shaders/SkImageShader.h
+++ b/src/shaders/SkImageShader.h
@@ -23,13 +23,13 @@
bool isOpaque() const override;
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader)
-
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
#endif
private:
+ SK_FLATTENABLE_HOOKS(SkImageShader)
+
SkImageShader(sk_sp<SkImage>,
SkShader::TileMode tx,
SkShader::TileMode ty,
diff --git a/src/shaders/SkLightingShader.cpp b/src/shaders/SkLightingShader.cpp
index 73e40bb..ee09dc9 100644
--- a/src/shaders/SkLightingShader.cpp
+++ b/src/shaders/SkLightingShader.cpp
@@ -80,8 +80,6 @@
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 @@
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkLightingShaderImpl)
+
sk_sp<SkShader> fDiffuseShader;
sk_sp<SkNormalSource> fNormalSource;
sk_sp<SkLights> fLights;
diff --git a/src/shaders/SkLightingShader.h b/src/shaders/SkLightingShader.h
index f7e63b2..3350bc1 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 30efb27..810220e 100644
--- a/src/shaders/SkLocalMatrixShader.h
+++ b/src/shaders/SkLocalMatrixShader.h
@@ -38,8 +38,6 @@
return fProxyShader;
}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixShader)
-
protected:
void flatten(SkWriteBuffer&) const override;
@@ -57,6 +55,8 @@
}
private:
+ SK_FLATTENABLE_HOOKS(SkLocalMatrixShader)
+
sk_sp<SkShader> fProxyShader;
typedef SkShaderBase INHERITED;
diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp
index 357df0a..86879f3 100644
--- a/src/shaders/SkPerlinNoiseShader.cpp
+++ b/src/shaders/SkPerlinNoiseShader.cpp
@@ -365,8 +365,6 @@
std::unique_ptr<GrFragmentProcessor> 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 @@
#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 514d71f..2dcf2fd 100644
--- a/src/shaders/SkPictureShader.h
+++ b/src/shaders/SkPictureShader.h
@@ -28,8 +28,6 @@
static sk_sp<SkShader> Make(sk_sp<SkPicture>, TileMode, TileMode, const SkMatrix*,
const SkRect*);
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
-
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
#endif
@@ -44,6 +42,8 @@
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
private:
+ SK_FLATTENABLE_HOOKS(SkPictureShader)
+
SkPictureShader(sk_sp<SkPicture>, TileMode, TileMode, const SkMatrix*, const SkRect*,
sk_sp<SkColorSpace>);
diff --git a/src/shaders/SkShaderBase.h b/src/shaders/SkShaderBase.h
index b607cc8..0b9bf58 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 9d00708..a549fcd 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 73af165..9950e6d 100644
--- a/src/shaders/gradients/SkLinearGradient.h
+++ b/src/shaders/gradients/SkLinearGradient.h
@@ -19,8 +19,6 @@
std::unique_ptr<GrFragmentProcessor> 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 @@
sk_sp<SkShader> 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 d6963f6..caff786 100644
--- a/src/shaders/gradients/SkRadialGradient.h
+++ b/src/shaders/gradients/SkRadialGradient.h
@@ -19,8 +19,6 @@
std::unique_ptr<GrFragmentProcessor> 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 @@
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 8957b47..7fea967 100644
--- a/src/shaders/gradients/SkSweepGradient.h
+++ b/src/shaders/gradients/SkSweepGradient.h
@@ -24,8 +24,6 @@
SkScalar getTScale() const { return fTScale; }
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
-
protected:
void flatten(SkWriteBuffer& buffer) const override;
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
@@ -34,6 +32,8 @@
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 e126054..f764c01 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient.h
+++ b/src/shaders/gradients/SkTwoPointConicalGradient.h
@@ -64,8 +64,6 @@
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<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
@@ -74,6 +72,8 @@
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 29ac188..a382d53 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 @@
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 @@
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 08b6df6..bf30dd9 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 @@
public:
static sk_sp<SkImageFilter> Make() { return sk_sp<SkImageFilter>(new ZeroBoundsImageFilter); }
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ZeroBoundsImageFilter)
-
protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage*, const Context&, SkIPoint*) const override {
return nullptr;
@@ -851,6 +848,8 @@
}
private:
+ SK_FLATTENABLE_HOOKS(ZeroBoundsImageFilter)
+
ZeroBoundsImageFilter() : INHERITED(nullptr, 0, nullptr) {}
typedef SkImageFilter INHERITED;
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp
index f9e2659..5dcf914 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -1154,6 +1154,7 @@
static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(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 @@
public:
static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(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 @@
return sk_sp<SkPathEffect>(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 @@
return sk_sp<SkPathEffect>(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 @@
public:
static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(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 0ae8d57..16653e2 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -57,8 +57,6 @@
return sk_sp<SkImageFilter>(new MatrixTestImageFilter(reporter, expectedMatrix));
}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter)
-
protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context& ctx,
SkIPoint* offset) const override {
@@ -75,6 +73,8 @@
}
private:
+ SK_FLATTENABLE_HOOKS(MatrixTestImageFilter)
+
MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expectedMatrix)
: INHERITED(nullptr, 0, nullptr)
, fReporter(reporter)
@@ -100,7 +100,7 @@
return nullptr;
}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
+ SK_FLATTENABLE_HOOKS(FailImageFilter)
private:
typedef SkImageFilter INHERITED;
@@ -289,6 +289,7 @@
private:
Factory getFactory() const override { return nullptr; }
+ const char* getTypeName() const override { return nullptr; }
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* src, const Context&,
SkIPoint* offset) const override {
@@ -1831,6 +1832,7 @@
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 fec03dc..9b97b03 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -359,7 +359,6 @@
return sk_sp<DummyImageFilter>(new DummyImageFilter(visited));
}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter)
bool visited() const { return fVisited; }
protected:
@@ -374,6 +373,7 @@
}
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 ffa012b..4bffe13 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 @@
return nullptr;
}
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestLooper)
-
private:
+ SK_FLATTENABLE_HOOKS(TestLooper)
+
class TestDrawLooperContext : public SkDrawLooper::Context {
public:
TestDrawLooperContext() : fOnce(true) {}