aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawState.h
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-13 18:49:30 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-13 18:49:30 +0000
commit972265db219ce25b5159879c75e6c62efaf0fa79 (patch)
tree7e6315d9224f44c3a7df0f5cf941c4e4583cb69c /src/gpu/GrDrawState.h
parentfedd09ba7e218116df8a676069726de6e9d35277 (diff)
releaseTextures portion of GrDrawState Ref textures CL (http://codereview.appspot.com/6251049/)
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 55bd04c87e..e77b63ad81 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -205,6 +205,27 @@ public:
return fTextures[stage];
}
+ /**
+ * Release all the textures referred to by this draw state
+ */
+ void releaseTextures() {
+ for (int i = 0; i < kNumStages; ++i) {
+ this->setTexture(i, NULL);
+ }
+ }
+
+ class AutoTextureRelease : public ::GrNoncopyable {
+ public:
+ AutoTextureRelease(GrDrawState* ds) : fDrawState(ds) {}
+ ~AutoTextureRelease() {
+ if (NULL != fDrawState) {
+ fDrawState->releaseTextures();
+ }
+ }
+ private:
+ GrDrawState* fDrawState;
+ };
+
/// @}
///////////////////////////////////////////////////////////////////////////