8 #ifndef SkFlattenable_DEFINED
9 #define SkFlattenable_DEFINED
59 static void Register(
const char name[], Factory);
67 virtual void flatten(SkWriteBuffer&)
const {}
88 static void RegisterFlattenablesIfNeeded();
89 static void Finalize();
96 #if defined(SK_DISABLE_EFFECT_DESERIALIZATION)
97 #define SK_REGISTER_FLATTENABLE(type) do{}while(false)
99 #define SK_FLATTENABLE_HOOKS(type) \
100 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
101 friend class SkFlattenable::PrivateInitializer; \
102 Factory getFactory() const override { return nullptr; } \
103 const char* getTypeName() const override { return #type; }
105 #define SK_REGISTER_FLATTENABLE(type) \
106 SkFlattenable::Register(#type, type::CreateProc)
108 #define SK_FLATTENABLE_HOOKS(type) \
109 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
110 friend class SkFlattenable::PrivateInitializer; \
111 Factory getFactory() const override { return type::CreateProc; } \
112 const char* getTypeName() const override { return #type; }
SkData holds an immutable data buffer.
Definition: SkData.h:25
Definition: SkFlattenable.h:81
static void InitEffects()
static void InitImageFilters()
SkFlattenable is the base class for objects that need to be flattened into a data stream for either t...
Definition: SkFlattenable.h:28
virtual void flatten(SkWriteBuffer &) const
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
Definition: SkFlattenable.h:67
static void Register(const char name[], Factory)
virtual const char * getTypeName() const =0
Returns the name of the object's class.
static Factory NameToFactory(const char name[])
sk_sp< SkData > serialize(const SkSerialProcs *=nullptr) const
static const char * FactoryToName(Factory)
virtual Type getFlattenableType() const =0
static sk_sp< SkFlattenable > Deserialize(Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
SkFlattenable()
Definition: SkFlattenable.h:43
Type
Definition: SkFlattenable.h:30
@ kSkDrawable_Type
Definition: SkFlattenable.h:33
@ kSkPathEffect_Type
Definition: SkFlattenable.h:37
@ kSkShader_Type
Definition: SkFlattenable.h:38
@ kSkMaskFilter_Type
Definition: SkFlattenable.h:36
@ kSkColorFilter_Type
Definition: SkFlattenable.h:31
@ kSkDrawLooper_Type
Definition: SkFlattenable.h:34
@ kSkBlender_Type
Definition: SkFlattenable.h:32
@ kSkImageFilter_Type
Definition: SkFlattenable.h:35
size_t serialize(void *memory, size_t memory_size, const SkSerialProcs *=nullptr) const
virtual Factory getFactory() const =0
Implement this to return a factory function pointer that can be called to recreate your class given a...
Definition: SkGraphics.h:23
Definition: SkRefCnt.h:119
Definition: SkSerialProcs.h:97
Definition: SkSerialProcs.h:86