releaseTextures portion of GrDrawState Ref textures CL (http://codereview.appspot.com/6251049/)
http://codereview.appspot.com/6299081/
git-svn-id: http://skia.googlecode.com/svn/trunk@4254 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 55bd04c..e77b63a 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -205,6 +205,27 @@
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;
+ };
+
/// @}
///////////////////////////////////////////////////////////////////////////