Index: src/gpu/GrBufferAllocPool.cpp |
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp |
index 9fafcb35ac439a04581460d357e76cfca0904919..26a1d1583725ee120b33d59797d92f926fae824e 100644 |
--- a/src/gpu/GrBufferAllocPool.cpp |
+++ b/src/gpu/GrBufferAllocPool.cpp |
@@ -131,6 +131,7 @@ void GrBufferAllocPool::unmap() { |
#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 @@ void GrBufferAllocPool::validate(bool unusedBlockAllowed) const { |
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 |