Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: src/gpu/GrTest.cpp

Issue 932863004: Use an array of nonpurgeable resources in GrResourceCache (Closed) Base URL: https://skia.googlesource.com/skia.git@queue
Patch Set: skdebugf- Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrResourceCache.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/gpu/GrResourceCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698