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 |
11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
12 | 12 |
13 class SkReadBuffer; | 13 class SkReadBuffer; |
14 class SkWriteBuffer; | 14 class SkWriteBuffer; |
15 | 15 |
| 16 class SkPrivateEffectInitializer; |
| 17 |
16 /* | 18 /* |
17 * Flattening is straight-forward: | 19 * Flattening is straight-forward: |
18 * 1. call getFactory() so we have a function-ptr to recreate the subclass | 20 * 1. call getFactory() so we have a function-ptr to recreate the subclass |
19 * 2. call flatten(buffer) to write out enough data for the factory to read | 21 * 2. call flatten(buffer) to write out enough data for the factory to read |
20 * | 22 * |
21 * Unflattening is easy for the caller: new_instance = factory(buffer) | 23 * Unflattening is easy for the caller: new_instance = factory(buffer) |
22 * | 24 * |
23 * The complexity of supporting this is as follows. | 25 * The complexity of supporting this is as follows. |
24 * | 26 * |
25 * If your subclass wants to control unflattening, use this macro in your decla
ration: | 27 * If your subclass wants to control unflattening, use this macro in your decla
ration: |
(...skipping 14 matching lines...) Expand all Loading... |
40 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ | 42 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ |
41 } | 43 } |
42 | 44 |
43 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ | 45 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ |
44 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ | 46 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ |
45 flattenable::GetFlattenableType()); | 47 flattenable::GetFlattenableType()); |
46 | 48 |
47 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ | 49 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ |
48 private: \ | 50 private: \ |
49 static SkFlattenable* CreateProc(SkReadBuffer&); \ | 51 static SkFlattenable* CreateProc(SkReadBuffer&); \ |
50 friend class SkPrivateEffectInitializer; \ | 52 friend class ::SkPrivateEffectInitializer; \ |
51 public: \ | 53 public: \ |
52 Factory getFactory() const override { return CreateProc; } | 54 Factory getFactory() const override { return CreateProc; } |
53 | 55 |
54 /** For SkFlattenable derived objects with a valid type | 56 /** For SkFlattenable derived objects with a valid type |
55 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 |
56 */ | 58 */ |
57 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \ | 59 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \ |
58 static Type GetFlattenableType() { \ | 60 static Type GetFlattenableType() { \ |
59 return k##flattenable##_Type; \ | 61 return k##flattenable##_Type; \ |
60 } | 62 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 117 |
116 private: | 118 private: |
117 static void InitializeFlattenablesIfNeeded(); | 119 static void InitializeFlattenablesIfNeeded(); |
118 | 120 |
119 friend class SkGraphics; | 121 friend class SkGraphics; |
120 | 122 |
121 typedef SkRefCnt INHERITED; | 123 typedef SkRefCnt INHERITED; |
122 }; | 124 }; |
123 | 125 |
124 #endif | 126 #endif |
OLD | NEW |