diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-18 17:12:57 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-18 17:12:57 +0000 |
commit | db7ae2093a2240c6ff0f9492cb6c77c38f5bfc4a (patch) | |
tree | 1491f12bfaa183eb6b8a961af073c8015f733cf2 /gpu/GrResourceCache.cpp | |
parent | 407ee05903b17cc662265a6b7a4ad478655b1794 (diff) | |
download | src-db7ae2093a2240c6ff0f9492cb6c77c38f5bfc4a.tar.gz |
The rest of: Add purgeAsNeeded calls before addResource calls
https://codereview.chromium.org/19591003/
git-svn-id: http://skia.googlecode.com/svn/trunk/src@10146 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/GrResourceCache.cpp')
-rw-r--r-- | gpu/GrResourceCache.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gpu/GrResourceCache.cpp b/gpu/GrResourceCache.cpp index baae6bd3..9dab021c 100644 --- a/gpu/GrResourceCache.cpp +++ b/gpu/GrResourceCache.cpp @@ -276,28 +276,33 @@ void GrResourceCache::makeNonExclusive(GrResourceEntry* entry) { * resource's destructor inserting new resources into the cache. If these * new resources were unlocked before purgeAsNeeded completed it could * potentially make purgeAsNeeded loop infinitely. + * + * extraCount and extraBytes are added to the current resource totals to account + * for incoming resources (e.g., GrContext is about to add 10MB split between + * 10 textures). */ -void GrResourceCache::purgeAsNeeded() { +void GrResourceCache::purgeAsNeeded(int extraCount, size_t extraBytes) { if (fPurging) { return; } fPurging = true; - this->internalPurge(); - if ((fEntryCount > fMaxCount || fEntryBytes > fMaxBytes) && + this->internalPurge(extraCount, extraBytes); + if (((fEntryCount+extraCount) > fMaxCount || + (fEntryBytes+extraBytes) > fMaxBytes) && NULL != fOverbudgetCB) { // Despite the purge we're still over budget. See if Ganesh can // release some resources and purge again. if ((*fOverbudgetCB)(fOverbudgetData)) { - this->internalPurge(); + this->internalPurge(extraCount, extraBytes); } } fPurging = false; } -void GrResourceCache::internalPurge() { +void GrResourceCache::internalPurge(int extraCount, size_t extraBytes) { SkASSERT(fPurging); bool withinBudget = false; @@ -319,7 +324,8 @@ void GrResourceCache::internalPurge() { while (NULL != entry) { GrAutoResourceCacheValidate atcv(this); - if (fEntryCount <= fMaxCount && fEntryBytes <= fMaxBytes) { + if ((fEntryCount+extraCount) <= fMaxCount && + (fEntryBytes+extraBytes) <= fMaxBytes) { withinBudget = true; break; } |