Added find, lock to GrContext & GrResourceCache interfaces

https://codereview.appspot.com/6499052/



git-svn-id: http://skia.googlecode.com/svn/trunk@5343 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 777470b..ca69ce4 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -184,6 +184,17 @@
     }
 }
 
+GrResource* GrResourceCache::find(const GrResourceKey& key) {
+    GrAutoResourceCacheValidate atcv(this);
+
+    GrResourceEntry* entry = fCache.find(key);
+    if (NULL == entry) {
+        return NULL;
+    }
+
+    return entry->fResource;
+}
+
 GrResource* GrResourceCache::findAndLock(const GrResourceKey& key,
                                          LockType type) {
     GrAutoResourceCacheValidate atcv(this);
@@ -256,7 +267,7 @@
     GrAutoResourceCacheValidate atcv(this);
 
     this->internalDetach(entry, true);
-    fCache.remove(entry->fKey, entry);
+    fCache.remove(entry->key(), entry);
 
 #if GR_DEBUG
     fExclusiveList.addToHead(entry);
@@ -291,6 +302,19 @@
     }
 }
 
+void GrResourceCache::lock(GrResourceEntry* entry) {
+    GrAutoResourceCacheValidate atcv(this);
+
+    GrAssert(entry);
+    GrAssert(fCache.find(entry->key()));
+
+    if (!entry->isLocked()) {
+        --fUnlockedEntryCount;
+    }
+
+    entry->lock();
+}
+
 void GrResourceCache::unlock(GrResourceEntry* entry) {
     GrAutoResourceCacheValidate atcv(this);
 
@@ -343,7 +367,7 @@
                 GrResourceEntry* prev = iter.prev();
                 if (!entry->isLocked()) {
                     // remove from our cache
-                    fCache.remove(entry->fKey, entry);
+                    fCache.remove(entry->key(), entry);
 
                     // remove from our llist
                     this->internalDetach(entry, false);