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-16 14:49:16 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-16 14:49:16 +0000
commit1f47f4f7325971dd53991e2bb02da94fa7c6d962 (patch)
treea5b5dc02a15a3f3d4edeb921bda4ea1895f4ce77 /src/gpu/GrResourceCache.cpp
parent71329d809a42889af8d2cadc4e43c60488a739a1 (diff)
Replaced TextureCacheEntry with GrTexture* and a back pointer to GrResourceEntry (in GrTexture)
Diffstat (limited to 'src/gpu/GrResourceCache.cpp')
-rw-r--r--src/gpu/GrResourceCache.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index b82cdb2d4b..982d45e3dd 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -28,6 +28,7 @@ GrResourceEntry::~GrResourceEntry() {
void GrResourceEntry::validate() const {
GrAssert(fLockCount >= 0);
GrAssert(fResource);
+ GrAssert(fResource->getCacheEntry() == this);
fResource->validate();
}
#endif
@@ -158,21 +159,24 @@ public:
#endif
};
-GrResourceEntry* GrResourceCache::findAndLock(const GrResourceKey& key,
- LockType type) {
+GrResource* GrResourceCache::findAndLock(const GrResourceKey& key,
+ LockType type) {
GrAutoResourceCacheValidate atcv(this);
GrResourceEntry* entry = fCache.find(key);
- if (entry) {
- 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
- if (kNested_LockType == type || !entry->isLocked()) {
- entry->lock();
- }
- this->attachToHead(entry, false);
+ if (NULL == entry) {
+ return NULL;
}
- return entry;
+
+ 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
+ if (kNested_LockType == type || !entry->isLocked()) {
+ entry->lock();
+ }
+ this->attachToHead(entry, false);
+
+ return entry->fResource;
}
bool GrResourceCache::hasKey(const GrResourceKey& key) const {
@@ -192,6 +196,8 @@ GrResourceEntry* GrResourceCache::create(const GrResourceKey& key,
GrResourceEntry* entry = SkNEW_ARGS(GrResourceEntry, (key, resource));
+ resource->setCacheEntry(entry);
+
if (lock) {
// mark the entry as "busy" so it doesn't get purged
// do this before attach for locked count tracking
@@ -210,13 +216,15 @@ GrResourceEntry* GrResourceCache::create(const GrResourceKey& key,
return entry;
}
-GrResourceEntry* GrResourceCache::createAndLock(const GrResourceKey& key,
- GrResource* resource) {
- return this->create(key, resource, true, false);
+void GrResourceCache::createAndLock(const GrResourceKey& key,
+ GrResource* resource) {
+ GrAssert(NULL == resource->getCacheEntry());
+ this->create(key, resource, true, false);
}
void GrResourceCache::attach(const GrResourceKey& key,
GrResource* resource) {
+ GrAssert(NULL == resource->getCacheEntry());
this->create(key, resource, false, true);
}