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

Side by Side Diff: src/gpu/GrDrawState.h

Issue 23703010: Replace uses of GR_DEBUGCODE by SkDEBUGCODE. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawState.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 2011 Google Inc. 2 * Copyright 2011 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 GrDrawState_DEFINED 8 #ifndef GrDrawState_DEFINED
9 #define GrDrawState_DEFINED 9 #define GrDrawState_DEFINED
10 10
(...skipping 12 matching lines...) Expand all
23 #include "effects/GrSimpleTextureEffect.h" 23 #include "effects/GrSimpleTextureEffect.h"
24 24
25 #include "SkMatrix.h" 25 #include "SkMatrix.h"
26 #include "SkXfermode.h" 26 #include "SkXfermode.h"
27 27
28 class GrDrawState : public GrRefCnt { 28 class GrDrawState : public GrRefCnt {
29 public: 29 public:
30 SK_DECLARE_INST_COUNT(GrDrawState) 30 SK_DECLARE_INST_COUNT(GrDrawState)
31 31
32 GrDrawState() { 32 GrDrawState() {
33 GR_DEBUGCODE(fBlockEffectRemovalCnt = 0;) 33 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
34 this->reset(); 34 this->reset();
35 } 35 }
36 36
37 GrDrawState(const SkMatrix& initialViewMatrix) { 37 GrDrawState(const SkMatrix& initialViewMatrix) {
38 GR_DEBUGCODE(fBlockEffectRemovalCnt = 0;) 38 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
39 this->reset(initialViewMatrix); 39 this->reset(initialViewMatrix);
40 } 40 }
41 41
42 /** 42 /**
43 * Copies another draw state. 43 * Copies another draw state.
44 **/ 44 **/
45 GrDrawState(const GrDrawState& state) : INHERITED() { 45 GrDrawState(const GrDrawState& state) : INHERITED() {
46 GR_DEBUGCODE(fBlockEffectRemovalCnt = 0;) 46 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
47 *this = state; 47 *this = state;
48 } 48 }
49 49
50 /** 50 /**
51 * Copies another draw state with a preconcat to the view matrix. 51 * Copies another draw state with a preconcat to the view matrix.
52 **/ 52 **/
53 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix) { 53 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix) {
54 GR_DEBUGCODE(fBlockEffectRemovalCnt = 0;) 54 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
55 *this = state; 55 *this = state;
56 if (!preConcatMatrix.isIdentity()) { 56 if (!preConcatMatrix.isIdentity()) {
57 for (int i = 0; i < fColorStages.count(); ++i) { 57 for (int i = 0; i < fColorStages.count(); ++i) {
58 fColorStages[i].localCoordChange(preConcatMatrix); 58 fColorStages[i].localCoordChange(preConcatMatrix);
59 } 59 }
60 for (int i = 0; i < fCoverageStages.count(); ++i) { 60 for (int i = 0; i < fCoverageStages.count(); ++i) {
61 fCoverageStages[i].localCoordChange(preConcatMatrix); 61 fCoverageStages[i].localCoordChange(preConcatMatrix);
62 } 62 }
63 } 63 }
64 } 64 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 ~AutoRestoreEffects() { this->set(NULL); } 412 ~AutoRestoreEffects() { this->set(NULL); }
413 413
414 void set(GrDrawState* ds) { 414 void set(GrDrawState* ds) {
415 if (NULL != fDrawState) { 415 if (NULL != fDrawState) {
416 int n = fDrawState->fColorStages.count() - fColorEffectCnt; 416 int n = fDrawState->fColorStages.count() - fColorEffectCnt;
417 SkASSERT(n >= 0); 417 SkASSERT(n >= 0);
418 fDrawState->fColorStages.pop_back_n(n); 418 fDrawState->fColorStages.pop_back_n(n);
419 n = fDrawState->fCoverageStages.count() - fCoverageEffectCnt; 419 n = fDrawState->fCoverageStages.count() - fCoverageEffectCnt;
420 SkASSERT(n >= 0); 420 SkASSERT(n >= 0);
421 fDrawState->fCoverageStages.pop_back_n(n); 421 fDrawState->fCoverageStages.pop_back_n(n);
422 GR_DEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) 422 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;)
423 } 423 }
424 fDrawState = ds; 424 fDrawState = ds;
425 if (NULL != ds) { 425 if (NULL != ds) {
426 fColorEffectCnt = ds->fColorStages.count(); 426 fColorEffectCnt = ds->fColorStages.count();
427 fCoverageEffectCnt = ds->fCoverageStages.count(); 427 fCoverageEffectCnt = ds->fCoverageStages.count();
428 GR_DEBUGCODE(++ds->fBlockEffectRemovalCnt;) 428 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;)
429 } 429 }
430 } 430 }
431 431
432 private: 432 private:
433 GrDrawState* fDrawState; 433 GrDrawState* fDrawState;
434 int fColorEffectCnt; 434 int fColorEffectCnt;
435 int fCoverageEffectCnt; 435 int fCoverageEffectCnt;
436 }; 436 };
437 437
438 int numColorStages() const { return fColorStages.count(); } 438 int numColorStages() const { return fColorStages.count(); }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 public: 974 public:
975 /** 975 /**
976 * DeferredState contains all of the data of a GrDrawState but does not hold refs on GrResource 976 * DeferredState contains all of the data of a GrDrawState but does not hold refs on GrResource
977 * objects. Resources are allowed to hit zero ref count while in DeferredSta tes. Their internal 977 * objects. Resources are allowed to hit zero ref count while in DeferredSta tes. Their internal
978 * dispose mechanism returns them to the cache. This allows recycling resour ces through the 978 * dispose mechanism returns them to the cache. This allows recycling resour ces through the
979 * the cache while they are in a deferred draw queue. 979 * the cache while they are in a deferred draw queue.
980 */ 980 */
981 class DeferredState { 981 class DeferredState {
982 public: 982 public:
983 DeferredState() : fRenderTarget(NULL) { 983 DeferredState() : fRenderTarget(NULL) {
984 GR_DEBUGCODE(fInitialized = false;) 984 SkDEBUGCODE(fInitialized = false;)
985 } 985 }
986 // TODO: Remove this when DeferredState no longer holds a ref to the RT 986 // TODO: Remove this when DeferredState no longer holds a ref to the RT
987 ~DeferredState() { SkSafeUnref(fRenderTarget); } 987 ~DeferredState() { SkSafeUnref(fRenderTarget); }
988 988
989 void saveFrom(const GrDrawState& drawState) { 989 void saveFrom(const GrDrawState& drawState) {
990 fCommon = drawState.fCommon; 990 fCommon = drawState.fCommon;
991 // TODO: Here we will copy the GrRenderTarget pointer without taking a ref. 991 // TODO: Here we will copy the GrRenderTarget pointer without taking a ref.
992 fRenderTarget = drawState.fRenderTarget.get(); 992 fRenderTarget = drawState.fRenderTarget.get();
993 SkSafeRef(fRenderTarget); 993 SkSafeRef(fRenderTarget);
994 // Here we ref the effects directly rather than the effect-refs. TOD O: When the effect- 994 // Here we ref the effects directly rather than the effect-refs. TOD O: When the effect-
995 // ref gets fully unref'ed it will cause the underlying effect to un ref its resources 995 // ref gets fully unref'ed it will cause the underlying effect to un ref its resources
996 // and recycle them to the cache (if no one else is holding a ref to the resources). 996 // and recycle them to the cache (if no one else is holding a ref to the resources).
997 fStages.reset(drawState.fColorStages.count() + drawState.fCoverageSt ages.count()); 997 fStages.reset(drawState.fColorStages.count() + drawState.fCoverageSt ages.count());
998 fColorStageCnt = drawState.fColorStages.count(); 998 fColorStageCnt = drawState.fColorStages.count();
999 for (int i = 0; i < fColorStageCnt; ++i) { 999 for (int i = 0; i < fColorStageCnt; ++i) {
1000 fStages[i].saveFrom(drawState.fColorStages[i]); 1000 fStages[i].saveFrom(drawState.fColorStages[i]);
1001 } 1001 }
1002 for (int i = 0; i < drawState.fCoverageStages.count(); ++i) { 1002 for (int i = 0; i < drawState.fCoverageStages.count(); ++i) {
1003 fStages[i + fColorStageCnt].saveFrom(drawState.fCoverageStages[i ]); 1003 fStages[i + fColorStageCnt].saveFrom(drawState.fCoverageStages[i ]);
1004 } 1004 }
1005 GR_DEBUGCODE(fInitialized = true;) 1005 SkDEBUGCODE(fInitialized = true;)
1006 } 1006 }
1007 1007
1008 void restoreTo(GrDrawState* drawState) { 1008 void restoreTo(GrDrawState* drawState) {
1009 SkASSERT(fInitialized); 1009 SkASSERT(fInitialized);
1010 drawState->fCommon = fCommon; 1010 drawState->fCommon = fCommon;
1011 drawState->setRenderTarget(fRenderTarget); 1011 drawState->setRenderTarget(fRenderTarget);
1012 // reinflate color/cov stage arrays. 1012 // reinflate color/cov stage arrays.
1013 drawState->fColorStages.reset(); 1013 drawState->fColorStages.reset();
1014 for (int i = 0; i < fColorStageCnt; ++i) { 1014 for (int i = 0; i < fColorStageCnt; ++i) {
1015 SkNEW_APPEND_TO_TARRAY(&drawState->fColorStages, GrEffectStage, (fStages[i])); 1015 SkNEW_APPEND_TO_TARRAY(&drawState->fColorStages, GrEffectStage, (fStages[i]));
(...skipping 30 matching lines...) Expand all
1046 } 1046 }
1047 1047
1048 private: 1048 private:
1049 typedef SkAutoSTArray<8, GrEffectStage::DeferredStage> DeferredStageArra y; 1049 typedef SkAutoSTArray<8, GrEffectStage::DeferredStage> DeferredStageArra y;
1050 1050
1051 GrRenderTarget* fRenderTarget; 1051 GrRenderTarget* fRenderTarget;
1052 CommonState fCommon; 1052 CommonState fCommon;
1053 int fColorStageCnt; 1053 int fColorStageCnt;
1054 DeferredStageArray fStages; 1054 DeferredStageArray fStages;
1055 1055
1056 GR_DEBUGCODE(bool fInitialized;) 1056 SkDEBUGCODE(bool fInitialized;)
1057 }; 1057 };
1058 1058
1059 private: 1059 private:
1060 1060
1061 SkAutoTUnref<GrRenderTarget> fRenderTarget; 1061 SkAutoTUnref<GrRenderTarget> fRenderTarget;
1062 CommonState fCommon; 1062 CommonState fCommon;
1063 1063
1064 typedef SkSTArray<4, GrEffectStage> EffectStageArray; 1064 typedef SkSTArray<4, GrEffectStage> EffectStageArray;
1065 EffectStageArray fColorStages; 1065 EffectStageArray fColorStages;
1066 EffectStageArray fCoverageStages; 1066 EffectStageArray fCoverageStages;
1067 1067
1068 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 1068 // Some of the auto restore objects assume that no effects are removed durin g their lifetime.
1069 // This is used to assert that this condition holds. 1069 // This is used to assert that this condition holds.
1070 GR_DEBUGCODE(int fBlockEffectRemovalCnt;) 1070 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
1071 1071
1072 /** 1072 /**
1073 * Sets vertex attributes for next draw. 1073 * Sets vertex attributes for next draw.
1074 * 1074 *
1075 * @param attribs the array of vertex attributes to set. 1075 * @param attribs the array of vertex attributes to set.
1076 * @param count the number of attributes being set, limited to kMaxVer texAttribCnt. 1076 * @param count the number of attributes being set, limited to kMaxVer texAttribCnt.
1077 */ 1077 */
1078 void setVertexAttribs(const GrVertexAttrib attribs[], int count); 1078 void setVertexAttribs(const GrVertexAttrib attribs[], int count);
1079 1079
1080 typedef GrRefCnt INHERITED; 1080 typedef GrRefCnt INHERITED;
1081 }; 1081 };
1082 1082
1083 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); 1083 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);
1084 1084
1085 #endif 1085 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698