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

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

Issue 846303002: Make uncached textures uncached from the get go. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrPathRange.cpp ('k') | src/gpu/GrStencilBuffer.h » ('j') | 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return; 254 return;
255 } 255 }
256 256
257 // Purge the resource if we're over budget 257 // Purge the resource if we're over budget
258 bool overBudget = fBudgetedCount > fMaxCount || fBudgetedBytes > fMaxBytes; 258 bool overBudget = fBudgetedCount > fMaxCount || fBudgetedBytes > fMaxBytes;
259 259
260 // Also purge if the resource has neither a valid scratch key nor a content key. 260 // Also purge if the resource has neither a valid scratch key nor a content key.
261 bool noKey = !resource->cacheAccess().isScratch() && 261 bool noKey = !resource->cacheAccess().isScratch() &&
262 (NULL == resource->cacheAccess().getContentKey()); 262 (NULL == resource->cacheAccess().getContentKey());
263 263
264 // Wrapped resources should never have a key. 264 // Only cached resources should ever have a key.
265 SkASSERT(noKey || !resource->cacheAccess().isWrapped()); 265 SkASSERT(noKey || resource->cacheAccess().isBudgeted());
266 266
267 // And purge if the resource is wrapped
268 if (overBudget || noKey) { 267 if (overBudget || noKey) {
269 SkDEBUGCODE(int beforeCount = fCount;) 268 SkDEBUGCODE(int beforeCount = fCount;)
270 resource->cacheAccess().release(); 269 resource->cacheAccess().release();
271 // We should at least free this resource, perhaps dependent resources as well. 270 // We should at least free this resource, perhaps dependent resources as well.
272 SkASSERT(fCount < beforeCount); 271 SkASSERT(fCount < beforeCount);
273 } 272 }
274 273
275 this->validate(); 274 this->validate();
276 } 275 }
277 276
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 fBudgetedBytes += size; 308 fBudgetedBytes += size;
310 this->purgeAsNeeded(); 309 this->purgeAsNeeded();
311 } else { 310 } else {
312 --fBudgetedCount; 311 --fBudgetedCount;
313 fBudgetedBytes -= size; 312 fBudgetedBytes -= size;
314 } 313 }
315 314
316 this->validate(); 315 this->validate();
317 } 316 }
318 317
319
320 void GrResourceCache2::internalPurgeAsNeeded() { 318 void GrResourceCache2::internalPurgeAsNeeded() {
321 SkASSERT(!fPurging); 319 SkASSERT(!fPurging);
322 SkASSERT(!fNewlyPurgableResourceWhilePurging); 320 SkASSERT(!fNewlyPurgableResourceWhilePurging);
323 SkASSERT(fBudgetedCount > fMaxCount || fBudgetedBytes > fMaxBytes); 321 SkASSERT(fBudgetedCount > fMaxCount || fBudgetedBytes > fMaxBytes);
324 322
325 fPurging = true; 323 fPurging = true;
326 324
327 bool overBudget = true; 325 bool overBudget = true;
328 do { 326 do {
329 fNewlyPurgableResourceWhilePurging = false; 327 fNewlyPurgableResourceWhilePurging = false;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 481
484 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes); 482 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
485 SkDebugf("\t\tEntry Count: current %d" 483 SkDebugf("\t\tEntry Count: current %d"
486 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), hig h %d\n", 484 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), hig h %d\n",
487 fCount, fBudgetedCount, wrapped, locked, scratch, countUtilization, fHig hWaterCount); 485 fCount, fBudgetedCount, wrapped, locked, scratch, countUtilization, fHig hWaterCount);
488 SkDebugf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudget ed) high %d\n", 486 SkDebugf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudget ed) high %d\n",
489 fBytes, fBudgetedBytes, byteUtilization, unbudgetedSize, fHighWa terBytes); 487 fBytes, fBudgetedBytes, byteUtilization, unbudgetedSize, fHighWa terBytes);
490 } 488 }
491 489
492 #endif 490 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrPathRange.cpp ('k') | src/gpu/GrStencilBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698