| Index: include/core/SkFlattenable.h
|
| diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
|
| index 3cfa85af48787e1636062d8bc44899ac087a89f1..679f640d3c4012a7868486f9a02bdef4b3325d5f 100644
|
| --- a/include/core/SkFlattenable.h
|
| +++ b/include/core/SkFlattenable.h
|
| @@ -12,6 +12,8 @@
|
|
|
| class SkReadBuffer;
|
| class SkWriteBuffer;
|
| +
|
| +#define SK_SUPPORT_LEGACY_DEEPFLATTENING
|
|
|
| /*
|
| * Flattening is straight-forward:
|
| @@ -43,6 +45,24 @@
|
| #define SK_DECLARE_UNFLATTENABLE_OBJECT() \
|
| virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
|
|
|
| +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
| +#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
| + SkFlattenable::Registrar(#flattenable, flattenable::DeepCreateProc, \
|
| + flattenable::GetFlattenableType());
|
| +
|
| +#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
| + private: \
|
| + static SkFlattenable* CreateProc(SkReadBuffer&); \
|
| + static SkFlattenable* DeepCreateProc(SkReadBuffer& buffer) { \
|
| + if (NeedsDeepUnflatten(buffer)) { \
|
| + return SkNEW_ARGS(flattenable, (buffer)); \
|
| + } \
|
| + return CreateProc(buffer); \
|
| + } \
|
| + friend class SkPrivateEffectInitializer; \
|
| + public: \
|
| + virtual Factory getFactory() const SK_OVERRIDE {return DeepCreateProc;}
|
| +#else
|
| #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
| SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
|
| flattenable::GetFlattenableType());
|
| @@ -53,6 +73,7 @@
|
| friend class SkPrivateEffectInitializer; \
|
| public: \
|
| virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
|
| +#endif
|
|
|
| // If your subclass will *never* need to be unflattened, declare this.
|
| #define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \
|
| @@ -123,6 +144,11 @@
|
| virtual void flatten(SkWriteBuffer&) const {}
|
|
|
| protected:
|
| +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
| + static bool NeedsDeepUnflatten(const SkReadBuffer&);
|
| + SkFlattenable(SkReadBuffer&) {}
|
| +#endif
|
| +
|
| static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) {
|
| return NULL;
|
| }
|
|
|