Replace GrResourceCache with GrResourceCache2.
BUG=skia:2889
Committed: https://skia.googlesource.com/skia/+/66a450f21a3da174b7eed89a1d5fc8591e8b6ee6
Committed: https://skia.googlesource.com/skia/+/407aa584d183c1bf314f5defd1cf0202e8a96c89
Review URL: https://codereview.chromium.org/716143004
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index 9fafcb3..26a1d15 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -131,6 +131,7 @@
#ifdef SK_DEBUG
void GrBufferAllocPool::validate(bool unusedBlockAllowed) const {
+ bool wasDestroyed = false;
if (fBufferPtr) {
SkASSERT(!fBlocks.empty());
if (fBlocks.back().fBuffer->isMapped()) {
@@ -146,18 +147,24 @@
for (int i = 0; i < fBlocks.count() - 1; ++i) {
SkASSERT(!fBlocks[i].fBuffer->isMapped());
}
- for (int i = 0; i < fBlocks.count(); ++i) {
- size_t bytes = fBlocks[i].fBuffer->gpuMemorySize() - fBlocks[i].fBytesFree;
- bytesInUse += bytes;
- SkASSERT(bytes || unusedBlockAllowed);
+ for (int i = 0; !wasDestroyed && i < fBlocks.count(); ++i) {
+ if (fBlocks[i].fBuffer->wasDestroyed()) {
+ wasDestroyed = true;
+ } else {
+ size_t bytes = fBlocks[i].fBuffer->gpuMemorySize() - fBlocks[i].fBytesFree;
+ bytesInUse += bytes;
+ SkASSERT(bytes || unusedBlockAllowed);
+ }
}
- SkASSERT(bytesInUse == fBytesInUse);
- if (unusedBlockAllowed) {
- SkASSERT((fBytesInUse && !fBlocks.empty()) ||
- (!fBytesInUse && (fBlocks.count() < 2)));
- } else {
- SkASSERT((0 == fBytesInUse) == fBlocks.empty());
+ if (!wasDestroyed) {
+ SkASSERT(bytesInUse == fBytesInUse);
+ if (unusedBlockAllowed) {
+ SkASSERT((fBytesInUse && !fBlocks.empty()) ||
+ (!fBytesInUse && (fBlocks.count() < 2)));
+ } else {
+ SkASSERT((0 == fBytesInUse) == fBlocks.empty());
+ }
}
}
#endif