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

Side by Side Diff: src/gpu/GrResourceCache2.cpp

Issue 729753003: Guard high water cache stats vars by GR_CACHE_STATS (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrResourceCache2.h" 10 #include "GrResourceCache2.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void GrResourceCache2::insertResource(GrGpuResource* resource) { 88 void GrResourceCache2::insertResource(GrGpuResource* resource) {
89 AutoValidate av(this); 89 AutoValidate av(this);
90 90
91 SkASSERT(resource); 91 SkASSERT(resource);
92 SkASSERT(!resource->wasDestroyed()); 92 SkASSERT(!resource->wasDestroyed());
93 SkASSERT(!this->isInCache(resource)); 93 SkASSERT(!this->isInCache(resource));
94 SkASSERT(!fPurging); 94 SkASSERT(!fPurging);
95 fResources.addToHead(resource); 95 fResources.addToHead(resource);
96 96
97 ++fCount; 97 ++fCount;
98 SkDEBUGCODE(fHighWaterCount = SkTMax(fCount, fHighWaterCount));
99 fBytes += resource->gpuMemorySize(); 98 fBytes += resource->gpuMemorySize();
100 SkDEBUGCODE(fHighWaterBytes = SkTMax(fBytes, fHighWaterBytes)); 99 #if GR_CACHE_STATS
100 fHighWaterCount = SkTMax(fCount, fHighWaterCount);
101 fHighWaterBytes = SkTMax(fBytes, fHighWaterBytes);
102 #endif
101 if (!resource->cacheAccess().getScratchKey().isNullScratch()) { 103 if (!resource->cacheAccess().getScratchKey().isNullScratch()) {
102 // TODO(bsalomon): Make this assertion possible. 104 // TODO(bsalomon): Make this assertion possible.
103 // SkASSERT(!resource->isWrapped()); 105 // SkASSERT(!resource->isWrapped());
104 fScratchMap.insert(resource->cacheAccess().getScratchKey(), resource); 106 fScratchMap.insert(resource->cacheAccess().getScratchKey(), resource);
105 } 107 }
106 108
107 this->purgeAsNeeded(); 109 this->purgeAsNeeded();
108 } 110 }
109 111
110 void GrResourceCache2::removeResource(GrGpuResource* resource) { 112 void GrResourceCache2::removeResource(GrGpuResource* resource) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 251
250 this->validate(); 252 this->validate();
251 } 253 }
252 254
253 void GrResourceCache2::didChangeGpuMemorySize(const GrGpuResource* resource, siz e_t oldSize) { 255 void GrResourceCache2::didChangeGpuMemorySize(const GrGpuResource* resource, siz e_t oldSize) {
254 // SkASSERT(!fPurging); GrPathRange increases size during flush. :( 256 // SkASSERT(!fPurging); GrPathRange increases size during flush. :(
255 SkASSERT(resource); 257 SkASSERT(resource);
256 SkASSERT(this->isInCache(resource)); 258 SkASSERT(this->isInCache(resource));
257 259
258 fBytes += resource->gpuMemorySize() - oldSize; 260 fBytes += resource->gpuMemorySize() - oldSize;
259 SkDEBUGCODE(fHighWaterBytes = SkTMax(fBytes, fHighWaterBytes)); 261 #if GR_CACHE_STATS
262 fHighWaterBytes = SkTMax(fBytes, fHighWaterBytes);
263 #endif
260 264
261 this->purgeAsNeeded(); 265 this->purgeAsNeeded();
262 this->validate(); 266 this->validate();
263 } 267 }
264 268
265 void GrResourceCache2::internalPurgeAsNeeded() { 269 void GrResourceCache2::internalPurgeAsNeeded() {
266 SkASSERT(!fPurging); 270 SkASSERT(!fPurging);
267 SkASSERT(!fNewlyPurgableResourceWhilePurging); 271 SkASSERT(!fNewlyPurgableResourceWhilePurging);
268 SkASSERT(fCount > fMaxCount || fBytes > fMaxBytes); 272 SkASSERT(fCount > fMaxCount || fBytes > fMaxBytes);
269 273
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 float byteUtilization = (100.f * fBytes) / fMaxBytes; 407 float byteUtilization = (100.f * fBytes) / fMaxBytes;
404 408
405 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes); 409 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
406 SkDebugf("\t\tEntry Count: current %d (%d locked, %d scratch %.2g%% full), h igh %d\n", 410 SkDebugf("\t\tEntry Count: current %d (%d locked, %d scratch %.2g%% full), h igh %d\n",
407 fCount, locked, scratch, countUtilization, fHighWaterCount); 411 fCount, locked, scratch, countUtilization, fHighWaterCount);
408 SkDebugf("\t\tEntry Bytes: current %d (%.2g%% full) high %d\n", 412 SkDebugf("\t\tEntry Bytes: current %d (%.2g%% full) high %d\n",
409 fBytes, byteUtilization, fHighWaterBytes); 413 fBytes, byteUtilization, fHighWaterBytes);
410 } 414 }
411 415
412 #endif 416 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698