Store vertex size in DrawState when setVertexAttribs is called
This will avoid recalculating vertex size throughout code, and will allow
for a set original vertex size once optimizations start removing VA's
BUG=skia:
R=bsalomon@google.com
Author: egdaniel@google.com
Review URL: https://codereview.chromium.org/498483002
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index ba5d628..de97f68 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -53,6 +53,7 @@
}
}
+ SkASSERT(a.fVertexSize == b.fVertexSize);
SkASSERT(0 == memcmp(a.fFixedFunctionVertexAttribIndices,
b.fFixedFunctionVertexAttribIndices,
sizeof(a.fFixedFunctionVertexAttribIndices)));
@@ -112,6 +113,7 @@
fFlagBits = that.fFlagBits;
fVACount = that.fVACount;
fVAPtr = that.fVAPtr;
+ fVertexSize = that.fVertexSize;
fStencilSettings = that.fStencilSettings;
fCoverage = that.fCoverage;
fDrawFace = that.fDrawFace;
@@ -236,7 +238,7 @@
}
size_t GrDrawState::getVertexSize() const {
- return vertex_size(fVAPtr, fVACount);
+ return fVertexSize;
}
////////////////////////////////////////////////////////////////////////////////
@@ -246,6 +248,7 @@
fVAPtr = attribs;
fVACount = count;
+ fVertexSize = vertex_size(fVAPtr, fVACount);
// Set all the indices to -1
memset(fFixedFunctionVertexAttribIndices,
@@ -283,6 +286,7 @@
fVAPtr = &kPositionAttrib;
fVACount = 1;
+ fVertexSize = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType);
// set all the fixed function indices to -1 except position.
memset(fFixedFunctionVertexAttribIndices,