Use a single stencil buffer for a given width,height,samplecount

Review URL: http://codereview.appspot.com/4854044/


git-svn-id: http://skia.googlecode.com/svn/trunk@2061 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrResourceCache.cpp b/gpu/src/GrResourceCache.cpp
index 2f5dfaf..97cbea8 100644
--- a/gpu/src/GrResourceCache.cpp
+++ b/gpu/src/GrResourceCache.cpp
@@ -155,7 +155,8 @@
 #endif
 };
 
-GrResourceEntry* GrResourceCache::findAndLock(const GrResourceKey& key) {
+GrResourceEntry* GrResourceCache::findAndLock(const GrResourceKey& key,
+                                              LockType type) {
     GrAutoResourceCacheValidate atcv(this);
 
     GrResourceEntry* entry = fCache.find(key);
@@ -163,7 +164,9 @@
         this->internalDetach(entry, false);
         // mark the entry as "busy" so it doesn't get purged
         // do this between detach and attach for locked count tracking
-        entry->lock();
+        if (kNested_LockType == type || !entry->isLocked()) {
+            entry->lock();
+        }
         this->attachToHead(entry, false);
     }
     return entry;