| Index: include/core/SkFlattenable.h
|
| diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
|
| index 4d45e246a5135c141980ee29de278c77a9c0eabf..c76f119c131d5daf2c2b990d51aa6b952932af22 100644
|
| --- a/include/core/SkFlattenable.h
|
| +++ b/include/core/SkFlattenable.h
|
| @@ -43,7 +43,8 @@
|
| }
|
|
|
| #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
| - SkFlattenable::Register(#flattenable, flattenable::CreateProc);
|
| + SkFlattenable::Register(#flattenable, flattenable::CreateProc, \
|
| + flattenable::GetFlattenableType());
|
|
|
| #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
| private: \
|
| @@ -51,6 +52,14 @@
|
| friend class SkFlattenable::PrivateInitializer; \
|
| public: \
|
| Factory getFactory() const override { return CreateProc; }
|
| +
|
| +/** For SkFlattenable derived objects with a valid type
|
| + This macro should only be used in base class objects in core
|
| + */
|
| +#define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \
|
| + static Type GetFlattenableType() { \
|
| + return k##flattenable##_Type; \
|
| + }
|
|
|
| /** \class SkFlattenable
|
|
|
| @@ -60,6 +69,19 @@
|
| */
|
| class SK_API SkFlattenable : public SkRefCnt {
|
| public:
|
| + enum Type {
|
| + kSkColorFilter_Type,
|
| + kSkDrawLooper_Type,
|
| + kSkImageFilter_Type,
|
| + kSkMaskFilter_Type,
|
| + kSkPathEffect_Type,
|
| + kSkPixelRef_Type,
|
| + kSkRasterizer_Type,
|
| + kSkShader_Type,
|
| + kSkUnused_Type, // used to be SkUnitMapper
|
| + kSkXfermode_Type,
|
| + };
|
| +
|
| typedef sk_sp<SkFlattenable> (*Factory)(SkReadBuffer&);
|
|
|
| SkFlattenable() {}
|
| @@ -76,8 +98,9 @@
|
|
|
| static Factory NameToFactory(const char name[]);
|
| static const char* FactoryToName(Factory);
|
| + static bool NameToType(const char name[], Type* type);
|
|
|
| - static void Register(const char name[], Factory);
|
| + static void Register(const char name[], Factory, Type);
|
|
|
| /**
|
| * Override this if your subclass needs to record data that it will need to recreate itself
|
|
|