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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab
les(); | 37 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenab
les(); |
38 | 38 |
39 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ | 39 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ |
40 void flattenable::InitializeFlattenables() { | 40 void flattenable::InitializeFlattenables() { |
41 | 41 |
42 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ | 42 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ |
43 } | 43 } |
44 | 44 |
45 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ | 45 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ |
46 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ | 46 SkFlattenable::Register(#flattenable, flattenable::CreateProc, \ |
47 flattenable::GetFlattenableType()); | 47 flattenable::GetFlattenableType()); |
48 | 48 |
49 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ | 49 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ |
50 private: \ | 50 private: \ |
51 static SkFlattenable* CreateProc(SkReadBuffer&); \ | 51 static SkFlattenable* CreateProc(SkReadBuffer&); \ |
52 friend class ::SkPrivateEffectInitializer; \ | 52 friend class ::SkPrivateEffectInitializer; \ |
53 public: \ | 53 public: \ |
54 Factory getFactory() const override { return CreateProc; } | 54 Factory getFactory() const override { return CreateProc; } |
55 | 55 |
56 /** For SkFlattenable derived objects with a valid type | 56 /** For SkFlattenable derived objects with a valid type |
57 This macro should only be used in base class objects in core | 57 This macro should only be used in base class objects in core |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 /** Returns the name of the object's class | 95 /** Returns the name of the object's class |
96 */ | 96 */ |
97 const char* getTypeName() const { return FactoryToName(getFactory()); } | 97 const char* getTypeName() const { return FactoryToName(getFactory()); } |
98 | 98 |
99 static Factory NameToFactory(const char name[]); | 99 static Factory NameToFactory(const char name[]); |
100 static const char* FactoryToName(Factory); | 100 static const char* FactoryToName(Factory); |
101 static bool NameToType(const char name[], Type* type); | 101 static bool NameToType(const char name[], Type* type); |
102 | 102 |
103 static void Register(const char name[], Factory, Type); | 103 static void Register(const char name[], Factory, Type); |
104 | 104 |
105 class Registrar { | |
106 public: | |
107 Registrar(const char name[], Factory factory, Type type) { | |
108 SkFlattenable::Register(name, factory, type); | |
109 } | |
110 }; | |
111 | |
112 /** | 105 /** |
113 * Override this if your subclass needs to record data that it will need to
recreate itself | 106 * Override this if your subclass needs to record data that it will need to
recreate itself |
114 * from its CreateProc (returned by getFactory()). | 107 * from its CreateProc (returned by getFactory()). |
115 */ | 108 */ |
116 virtual void flatten(SkWriteBuffer&) const {} | 109 virtual void flatten(SkWriteBuffer&) const {} |
117 | 110 |
118 private: | 111 private: |
119 static void InitializeFlattenablesIfNeeded(); | 112 static void InitializeFlattenablesIfNeeded(); |
120 | 113 |
121 friend class SkGraphics; | 114 friend class SkGraphics; |
122 | 115 |
123 typedef SkRefCnt INHERITED; | 116 typedef SkRefCnt INHERITED; |
124 }; | 117 }; |
125 | 118 |
126 #endif | 119 #endif |
OLD | NEW |