Move vertex layout from GeometrySrcState to GrDrawState.
Also adds AutoStateRestore member to AutoGeometryPush to push DrawState as well
as GeometrySrcState. And removed vertex layout as an argument to a number of
functions -- they will get vertex layout info from the current DrawState.
Review URL: https://codereview.appspot.com/7286047
git-svn-id: http://skia.googlecode.com/svn/trunk@7600 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 0a0b0da..de23df7 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -84,6 +84,7 @@
fRenderTarget.reset(NULL);
fCommon.fColor = 0xffffffff;
+ fCommon.fVertexLayout = kDefault_VertexLayout;
fCommon.fViewMatrix.reset();
fCommon.fSrcBlend = kOne_GrBlendCoeff;
fCommon.fDstBlend = kZero_GrBlendCoeff;
@@ -107,7 +108,7 @@
void setFromPaint(const GrPaint& paint);
///////////////////////////////////////////////////////////////////////////
- /// @name Vertex Format
+ /// @name Vertex Layout
////
/**
@@ -179,6 +180,21 @@
// make sure we haven't exceeded the number of bits in GrVertexLayout.
GR_STATIC_ASSERT(kHighVertexLayoutBit < ((uint64_t)1 << 8*sizeof(GrVertexLayout)));
+ enum VertexLayout {
+ kDefault_VertexLayout = 0
+ };
+
+ /**
+ * Sets vertex layout for next draw.
+ *
+ * @param layout the vertex layout to set.
+ */
+ void setVertexLayout(GrVertexLayout layout) { fCommon.fVertexLayout = layout; }
+
+ GrVertexLayout getVertexLayout() const { return fCommon.fVertexLayout; }
+ size_t getVertexSize() const { return VertexSize(fCommon.fVertexLayout); }
+
+
////////////////////////////////////////////////////////////////////////////
// Helpers for picking apart vertex layouts
@@ -1161,6 +1177,7 @@
struct CommonState {
// These fields are roughly sorted by decreasing likelihood of being different in op==
GrColor fColor;
+ GrVertexLayout fVertexLayout;
SkMatrix fViewMatrix;
GrBlendCoeff fSrcBlend;
GrBlendCoeff fDstBlend;
@@ -1175,6 +1192,7 @@
DrawFace fDrawFace;
bool operator== (const CommonState& other) const {
return fColor == other.fColor &&
+ fVertexLayout == other.fVertexLayout &&
fViewMatrix.cheapEqualTo(other.fViewMatrix) &&
fSrcBlend == other.fSrcBlend &&
fDstBlend == other.fDstBlend &&