| Index: include/core/SkFlattenable.h
|
| diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
|
| index f6d377a9d743b4838f6e2e6206053f0056729bee..4b90e2e1916f649ee96bce6de0394e6fe64b4814 100644
|
| --- a/include/core/SkFlattenable.h
|
| +++ b/include/core/SkFlattenable.h
|
| @@ -1,4 +1,3 @@
|
| -
|
| /*
|
| * Copyright 2006 The Android Open Source Project
|
| *
|
| @@ -6,12 +5,13 @@
|
| * found in the LICENSE file.
|
| */
|
|
|
| -
|
| #ifndef SkFlattenable_DEFINED
|
| #define SkFlattenable_DEFINED
|
|
|
| #include "SkRefCnt.h"
|
|
|
| +//#define SK_SUPPORT_LEGACY_DEEPFLATTENING
|
| +
|
| class SkReadBuffer;
|
| class SkWriteBuffer;
|
|
|
| @@ -30,11 +30,25 @@ class SkWriteBuffer;
|
| #define SK_DECLARE_UNFLATTENABLE_OBJECT() \
|
| virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
|
|
|
| -#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
| - virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \
|
| - static SkFlattenable* CreateProc(SkReadBuffer& buffer) { \
|
| - return SkNEW_ARGS(flattenable, (buffer)); \
|
| +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
| +#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
| + static SkFlattenable* CreateProc(SkReadBuffer&); \
|
| + virtual Factory getFactory() const SK_OVERRIDE {return DeepCreateProc;} \
|
| + static SkFlattenable* DeepCreateProc(SkReadBuffer& buffer) { \
|
| + if (NeedsDeepUnflatten(buffer)) { \
|
| + return SkNEW_ARGS(flattenable, (buffer)); \
|
| + } \
|
| + return CreateProc(buffer); \
|
| }
|
| +#else
|
| +#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
| + static SkFlattenable* CreateProc(SkReadBuffer&); \
|
| + virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
|
| +#endif
|
| +
|
| +// If your subclass will *never* need to be unflattened, declar this.
|
| +#define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \
|
| + virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc; }
|
|
|
| /** For SkFlattenable derived objects with a valid type
|
| This macro should only be used in base class objects in core
|
| @@ -101,7 +115,17 @@ public:
|
| virtual void flatten(SkWriteBuffer&) const;
|
|
|
| protected:
|
| +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
| + enum {
|
| + kNewFlattenVersion = 27
|
| + };
|
| + static bool NeedsDeepUnflatten(const SkReadBuffer&);
|
| SkFlattenable(SkReadBuffer&) {}
|
| +#endif
|
| +
|
| + static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) {
|
| + return NULL;
|
| + }
|
|
|
| private:
|
| static void InitializeFlattenablesIfNeeded();
|
|
|