Index: src/gpu/GrResourceCache.cpp |
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp |
index 4a0c9b2b369bbc12cb4254dedeaae16b929454d6..2abe7e93530af2ad858890f77c741e62751ba980 100644 |
--- a/src/gpu/GrResourceCache.cpp |
+++ b/src/gpu/GrResourceCache.cpp |
@@ -375,25 +375,27 @@ void GrResourceCache::notifyCntReachedZero(GrGpuResource* resource, uint32_t fla |
this->removeFromNonpurgeableArray(resource); |
fPurgeableQueue.insert(resource); |
- if (!resource->resourcePriv().isBudgeted()) { |
- // Check whether this resource could still be used as a scratch resource. |
- if (!resource->cacheAccess().isExternal() && |
- resource->resourcePriv().getScratchKey().isValid()) { |
- // We won't purge an existing resource to make room for this one. |
- if (fBudgetedCount < fMaxCount && |
- fBudgetedBytes + resource->gpuMemorySize() <= fMaxBytes) { |
- resource->resourcePriv().makeBudgeted(); |
+ if (resource->reuseable()) { |
+ if (!resource->resourcePriv().isBudgeted()) { |
+ // Check whether this resource could still be used as a scratch resource. |
+ if (!resource->cacheAccess().isExternal() && |
+ resource->resourcePriv().getScratchKey().isValid()) { |
+ // We won't purge an existing resource to make room for this one. |
+ if (fBudgetedCount < fMaxCount && |
+ fBudgetedBytes + resource->gpuMemorySize() <= fMaxBytes) { |
+ resource->resourcePriv().makeBudgeted(); |
+ return; |
+ } |
+ } |
+ } else { |
+ // Purge the resource immediately if we're over budget |
+ // Also purge if the resource has neither a valid scratch key nor a unique key. |
+ bool noKey = !resource->resourcePriv().getScratchKey().isValid() && |
+ !resource->getUniqueKey().isValid(); |
+ if (!this->overBudget() && !noKey) { |
return; |
} |
} |
- } else { |
- // Purge the resource immediately if we're over budget |
- // Also purge if the resource has neither a valid scratch key nor a unique key. |
- bool noKey = !resource->resourcePriv().getScratchKey().isValid() && |
- !resource->getUniqueKey().isValid(); |
- if (!this->overBudget() && !noKey) { |
- return; |
- } |
} |
SkDEBUGCODE(int beforeCount = this->getResourceCount();) |