Fixed Resource counting bug in AutoScratchTexture detach mechanism
http://codereview.appspot.com/6356043/
git-svn-id: http://skia.googlecode.com/svn/trunk@4361 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 2ad5d6f..633cd23 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -181,7 +181,8 @@
GrResourceEntry* GrResourceCache::create(const GrResourceKey& key,
GrResource* resource,
- bool lock) {
+ bool lock,
+ bool clientReattach) {
// we don't expect to create new resources during a purge. In theory
// this could cause purgeAsNeeded() into an infinite loop (e.g.
// each resource destroyed creates and locks 2 resources and
@@ -197,7 +198,7 @@
entry->lock();
}
- this->attachToHead(entry, false);
+ this->attachToHead(entry, clientReattach);
fCache.insert(key, entry);
#if GR_DUMP_TEXTURE_UPLOAD
@@ -211,12 +212,12 @@
GrResourceEntry* GrResourceCache::createAndLock(const GrResourceKey& key,
GrResource* resource) {
- return this->create(key, resource, true);
+ return this->create(key, resource, true, false);
}
void GrResourceCache::attach(const GrResourceKey& key,
GrResource* resource) {
- this->create(key, resource, false);
+ this->create(key, resource, false, true);
}
void GrResourceCache::detach(GrResourceEntry* entry) {
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 525c67e..24f2b8f 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -316,13 +316,14 @@
size_t fEntryBytes;
int fClientDetachedCount;
size_t fClientDetachedBytes;
-
+
// prevents recursive purging
bool fPurging;
GrResourceEntry* create(const GrResourceKey& key,
GrResource* resource,
- bool lock);
+ bool lock,
+ bool clientReattach);
};