aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceCache.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-09-08 11:44:14 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-08 16:04:33 +0000
commit0d53780b8cbf75c0282fb8246a0a3de0026f211b (patch)
tree3cc98d793a9803b2a15bab7b740b0507ea3938e7 /src/gpu/GrResourceCache.cpp
parent33fea05c3f3f228b245cde99184d5ce790068745 (diff)
Update GrResourceCache changeUniqueKey to stay in valid state after each step
The issues are that we are intertwining removing things from the old and new resource. This changes it so we do all the removal on the old resource first then start updating the new resource. Bug: skia: Change-Id: I7ce4a309290cd499cdc4398c87d1cfd42ef6994d Reviewed-on: https://skia-review.googlesource.com/44242 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrResourceCache.cpp')
-rw-r--r--src/gpu/GrResourceCache.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index b781e42be1..f6170c01b6 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -294,6 +294,16 @@ void GrResourceCache::changeUniqueKey(GrGpuResource* resource, const GrUniqueKey
// If another resource has the new key, remove its key then install the key on this resource.
if (newKey.isValid()) {
+ if (GrGpuResource* old = fUniqueHash.find(newKey)) {
+ // If the old resource using the key is purgeable and is unreachable, then remove it.
+ if (!old->resourcePriv().getScratchKey().isValid() && old->isPurgeable()) {
+ old->cacheAccess().release();
+ } else {
+ this->removeUniqueKey(old);
+ }
+ }
+ SkASSERT(nullptr == fUniqueHash.find(newKey));
+
// Remove the entry for this resource if it already has a unique key.
if (resource->getUniqueKey().isValid()) {
SkASSERT(resource == fUniqueHash.find(resource->getUniqueKey()));
@@ -307,18 +317,6 @@ void GrResourceCache::changeUniqueKey(GrGpuResource* resource, const GrUniqueKey
}
}
- if (GrGpuResource* old = fUniqueHash.find(newKey)) {
- // If the old resource using the key is purgeable and is unreachable, then remove it.
- if (!old->resourcePriv().getScratchKey().isValid() && old->isPurgeable()) {
- // release may call validate() which will assert that resource is in fUniqueHash
- // if it has a valid key. So in debug reset the key here before we assign it.
- SkDEBUGCODE(resource->cacheAccess().removeUniqueKey();)
- old->cacheAccess().release();
- } else {
- this->removeUniqueKey(old);
- }
- }
- SkASSERT(nullptr == fUniqueHash.find(newKey));
resource->cacheAccess().setUniqueKey(newKey);
fUniqueHash.add(resource);
} else {