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

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

Issue 769953002: 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
18 /* 16 /*
19 * Flattening is straight-forward: 17 * Flattening is straight-forward:
20 * 1. call getFactory() so we have a function-ptr to recreate the subclass 18 * 1. call getFactory() so we have a function-ptr to recreate the subclass
21 * 2. call flatten(buffer) to write out enough data for the factory to read 19 * 2. call flatten(buffer) to write out enough data for the factory to read
22 * 20 *
23 * Unflattening is easy for the caller: new_instance = factory(buffer) 21 * Unflattening is easy for the caller: new_instance = factory(buffer)
24 * 22 *
25 * The complexity of supporting this is as follows. 23 * The complexity of supporting this is as follows.
26 * 24 *
27 * If your subclass wants to control unflattening, use this macro in your decla ration: 25 * If your subclass wants to control unflattening, use this macro in your decla ration:
(...skipping 10 matching lines...) Expand all
38 36
39 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ 37 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \
40 void flattenable::InitializeFlattenables() { 38 void flattenable::InitializeFlattenables() {
41 39
42 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ 40 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
43 } 41 }
44 42
45 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \ 43 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \
46 virtual Factory getFactory() const SK_OVERRIDE { return NULL; } 44 virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
47 45
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
66 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ 46 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
67 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ 47 SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
68 flattenable::GetFlattenableType()); 48 flattenable::GetFlattenableType());
69 49
70 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ 50 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
71 private: \ 51 private: \
72 static SkFlattenable* CreateProc(SkReadBuffer&); \ 52 static SkFlattenable* CreateProc(SkReadBuffer&); \
73 friend class SkPrivateEffectInitializer; \ 53 friend class SkPrivateEffectInitializer; \
74 public: \ 54 public: \
75 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } 55 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
76 #endif
77 56
78 // If your subclass will *never* need to be unflattened, declare this. 57 // If your subclass will *never* need to be unflattened, declare this.
79 #define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \ 58 #define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \
80 virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc ; } 59 virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc ; }
81 60
82 /** For SkFlattenable derived objects with a valid type 61 /** For SkFlattenable derived objects with a valid type
83 This macro should only be used in base class objects in core 62 This macro should only be used in base class objects in core
84 */ 63 */
85 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \ 64 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \
86 static Type GetFlattenableType() { \ 65 static Type GetFlattenableType() { \
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 116 }
138 }; 117 };
139 118
140 /** 119 /**
141 * Override this if your subclass needs to record data that it will need to recreate itself 120 * Override this if your subclass needs to record data that it will need to recreate itself
142 * from its CreateProc (returned by getFactory()). 121 * from its CreateProc (returned by getFactory()).
143 */ 122 */
144 virtual void flatten(SkWriteBuffer&) const {} 123 virtual void flatten(SkWriteBuffer&) const {}
145 124
146 protected: 125 protected:
147 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
148 static bool NeedsDeepUnflatten(const SkReadBuffer&);
149 SkFlattenable(SkReadBuffer&) {}
150 #endif
151
152 static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) { 126 static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) {
153 return NULL; 127 return NULL;
154 } 128 }
155 129
156 private: 130 private:
157 static void InitializeFlattenablesIfNeeded(); 131 static void InitializeFlattenablesIfNeeded();
158 132
159 friend class SkGraphics; 133 friend class SkGraphics;
160 134
161 typedef SkRefCnt INHERITED; 135 typedef SkRefCnt INHERITED;
162 }; 136 };
163 137
164 #endif 138 #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