aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawState.h
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-02 21:00:15 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-02 21:00:15 +0000
commit0406b9e1faee06c6ecb2732a1bcf3b0e53104e07 (patch)
tree604c310566ff6e7bacd5d8a1ddd5a836692041d6 /src/gpu/GrDrawState.h
parent5d01bec07a0740b30e4ebc51eec9057009a09bc2 (diff)
Make drawRect preserve vertex attrib state and push/pop the geom sources.
Also, add some balancing calls for setIndexSource*() Review URL: https://codereview.chromium.org/13468004 git-svn-id: http://skia.googlecode.com/svn/trunk@8499 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrDrawState.h')
-rw-r--r--src/gpu/GrDrawState.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 024dfd0327..0beebf742e 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -170,6 +170,27 @@ public:
bool validateVertexAttribs() const;
/**
+ * Helper to save/restore vertex attribs
+ */
+ class AutoVertexAttribRestore {
+ public:
+ AutoVertexAttribRestore(GrDrawState* drawState) {
+ GrAssert(NULL != drawState);
+ fDrawState = drawState;
+ fVertexAttribs = drawState->fCommon.fVertexAttribs;
+ fDrawState->setDefaultVertexAttribs();
+ }
+
+ ~AutoVertexAttribRestore(){
+ fDrawState->fCommon.fVertexAttribs = fVertexAttribs;
+ }
+
+ private:
+ GrDrawState* fDrawState;
+ GrVertexAttribArray<kMaxVertexAttribCnt> fVertexAttribs;
+ };
+
+ /**
* Accessing positions, local coords, or colors, of a vertex within an array is a hassle
* involving casts and simple math. These helpers exist to keep GrDrawTarget clients' code a bit
* nicer looking.