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

Unified Diff: src/gpu/GrDrawState.h

Issue 14328009: Vertex Attrib configurations now handled as pointers vs. SkSTArrays (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added "extern const" & removed comment Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.h
===================================================================
--- src/gpu/GrDrawState.h (revision 8777)
+++ src/gpu/GrDrawState.h (working copy)
@@ -120,15 +120,15 @@
*/
/**
- * Sets vertex attributes for next draw.
- *
- * @param attribs the array of vertex attributes to set.
- * @param count the number of attributes being set, limited to kMaxVertexAttribCnt.
+ * Sets vertex attributes for next draw. The object driving the templatization
+ * should be a global GrVertexAttrib array that is never changed.
*/
- void setVertexAttribs(const GrVertexAttrib attribs[], int count);
+ template <const GrVertexAttrib A[]> void setVertexAttribs(int count) {
+ this->setVertexAttribs(A, count);
+ }
- const GrVertexAttrib* getVertexAttribs() const { return fCommon.fVertexAttribs.begin(); }
- int getVertexAttribCount() const { return fCommon.fVertexAttribs.count(); }
+ const GrVertexAttrib* getVertexAttribs() const { return fCommon.fVAPtr; }
+ int getVertexAttribCount() const { return fCommon.fVACount; }
size_t getVertexSize() const;
@@ -177,17 +177,20 @@
AutoVertexAttribRestore(GrDrawState* drawState) {
GrAssert(NULL != drawState);
fDrawState = drawState;
- fVertexAttribs = drawState->fCommon.fVertexAttribs;
+ fVAPtr = drawState->fCommon.fVAPtr;
+ fVACount = drawState->fCommon.fVACount;
fDrawState->setDefaultVertexAttribs();
}
~AutoVertexAttribRestore(){
- fDrawState->fCommon.fVertexAttribs = fVertexAttribs;
+ fDrawState->fCommon.fVAPtr = fVAPtr;
+ fDrawState->fCommon.fVACount = fVACount;
}
private:
- GrDrawState* fDrawState;
- GrVertexAttribArray<kMaxVertexAttribCnt> fVertexAttribs;
+ GrDrawState* fDrawState;
+ const GrVertexAttrib* fVAPtr;
+ int fVACount;
};
/**
@@ -1034,19 +1037,20 @@
/** Fields that are identical in GrDrawState and GrDrawState::DeferredState. */
struct CommonState {
// These fields are roughly sorted by decreasing likelihood of being different in op==
- GrColor fColor;
- SkMatrix fViewMatrix;
- GrBlendCoeff fSrcBlend;
- GrBlendCoeff fDstBlend;
- GrColor fBlendConstant;
- uint32_t fFlagBits;
- GrVertexAttribArray<kMaxVertexAttribCnt> fVertexAttribs;
- GrStencilSettings fStencilSettings;
- int fFirstCoverageStage;
- GrColor fCoverage;
- SkXfermode::Mode fColorFilterMode;
- GrColor fColorFilterColor;
- DrawFace fDrawFace;
+ GrColor fColor;
+ SkMatrix fViewMatrix;
+ GrBlendCoeff fSrcBlend;
+ GrBlendCoeff fDstBlend;
+ GrColor fBlendConstant;
+ uint32_t fFlagBits;
+ const GrVertexAttrib* fVAPtr;
+ int fVACount;
+ GrStencilSettings fStencilSettings;
+ int fFirstCoverageStage;
+ GrColor fCoverage;
+ SkXfermode::Mode fColorFilterMode;
+ GrColor fColorFilterColor;
+ DrawFace fDrawFace;
// This is simply a different representation of info in fVertexAttribs and thus does
// not need to be compared in op==.
@@ -1059,7 +1063,8 @@
fDstBlend == other.fDstBlend &&
fBlendConstant == other.fBlendConstant &&
fFlagBits == other.fFlagBits &&
- fVertexAttribs == other.fVertexAttribs &&
+ fVACount == other.fVACount &&
+ !memcmp(fVAPtr, other.fVAPtr, fVACount * sizeof(GrVertexAttrib)) &&
fStencilSettings == other.fStencilSettings &&
fFirstCoverageStage == other.fFirstCoverageStage &&
fCoverage == other.fCoverage &&
@@ -1146,6 +1151,14 @@
CommonState fCommon;
GrEffectStage fStages[kNumStages];
+ /**
+ * Sets vertex attributes for next draw.
+ *
+ * @param attribs the array of vertex attributes to set.
+ * @param count the number of attributes being set, limited to kMaxVertexAttribCnt.
+ */
+ void setVertexAttribs(const GrVertexAttrib attribs[], int count);
+
typedef GrRefCnt INHERITED;
};
« 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