Fix GPU resource cache related assertions.
Review URL: https://codereview.chromium.org/879963003
diff --git a/include/gpu/GrResourceKey.h b/include/gpu/GrResourceKey.h
index 15d7b43..26373a7 100644
--- a/include/gpu/GrResourceKey.h
+++ b/include/gpu/GrResourceKey.h
@@ -45,6 +45,7 @@
}
bool operator==(const GrResourceKey& that) const {
+ SkASSERT(this->isValid() && that.isValid());
return 0 == memcmp(fKey.get(), that.fKey.get(), this->size());
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 6879b10..13b0bfa 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -502,9 +502,11 @@
GrTexture* texture = fGpu->createTexture(*desc, true, NULL, 0);
#ifdef SK_DEBUG
- GrScratchKey key;
- GrTexturePriv::ComputeScratchKey(*desc, &key);
- SkASSERT(NULL == texture || texture->cacheAccess().getScratchKey() == key);
+ if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
+ GrScratchKey key;
+ GrTexturePriv::ComputeScratchKey(*desc, &key);
+ SkASSERT(NULL == texture || texture->cacheAccess().getScratchKey() == key);
+ }
#endif
return texture;
}
diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp
index c72fc7c..65894d3 100644
--- a/src/gpu/GrResourceCache2.cpp
+++ b/src/gpu/GrResourceCache2.cpp
@@ -217,7 +217,7 @@
}
void GrResourceCache2::willRemoveScratchKey(const GrGpuResource* resource) {
- SkASSERT(resource->cacheAccess().isScratch());
+ SkASSERT(resource->cacheAccess().getScratchKey().isValid());
fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource);
}