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

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

Issue 22850006: Replace uses of GrAssert by SkASSERT. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « include/gpu/GrDrawEffect.h ('k') | include/gpu/GrEffectStage.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 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 int numVertexAttribs() const { return fVertexAttribTypes.count(); } 161 int numVertexAttribs() const { return fVertexAttribTypes.count(); }
162 162
163 GrSLType vertexAttribType(int index) const { return fVertexAttribTypes[index ]; } 163 GrSLType vertexAttribType(int index) const { return fVertexAttribTypes[index ]; }
164 164
165 static const int kMaxVertexAttribs = 2; 165 static const int kMaxVertexAttribs = 2;
166 166
167 /** Useful for effects that want to insert a texture matrix that is implied by the texture 167 /** Useful for effects that want to insert a texture matrix that is implied by the texture
168 dimensions */ 168 dimensions */
169 static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) { 169 static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
170 GrAssert(NULL != texture); 170 SkASSERT(NULL != texture);
171 SkMatrix mat; 171 SkMatrix mat;
172 mat.setIDiv(texture->width(), texture->height()); 172 mat.setIDiv(texture->width(), texture->height());
173 return mat; 173 return mat;
174 } 174 }
175 175
176 void* operator new(size_t size); 176 void* operator new(size_t size);
177 void operator delete(void* target); 177 void operator delete(void* target);
178 178
179 void* operator new(size_t size, void* placement) { 179 void* operator new(size_t size, void* placement) {
180 return ::operator new(size, placement); 180 return ::operator new(size, placement);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 return effect->fEffectRef; 229 return effect->fEffectRef;
230 } 230 }
231 231
232 static const GrEffectRef* CreateEffectRef(const GrEffect* effect) { 232 static const GrEffectRef* CreateEffectRef(const GrEffect* effect) {
233 return CreateEffectRef(const_cast<GrEffect*>(effect)); 233 return CreateEffectRef(const_cast<GrEffect*>(effect));
234 } 234 }
235 235
236 /** Used by GR_CREATE_STATIC_EFFECT below */ 236 /** Used by GR_CREATE_STATIC_EFFECT below */
237 static GrEffectRef* CreateStaticEffectRef(void* refStorage, GrEffect* effect ) { 237 static GrEffectRef* CreateStaticEffectRef(void* refStorage, GrEffect* effect ) {
238 GrAssert(NULL == effect->fEffectRef); 238 SkASSERT(NULL == effect->fEffectRef);
239 effect->fEffectRef = SkNEW_PLACEMENT_ARGS(refStorage, GrEffectRef, (effe ct)); 239 effect->fEffectRef = SkNEW_PLACEMENT_ARGS(refStorage, GrEffectRef, (effe ct));
240 return effect->fEffectRef; 240 return effect->fEffectRef;
241 } 241 }
242 242
243 243
244 /** Helper used in subclass factory functions to unref the effect after it h as been wrapped in a 244 /** Helper used in subclass factory functions to unref the effect after it h as been wrapped in a
245 GrEffectRef. E.g.: 245 GrEffectRef. E.g.:
246 246
247 class EffectSubclass : public GrEffect { 247 class EffectSubclass : public GrEffect {
248 public: 248 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } 282 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
283 283
284 private: 284 private:
285 bool isEqual(const GrEffect& other) const { 285 bool isEqual(const GrEffect& other) const {
286 if (&this->getFactory() != &other.getFactory()) { 286 if (&this->getFactory() != &other.getFactory()) {
287 return false; 287 return false;
288 } 288 }
289 bool result = this->onIsEqual(other); 289 bool result = this->onIsEqual(other);
290 #if GR_DEBUG 290 #if GR_DEBUG
291 if (result) { 291 if (result) {
292 GrAssert(this->numTextures() == other.numTextures()); 292 SkASSERT(this->numTextures() == other.numTextures());
293 for (int i = 0; i < this->numTextures(); ++i) { 293 for (int i = 0; i < this->numTextures(); ++i) {
294 GrAssert(*fTextureAccesses[i] == *other.fTextureAccesses[i]); 294 SkASSERT(*fTextureAccesses[i] == *other.fTextureAccesses[i]);
295 } 295 }
296 } 296 }
297 #endif 297 #endif
298 return result; 298 return result;
299 } 299 }
300 300
301 /** Subclass implements this to support isEqual(). It will only be called if it is known that 301 /** Subclass implements this to support isEqual(). It will only be called if it is known that
302 the two effects are of the same subclass (i.e. they return the same obje ct from 302 the two effects are of the same subclass (i.e. they return the same obje ct from
303 getFactory()).*/ 303 getFactory()).*/
304 virtual bool onIsEqual(const GrEffect& other) const = 0; 304 virtual bool onIsEqual(const GrEffect& other) const = 0;
305 305
306 void EffectRefDestroyed() { fEffectRef = NULL; } 306 void EffectRefDestroyed() { fEffectRef = NULL; }
307 307
308 friend class GrEffectRef; // to call EffectRefDestroyed() 308 friend class GrEffectRef; // to call EffectRefDestroyed()
309 friend class GrEffectStage; // to rewrap GrEffect in GrEffectRef when restor ing an effect-stage 309 friend class GrEffectStage; // to rewrap GrEffect in GrEffectRef when restor ing an effect-stage
310 // from deferred state, to call isEqual on naked GrEffects, and 310 // from deferred state, to call isEqual on naked GrEffects, and
311 // to inc/dec deferred ref counts. 311 // to inc/dec deferred ref counts.
312 312
313 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; 313 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
314 SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes; 314 SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes;
315 bool fWillReadDstColor; 315 bool fWillReadDstColor;
316 bool fWillReadFragmentPosition; 316 bool fWillReadFragmentPosition;
317 GrEffectRef* fEffectRef; 317 GrEffectRef* fEffectRef;
318 318
319 typedef GrRefCnt INHERITED; 319 typedef GrRefCnt INHERITED;
320 }; 320 };
321 321
322 inline GrEffectRef::GrEffectRef(GrEffect* effect) { 322 inline GrEffectRef::GrEffectRef(GrEffect* effect) {
323 GrAssert(NULL != effect); 323 SkASSERT(NULL != effect);
324 effect->ref(); 324 effect->ref();
325 fEffect = effect; 325 fEffect = effect;
326 } 326 }
327 327
328 /** 328 /**
329 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called 329 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called
330 * at global destruction time. NAME will be the name of the created GrEffectRef. 330 * at global destruction time. NAME will be the name of the created GrEffectRef.
331 */ 331 */
332 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS) \ 332 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS) \
333 enum { \ 333 enum { \
334 k_##NAME##_EffectRefOffset = GR_CT_ALIGN_UP(sizeof(EFFECT_CLASS), 8), \ 334 k_##NAME##_EffectRefOffset = GR_CT_ALIGN_UP(sizeof(EFFECT_CLASS), 8), \
335 k_##NAME##_StorageSize = k_##NAME##_EffectRefOffset + sizeof(GrEffectRef) \ 335 k_##NAME##_StorageSize = k_##NAME##_EffectRefOffset + sizeof(GrEffectRef) \
336 }; \ 336 }; \
337 static SkAlignedSStorage<k_##NAME##_StorageSize> g_##NAME##_Storage; \ 337 static SkAlignedSStorage<k_##NAME##_StorageSize> g_##NAME##_Storage; \
338 static void* NAME##_RefLocation = (char*)g_##NAME##_Storage.get() + k_##NAME##_E ffectRefOffset; \ 338 static void* NAME##_RefLocation = (char*)g_##NAME##_Storage.get() + k_##NAME##_E ffectRefOffset; \
339 static GrEffect* NAME##_Effect SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EF FECT_CLASS, ARGS);\ 339 static GrEffect* NAME##_Effect SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EF FECT_CLASS, ARGS);\
340 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME##_Effect); \ 340 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME##_Effect); \
341 static GrEffectRef* NAME(GrEffect::CreateStaticEffectRef(NAME##_RefLocation, NAM E##_Effect)); \ 341 static GrEffectRef* NAME(GrEffect::CreateStaticEffectRef(NAME##_RefLocation, NAM E##_Effect)); \
342 static SkAutoTDestroy<GrEffectRef> NAME##_Ref_ad(NAME) 342 static SkAutoTDestroy<GrEffectRef> NAME##_Ref_ad(NAME)
343 343
344 344
345 #endif 345 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrDrawEffect.h ('k') | include/gpu/GrEffectStage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698