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

Unified Diff: src/gpu/GrDrawState.cpp

Issue 502533004: Revert of Make setVertexAttribs in GrDrawState take a stride parameter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.cpp
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 0c2b1c3684e295d3bb321669375a9f3d414cb4ed..a6b3d68238cdc18a20f527c9f7a3dccd5b05b8c9 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -75,7 +75,7 @@
fFlagBits = that.fFlagBits;
fVACount = that.fVACount;
fVAPtr = that.fVAPtr;
- fVAStride = that.fVAStride;
+ fVertexSize = that.fVertexSize;
fStencilSettings = that.fStencilSettings;
fCoverage = that.fCoverage;
fDrawFace = that.fDrawFace;
@@ -178,34 +178,35 @@
////////////////////////////////////////////////////////////////////////////////
-static void validate_vertex_attribs(const GrVertexAttrib* attribs, int count, size_t stride) {
+static size_t vertex_size(const GrVertexAttrib* attribs, int count) {
// this works as long as we're 4 byte-aligned
#ifdef SK_DEBUG
uint32_t overlapCheck = 0;
+#endif
SkASSERT(count <= GrRODrawState::kMaxVertexAttribCnt);
+ size_t size = 0;
for (int index = 0; index < count; ++index) {
size_t attribSize = GrVertexAttribTypeSize(attribs[index].fType);
- size_t attribOffset = attribs[index].fOffset;
- SkASSERT(attribOffset + attribSize <= stride);
+ size += attribSize;
+#ifdef SK_DEBUG
size_t dwordCount = attribSize >> 2;
uint32_t mask = (1 << dwordCount)-1;
- size_t offsetShift = attribOffset >> 2;
+ size_t offsetShift = attribs[index].fOffset >> 2;
SkASSERT(!(overlapCheck & (mask << offsetShift)));
overlapCheck |= (mask << offsetShift);
- }
#endif
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-void GrDrawState::internalSetVertexAttribs(const GrVertexAttrib* attribs, int count,
- size_t stride) {
+ }
+ return size;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) {
SkASSERT(count <= kMaxVertexAttribCnt);
fVAPtr = attribs;
fVACount = count;
- fVAStride = stride;
- validate_vertex_attribs(fVAPtr, fVACount, fVAStride);
+ fVertexSize = vertex_size(fVAPtr, fVACount);
// Set all the indices to -1
memset(fFixedFunctionVertexAttribIndices,
@@ -243,7 +244,7 @@
fVAPtr = &kPositionAttrib;
fVACount = 1;
- fVAStride = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType);
+ fVertexSize = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType);
// set all the fixed function indices to -1 except position.
memset(fFixedFunctionVertexAttribIndices,
@@ -278,7 +279,6 @@
fDrawState = drawState;
fVAPtr = drawState->fVAPtr;
fVACount = drawState->fVACount;
- fVAStride = drawState->fVAStride;
fDrawState->setDefaultVertexAttribs();
}
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698