Chromium Code Reviews| Index: src/gpu/GrResourceCache.cpp |
| diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp |
| index 1d0f3845c5d5a4e08f417baa5fe4f52442bf6a54..5cf3f82c7d780d1acc5ee53ca20d9f6140b1a7b4 100644 |
| --- a/src/gpu/GrResourceCache.cpp |
| +++ b/src/gpu/GrResourceCache.cpp |
| @@ -284,6 +284,8 @@ void GrResourceCache::purgeAsNeeded(int extraCount, size_t extraBytes) { |
| fPurging = true; |
| + this->purgeInvalidated(); |
| + |
| this->internalPurge(extraCount, extraBytes); |
| if (((fEntryCount+extraCount) > fMaxCount || |
| (fEntryBytes+extraBytes) > fMaxBytes) && |
| @@ -298,6 +300,25 @@ void GrResourceCache::purgeAsNeeded(int extraCount, size_t extraBytes) { |
| fPurging = false; |
| } |
| +void GrResourceCache::purgeInvalidated() { |
| + SkTDArray<GrResourceInvalidatedMessage> invalidated; |
| + fInvalidationInbox.poll(&invalidated); |
| + |
| + for (int i = 0; i < invalidated.count(); i++) { |
| + // We're somewhat missing an opportunity here. We could use the |
| + // default find functor that gives us back resources whether we own |
| + // them exclusively or not, and when they're not exclusively owned mark |
| + // them for purging later when they do become exclusively owned. |
| + // |
| + // This is complicated and confusing. May try this in the future. For |
| + // now, these resources are just LRU'd as if we never got the message. |
| + GrResourceEntry* entry = fCache.find(invalidated[i].key, GrTFindUnreffedFunctor()); |
|
bsalomon
2013/10/23 13:52:57
Don't we need the unique check somewhere in here?
mtklein
2013/10/23 15:28:10
Yes. That's what GrTFindUnreffedFunctor() does. :
|
| + if (entry) { |
| + this->deleteResource(entry); |
| + } |
| + } |
| +} |
| + |
| void GrResourceCache::deleteResource(GrResourceEntry* entry) { |
| SkASSERT(1 == entry->fResource->getRefCnt()); |