aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceCache.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-30 11:06:31 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-30 11:06:31 +0000
commita9b0623eac4a473517c15418dbdc1e331ee752d2 (patch)
treef31354f880f7113eddfb28a301dc53d687b15d8c /src/gpu/GrResourceCache.cpp
parent9cb5adf50dc3e8f83904380934b08d135229ef6f (diff)
Added find, lock to GrContext & GrResourceCache interfaces
Diffstat (limited to 'src/gpu/GrResourceCache.cpp')
-rw-r--r--src/gpu/GrResourceCache.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 777470b00d..ca69ce44ce 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -184,6 +184,17 @@ void GrResourceCache::attachToHead(GrResourceEntry* entry,
}
}
+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 @@ void GrResourceCache::makeExclusive(GrResourceEntry* entry) {
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::makeNonExclusive(GrResourceEntry* entry) {
}
}
+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 @@ void GrResourceCache::purgeAsNeeded() {
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);