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/GrContext.cpp b/src/gpu/GrContext.cpp
index 1fda26b..fc2b143 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -520,6 +520,18 @@
     return TextureCacheEntry(entry);
 }
 
+void GrContext::addExistingTextureToCache(GrTexture* texture) {
+
+    if (NULL == texture) {
+        return;
+    }
+
+    GrResourceKey key = GrTexture::ComputeKey(fGpu, NULL,
+                                              texture->desc(),
+                                              true);
+    fTextureCache->attach(key, texture);
+}
+
 void GrContext::unlockTexture(TextureCacheEntry entry) {
     ASSERT_OWNED_RESOURCE(entry.texture());
     // If this is a scratch texture we detached it from the cache
@@ -532,6 +544,12 @@
     }
 }
 
+void GrContext::freeEntry(TextureCacheEntry entry) {
+    ASSERT_OWNED_RESOURCE(entry.texture());
+
+    fTextureCache->freeEntry(entry.cacheEntry());
+}
+
 GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& descIn,
                                             void* srcData,
                                             size_t rowBytes) {