Index: src/gpu/GrTest.cpp |
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp |
index 72fde041b188bebef1c60ca97f0d35c73ae16596..ba9278ed506e05cd4f4bc762bcbee5e02ce3b87f 100644 |
--- a/src/gpu/GrTest.cpp |
+++ b/src/gpu/GrTest.cpp |
@@ -79,27 +79,35 @@ void GrGpu::Stats::dump(SkString* out) { |
void GrResourceCache::dumpStats(SkString* out) const { |
this->validate(); |
- int locked = 0; |
- int scratch = 0; |
- int wrapped = 0; |
- size_t unbudgetedSize = 0; |
+ int locked = fNonpurgeableResources.count(); |
+ |
+ struct Stats { |
+ int fScratch; |
+ int fWrapped; |
+ size_t fUnbudgetedSize; |
+ |
+ Stats() : fScratch(0), fWrapped(0), fUnbudgetedSize(0) {} |
+ |
+ void update(GrGpuResource* resource) { |
+ if (resource->cacheAccess().isScratch()) { |
+ ++fScratch; |
+ } |
+ if (resource->cacheAccess().isWrapped()) { |
+ ++fWrapped; |
+ } |
+ if (!resource->resourcePriv().isBudgeted()) { |
+ fUnbudgetedSize += resource->gpuMemorySize(); |
+ } |
+ } |
+ }; |
- ResourceList::Iter iter; |
- GrGpuResource* resource = iter.init(fResources, ResourceList::Iter::kHead_IterStart); |
+ Stats stats; |
- for ( ; resource; resource = iter.next()) { |
- if (!resource->isPurgeable()) { |
- ++locked; |
- } |
- if (resource->cacheAccess().isScratch()) { |
- ++scratch; |
- } |
- if (resource->cacheAccess().isWrapped()) { |
- ++wrapped; |
- } |
- if (!resource->resourcePriv().isBudgeted()) { |
- unbudgetedSize += resource->gpuMemorySize(); |
- } |
+ for (int i = 0; i < fNonpurgeableResources.count(); ++i) { |
+ stats.update(fNonpurgeableResources[i]); |
+ } |
+ for (int i = 0; i < fPurgeableQueue.count(); ++i) { |
+ stats.update(fPurgeableQueue.at(i)); |
} |
float countUtilization = (100.f * fBudgetedCount) / fMaxCount; |
@@ -108,11 +116,11 @@ void GrResourceCache::dumpStats(SkString* out) const { |
out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); |
out->appendf("\t\tEntry Count: current %d" |
" (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n", |
- fCount, fBudgetedCount, wrapped, locked, scratch, countUtilization, |
+ fCount, fBudgetedCount, stats.fWrapped, locked, stats.fScratch, countUtilization, |
fHighWaterCount); |
out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudgeted) high %d\n", |
- (int)fBytes, (int)fBudgetedBytes, byteUtilization, |
- (int)unbudgetedSize, (int)fHighWaterBytes); |
+ SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, |
+ SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); |
} |
#endif |