aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-08-22 07:19:35 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-22 07:19:35 -0700
commitab78e06830cb70410b0e9e4f96575e137867e89f (patch)
tree96282cb9b995dcef2c9c40a34ef14fdf44cd4ab4
parent6f1cd27536fcaaef8818bb87785ed3a56a8033d6 (diff)
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
-rw-r--r--src/gpu/GrDrawState.cpp6
-rw-r--r--src/gpu/GrDrawState.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index ba5d62876c..de97f68291 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -53,6 +53,7 @@ GrDrawState::CombinedState GrDrawState::CombineIfPossible(
}
}
+ SkASSERT(a.fVertexSize == b.fVertexSize);
SkASSERT(0 == memcmp(a.fFixedFunctionVertexAttribIndices,
b.fFixedFunctionVertexAttribIndices,
sizeof(a.fFixedFunctionVertexAttribIndices)));
@@ -112,6 +113,7 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
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 @@ static size_t vertex_size(const GrVertexAttrib* attribs, int count) {
}
size_t GrDrawState::getVertexSize() const {
- return vertex_size(fVAPtr, fVACount);
+ return fVertexSize;
}
////////////////////////////////////////////////////////////////////////////////
@@ -246,6 +248,7 @@ void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) {
fVAPtr = attribs;
fVACount = count;
+ fVertexSize = vertex_size(fVAPtr, fVACount);
// Set all the indices to -1
memset(fFixedFunctionVertexAttribIndices,
@@ -283,6 +286,7 @@ void GrDrawState::setDefaultVertexAttribs() {
fVAPtr = &kPositionAttrib;
fVACount = 1;
+ fVertexSize = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType);
// set all the fixed function indices to -1 except position.
memset(fFixedFunctionVertexAttribIndices,
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index ce0a583084..cc1df05ec3 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -783,6 +783,7 @@ private:
uint32_t fFlagBits;
const GrVertexAttrib* fVAPtr;
int fVACount;
+ size_t fVertexSize;
GrStencilSettings fStencilSettings;
uint8_t fCoverage;
DrawFace fDrawFace;