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/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index ca7ca10..ba5ea4e 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -231,15 +231,26 @@
     GrResourceEntry* findAndLock(const GrResourceKey&, LockType style);
 
     /**
-     *  Create a new entry, based on the specified key and resource, and return
-     *  its "locked" entry.
+     *  Create a new cache entry, based on the provided key and resource, and 
+     *  return it.
      *
-     *  Ownership of the resource is transferred to the Entry, which will
-     *  unref() it when we are purged or deleted.
+     *  Ownership of the resource is transferred to the resource cache, 
+     *  which will unref() it when it is purged or deleted.
      */
     GrResourceEntry* createAndLock(const GrResourceKey&, GrResource*);
 
     /**
+     *  Create a new cache entry, based on the provided key and resource.
+     *
+     *  Ownership of the resource is transferred to the resource cache, 
+     *  which will unref() it when it is purged or deleted.
+     *
+     *  Currently this entry point is only intended for textures "detached"
+     *  from an AutoScratchTexture object.
+     */
+    void attach(const GrResourceKey& key, GrResource* resource);
+
+    /**
      * Determines if the cache contains an entry matching a key. If a matching
      * entry exists but was detached then it will not be found.
      */
@@ -253,6 +264,8 @@
      */
     void detach(GrResourceEntry*);
 
+    void freeEntry(GrResourceEntry* entry);
+
     /**
      * Reattaches a resource to the cache and unlocks it. Allows it to be found
      * by a subsequent findAndLock or be purged (provided its lock count is
@@ -298,6 +311,11 @@
     
     // prevents recursive purging
     bool fPurging;
+
+    GrResourceEntry* create(const GrResourceKey& key,
+                            GrResource* resource,
+                            bool lock);
+
 };
 
 ///////////////////////////////////////////////////////////////////////////////