| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkFlattenable_DEFINED | 8 #ifndef SkFlattenable_DEFINED |
| 9 #define SkFlattenable_DEFINED | 9 #define SkFlattenable_DEFINED |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 */ | 33 */ |
| 34 | 34 |
| 35 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab
les(); | 35 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab
les(); |
| 36 | 36 |
| 37 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ | 37 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ |
| 38 void flattenable::InitializeFlattenables() { | 38 void flattenable::InitializeFlattenables() { |
| 39 | 39 |
| 40 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ | 40 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ |
| 41 } | 41 } |
| 42 | 42 |
| 43 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \ | |
| 44 virtual Factory getFactory() const SK_OVERRIDE { return NULL; } | |
| 45 | |
| 46 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ | 43 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ |
| 47 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ | 44 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ |
| 48 flattenable::GetFlattenableType()); | 45 flattenable::GetFlattenableType()); |
| 49 | 46 |
| 50 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ | 47 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ |
| 51 private: \ | 48 private: \ |
| 52 static SkFlattenable* CreateProc(SkReadBuffer&); \ | 49 static SkFlattenable* CreateProc(SkReadBuffer&); \ |
| 53 friend class SkPrivateEffectInitializer; \ | 50 friend class SkPrivateEffectInitializer; \ |
| 54 public: \ | 51 public: \ |
| 55 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } | 52 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } |
| 56 | 53 |
| 57 // If your subclass will *never* need to be unflattened, declare this. | |
| 58 #define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \ | |
| 59 virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc
; } | |
| 60 | |
| 61 /** For SkFlattenable derived objects with a valid type | 54 /** For SkFlattenable derived objects with a valid type |
| 62 This macro should only be used in base class objects in core | 55 This macro should only be used in base class objects in core |
| 63 */ | 56 */ |
| 64 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \ | 57 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \ |
| 65 static Type GetFlattenableType() { \ | 58 static Type GetFlattenableType() { \ |
| 66 return k##flattenable##_Type; \ | 59 return k##flattenable##_Type; \ |
| 67 } | 60 } |
| 68 | 61 |
| 69 /** \class SkFlattenable | 62 /** \class SkFlattenable |
| 70 | 63 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 SkFlattenable::Register(name, factory, type); | 108 SkFlattenable::Register(name, factory, type); |
| 116 } | 109 } |
| 117 }; | 110 }; |
| 118 | 111 |
| 119 /** | 112 /** |
| 120 * Override this if your subclass needs to record data that it will need to
recreate itself | 113 * Override this if your subclass needs to record data that it will need to
recreate itself |
| 121 * from its CreateProc (returned by getFactory()). | 114 * from its CreateProc (returned by getFactory()). |
| 122 */ | 115 */ |
| 123 virtual void flatten(SkWriteBuffer&) const {} | 116 virtual void flatten(SkWriteBuffer&) const {} |
| 124 | 117 |
| 125 protected: | |
| 126 static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) { | |
| 127 return NULL; | |
| 128 } | |
| 129 | |
| 130 private: | 118 private: |
| 131 static void InitializeFlattenablesIfNeeded(); | 119 static void InitializeFlattenablesIfNeeded(); |
| 132 | 120 |
| 133 friend class SkGraphics; | 121 friend class SkGraphics; |
| 134 | 122 |
| 135 typedef SkRefCnt INHERITED; | 123 typedef SkRefCnt INHERITED; |
| 136 }; | 124 }; |
| 137 | 125 |
| 138 #endif | 126 #endif |
| OLD | NEW |