OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
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 GrEffect_DEFINED | 8 #ifndef GrEffect_DEFINED |
9 #define GrEffect_DEFINED | 9 #define GrEffect_DEFINED |
10 | 10 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 * called from the constructor because GrEffects are immutable. | 162 * called from the constructor because GrEffects are immutable. |
163 */ | 163 */ |
164 void addTextureAccess(const GrTextureAccess* textureAccess); | 164 void addTextureAccess(const GrTextureAccess* textureAccess); |
165 | 165 |
166 GrEffect() | 166 GrEffect() |
167 : fWillReadDstColor(false) | 167 : fWillReadDstColor(false) |
168 , fWillReadFragmentPosition(false) | 168 , fWillReadFragmentPosition(false) |
169 , fWillUseInputColor(true) | 169 , fWillUseInputColor(true) |
170 , fHasVertexCode(false) {} | 170 , fHasVertexCode(false) {} |
171 | 171 |
172 /** This should be called by GrEffect subclass factories. See the comment on
AutoEffectUnref for | 172 /** Helper for down-casting to a GrEffect subclass |
173 an example factory function. */ | |
174 static GrEffect* CreateEffectRef(GrEffect* effect) { | |
175 return SkRef(effect); | |
176 } | |
177 | |
178 static const GrEffect* CreateEffectRef(const GrEffect* effect) { | |
179 return CreateEffectRef(const_cast<GrEffect*>(effect)); | |
180 } | |
181 | |
182 /** Helper used in subclass factory functions to unref the effect after it h
as been wrapped in a | |
183 GrEffectRef. E.g.: | |
184 | |
185 class EffectSubclass : public GrEffect { | |
186 public: | |
187 GrEffectRef* Create(ParamType1 param1, ParamType2 param2, ...) { | |
188 AutoEffectUnref effect(SkNEW_ARGS(EffectSubclass, (param1, param
2, ...))); | |
189 return CreateEffectRef(effect); | |
190 } | |
191 */ | |
192 typedef SkAutoTUnref<GrEffect> AutoEffectUnref; | |
193 | |
194 /** Helper for getting the GrEffect out of a GrEffectRef and down-casting to
a GrEffect subclass | |
195 */ | 173 */ |
196 template <typename T> | 174 template <typename T> |
197 static const T& CastEffect(const GrEffect& effectRef) { | 175 static const T& CastEffect(const GrEffect& effectRef) { |
198 return *static_cast<const T*>(&effectRef); | 176 return *static_cast<const T*>(&effectRef); |
199 } | 177 } |
200 | 178 |
201 /** | 179 /** |
202 * If the effect subclass will read the destination pixel value then it must
call this function | 180 * If the effect subclass will read the destination pixel value then it must
call this function |
203 * from its constructor. Otherwise, when its generated backend-specific effe
ct class attempts | 181 * from its constructor. Otherwise, when its generated backend-specific effe
ct class attempts |
204 * to generate code that reads the destination pixel it will fail. | 182 * to generate code that reads the destination pixel it will fail. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 * This creates an effect outside of the effect memory pool. The effect's destru
ctor will be called | 224 * This creates an effect outside of the effect memory pool. The effect's destru
ctor will be called |
247 * at global destruction time. NAME will be the name of the created GrEffect. | 225 * at global destruction time. NAME will be the name of the created GrEffect. |
248 */ | 226 */ |
249 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS)
\ | 227 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS)
\ |
250 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage;
\ | 228 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage;
\ |
251 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS
S, ARGS); \ | 229 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS
S, ARGS); \ |
252 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME); | 230 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME); |
253 | 231 |
254 | 232 |
255 #endif | 233 #endif |
OLD | NEW |