Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: include/core/SkFlattenable.h

Issue 768183002: Revert of Remove SK_SUPPORT_LEGACY_DEEPFLATTENING. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkDrawLooper.h ('k') | include/core/SkMaskFilter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #define SK_SUPPORT_LEGACY_DEEPFLATTENING
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 10 matching lines...) Expand all
36 38
37 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ 39 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \
38 void flattenable::InitializeFlattenables() { 40 void flattenable::InitializeFlattenables() {
39 41
40 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ 42 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
41 } 43 }
42 44
43 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \ 45 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \
44 virtual Factory getFactory() const SK_OVERRIDE { return NULL; } 46 virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
45 47
48 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
49 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
50 SkFlattenable::Registrar(#flattenable, flattenable::DeepCreateProc, \
51 flattenable::GetFlattenableType());
52
53 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
54 private: \
55 static SkFlattenable* CreateProc(SkReadBuffer&); \
56 static SkFlattenable* DeepCreateProc(SkReadBuffer& buffer) { \
57 if (NeedsDeepUnflatten(buffer)) { \
58 return SkNEW_ARGS(flattenable, (buffer)); \
59 } \
60 return CreateProc(buffer); \
61 } \
62 friend class SkPrivateEffectInitializer; \
63 public: \
64 virtual Factory getFactory() const SK_OVERRIDE {return DeepCreateProc;}
65 #else
46 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ 66 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
47 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ 67 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
48 flattenable::GetFlattenableType()); 68 flattenable::GetFlattenableType());
49 69
50 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ 70 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
51 private: \ 71 private: \
52 static SkFlattenable* CreateProc(SkReadBuffer&); \ 72 static SkFlattenable* CreateProc(SkReadBuffer&); \
53 friend class SkPrivateEffectInitializer; \ 73 friend class SkPrivateEffectInitializer; \
54 public: \ 74 public: \
55 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } 75 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
76 #endif
56 77
57 // If your subclass will *never* need to be unflattened, declare this. 78 // If your subclass will *never* need to be unflattened, declare this.
58 #define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \ 79 #define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \
59 virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc ; } 80 virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc ; }
60 81
61 /** For SkFlattenable derived objects with a valid type 82 /** For SkFlattenable derived objects with a valid type
62 This macro should only be used in base class objects in core 83 This macro should only be used in base class objects in core
63 */ 84 */
64 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \ 85 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \
65 static Type GetFlattenableType() { \ 86 static Type GetFlattenableType() { \
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 137 }
117 }; 138 };
118 139
119 /** 140 /**
120 * Override this if your subclass needs to record data that it will need to recreate itself 141 * Override this if your subclass needs to record data that it will need to recreate itself
121 * from its CreateProc (returned by getFactory()). 142 * from its CreateProc (returned by getFactory()).
122 */ 143 */
123 virtual void flatten(SkWriteBuffer&) const {} 144 virtual void flatten(SkWriteBuffer&) const {}
124 145
125 protected: 146 protected:
147 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
148 static bool NeedsDeepUnflatten(const SkReadBuffer&);
149 SkFlattenable(SkReadBuffer&) {}
150 #endif
151
126 static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) { 152 static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) {
127 return NULL; 153 return NULL;
128 } 154 }
129 155
130 private: 156 private:
131 static void InitializeFlattenablesIfNeeded(); 157 static void InitializeFlattenablesIfNeeded();
132 158
133 friend class SkGraphics; 159 friend class SkGraphics;
134 160
135 typedef SkRefCnt INHERITED; 161 typedef SkRefCnt INHERITED;
136 }; 162 };
137 163
138 #endif 164 #endif
OLDNEW
« no previous file with comments | « include/core/SkDrawLooper.h ('k') | include/core/SkMaskFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698