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

Side by Side Diff: include/gpu/GrEffect.h

Issue 371103003: Remove GrEffect::CreateEffectRef and GrEffect::AutoEffectRef. (Closed) Base URL: https://skia.googlesource.com/skia.git@no_ref2
Patch Set: Address comments and update for new YUV effect Created 6 years, 5 months 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 | « no previous file | src/core/SkXfermode.cpp » ('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 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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698