| OLD | NEW |
| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 resource = fScratchMap.find(scratchKey, AvailableForScratchUse(false)); | 212 resource = fScratchMap.find(scratchKey, AvailableForScratchUse(false)); |
| 213 if (resource) { | 213 if (resource) { |
| 214 resource->ref(); | 214 resource->ref(); |
| 215 this->makeResourceMRU(resource); | 215 this->makeResourceMRU(resource); |
| 216 this->validate(); | 216 this->validate(); |
| 217 } | 217 } |
| 218 return resource; | 218 return resource; |
| 219 } | 219 } |
| 220 | 220 |
| 221 void GrResourceCache2::willRemoveScratchKey(const GrGpuResource* resource) { |
| 222 SkASSERT(resource->cacheAccess().isScratch()); |
| 223 fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource); |
| 224 } |
| 225 |
| 221 bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) { | 226 bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) { |
| 222 SkASSERT(!fPurging); | 227 SkASSERT(!fPurging); |
| 223 SkASSERT(resource); | 228 SkASSERT(resource); |
| 224 SkASSERT(this->isInCache(resource)); | 229 SkASSERT(this->isInCache(resource)); |
| 225 SkASSERT(resource->cacheAccess().getContentKey()); | 230 SkASSERT(resource->cacheAccess().getContentKey()); |
| 226 SkASSERT(!resource->cacheAccess().getContentKey()->isScratch()); | 231 SkASSERT(!resource->cacheAccess().getContentKey()->isScratch()); |
| 227 | 232 |
| 228 GrGpuResource* res = fContentHash.find(*resource->cacheAccess().getContentKe
y()); | 233 GrGpuResource* res = fContentHash.find(*resource->cacheAccess().getContentKe
y()); |
| 229 if (NULL != res) { | 234 if (NULL != res) { |
| 230 return false; | 235 return false; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 489 |
| 485 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes); | 490 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes); |
| 486 SkDebugf("\t\tEntry Count: current %d" | 491 SkDebugf("\t\tEntry Count: current %d" |
| 487 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), hig
h %d\n", | 492 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), hig
h %d\n", |
| 488 fCount, fBudgetedCount, wrapped, locked, scratch, countUtilization, fHig
hWaterCount); | 493 fCount, fBudgetedCount, wrapped, locked, scratch, countUtilization, fHig
hWaterCount); |
| 489 SkDebugf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudget
ed) high %d\n", | 494 SkDebugf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudget
ed) high %d\n", |
| 490 fBytes, fBudgetedBytes, byteUtilization, unbudgetedSize, fHighWa
terBytes); | 495 fBytes, fBudgetedBytes, byteUtilization, unbudgetedSize, fHighWa
terBytes); |
| 491 } | 496 } |
| 492 | 497 |
| 493 #endif | 498 #endif |
| OLD | NEW |