Enable Scratch texture detach in SW path renderer's onDrawPath (take 2)

http://codereview.appspot.com/6331057/



git-svn-id: http://skia.googlecode.com/svn/trunk@4324 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index bfad6df..5e4f6f1 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -336,11 +336,7 @@
     if (sw_draw_path_to_mask_texture(path, pathBounds,
                                      fill, fContext,
                                      translate, &ast, antiAlias)) {
-#if 1
-        GrTexture* texture = ast.texture();
-#else
         SkAutoTUnref<GrTexture> texture(ast.detach());
-#endif
         GrAssert(NULL != texture);
         GrDrawTarget::AutoDeviceCoordDraw adcd(target, stageMask);
         enum {
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 19dc322..8c12bd2 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -30,10 +30,8 @@
         nonConstThis->resetFlag((GrTextureFlags) kReturnToCache_FlagBit);
         nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonConstThis);
 
-        // Note: this next assert is only correct for the texture cache's
-        // current single threaded usage. If we ever start accessing it via 
-        // threads it isn't guaranteed to be correct.
-        GrAssert(1 == this->INHERITED::getRefCnt());
+        // Note: "this" texture might be freed inside addExistingTextureToCache 
+        // if it is purged.
         return;
     }