Don't purge resources from cache if they have > 1 ref

https://codereview.appspot.com/6494069/



git-svn-id: http://skia.googlecode.com/svn/trunk@5380 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2012-09-04 13:36:31 +00:00
parent 9474ed0617
commit 6fc9518a55

View File

@ -332,9 +332,15 @@ void GrResourceCache::purgeAsNeeded() {
if (!fPurging) {
fPurging = true;
bool withinBudget = false;
int priorUnlockedEntryCount = 0;
// The purging process is repeated several times since one pass
// may free up other resources
do {
EntryList::Iter iter;
priorUnlockedEntryCount = fUnlockedEntryCount;
// Note: the following code relies on the fact that the
// doubly linked list doesn't invalidate its data/pointers
// outside of the specific area where a deletion occurs (e.g.,
@ -349,7 +355,7 @@ void GrResourceCache::purgeAsNeeded() {
}
GrResourceEntry* prev = iter.prev();
if (!entry->isLocked()) {
if (!entry->isLocked() && entry->fResource->getRefCnt() == 1) {
// remove from our cache
fCache.remove(entry->key(), entry);
@ -367,7 +373,7 @@ void GrResourceCache::purgeAsNeeded() {
}
entry = prev;
}
} while (!withinBudget && fUnlockedEntryCount);
} while (!withinBudget && (fUnlockedEntryCount != priorUnlockedEntryCount));
fPurging = false;
}
}