AutoScratchTexture can now release its texture and it will return to the texture cache when freed

http://codereview.appspot.com/6262043/



git-svn-id: http://skia.googlecode.com/svn/trunk@4301 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 79b39ec..783a147 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -33,6 +33,29 @@
 
     // from GrResource
     /**
+     * Informational texture flags
+     */
+    enum FlagBits {
+        kFirstBit = (kLastPublic_GrTextureFlagBit << 1),
+
+        /**
+         * This texture should be returned to the texture cache when
+         * it is no longer reffed
+         */
+        kReturnToCache_FlagBit        = kFirstBit,
+    };
+
+    void setFlag(GrTextureFlags flags) {
+        fDesc.fFlags = fDesc.fFlags | flags;
+    }
+    void resetFlag(GrTextureFlags flags) {
+        fDesc.fFlags = fDesc.fFlags & ~flags;
+    }
+    bool isSetFlag(GrTextureFlags flags) const { 
+        return 0 != (fDesc.fFlags & flags); 
+    }
+
+    /**
      *  Approximate number of bytes used by the texture
      */
     virtual size_t sizeInBytes() const SK_OVERRIDE {
@@ -162,11 +185,8 @@
     }
 
     // GrResource overrides
-    virtual void onRelease() {
-        this->releaseRenderTarget();
-    }
-
-    virtual void onAbandon();
+    virtual void onRelease() SK_OVERRIDE;
+    virtual void onAbandon() SK_OVERRIDE;
 
     void validateDesc() const;
 
@@ -176,6 +196,8 @@
     int                 fShiftFixedX;
     int                 fShiftFixedY;
 
+    virtual void internal_dispose() const SK_OVERRIDE;
+
     typedef GrSurface INHERITED;
 };