| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 #endif | 157 #endif |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 // This functor just searches for an entry with only a single ref (from | 161 // This functor just searches for an entry with only a single ref (from |
| 162 // the texture cache itself). Presumably in this situation no one else | 162 // the texture cache itself). Presumably in this situation no one else |
| 163 // is relying on the texture. | 163 // is relying on the texture. |
| 164 class GrTFindUnreffedFunctor { | 164 class GrTFindUnreffedFunctor { |
| 165 public: | 165 public: |
| 166 bool operator()(const GrResourceEntry* entry) const { | 166 bool operator()(const GrResourceEntry* entry) const { |
| 167 return 1 == entry->resource()->getRefCnt(); | 167 return entry->resource()->unique(); |
| 168 } | 168 } |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 GrResource* GrResourceCache::find(const GrResourceKey& key, uint32_t ownershipFl
ags) { | 171 GrResource* GrResourceCache::find(const GrResourceKey& key, uint32_t ownershipFl
ags) { |
| 172 GrAutoResourceCacheValidate atcv(this); | 172 GrAutoResourceCacheValidate atcv(this); |
| 173 | 173 |
| 174 GrResourceEntry* entry = NULL; | 174 GrResourceEntry* entry = NULL; |
| 175 | 175 |
| 176 if (ownershipFlags & kNoOtherOwners_OwnershipFlag) { | 176 if (ownershipFlags & kNoOtherOwners_OwnershipFlag) { |
| 177 GrTFindUnreffedFunctor functor; | 177 GrTFindUnreffedFunctor functor; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 while (NULL != entry) { | 331 while (NULL != entry) { |
| 332 GrAutoResourceCacheValidate atcv(this); | 332 GrAutoResourceCacheValidate atcv(this); |
| 333 | 333 |
| 334 if ((fEntryCount+extraCount) <= fMaxCount && | 334 if ((fEntryCount+extraCount) <= fMaxCount && |
| 335 (fEntryBytes+extraBytes) <= fMaxBytes) { | 335 (fEntryBytes+extraBytes) <= fMaxBytes) { |
| 336 withinBudget = true; | 336 withinBudget = true; |
| 337 break; | 337 break; |
| 338 } | 338 } |
| 339 | 339 |
| 340 GrResourceEntry* prev = iter.prev(); | 340 GrResourceEntry* prev = iter.prev(); |
| 341 if (1 == entry->fResource->getRefCnt()) { | 341 if (entry->fResource->unique()) { |
| 342 changed = true; | 342 changed = true; |
| 343 this->deleteResource(entry); | 343 this->deleteResource(entry); |
| 344 } | 344 } |
| 345 entry = prev; | 345 entry = prev; |
| 346 } | 346 } |
| 347 } while (!withinBudget && changed); | 347 } while (!withinBudget && changed); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void GrResourceCache::purgeAllUnlocked() { | 350 void GrResourceCache::purgeAllUnlocked() { |
| 351 GrAutoResourceCacheValidate atcv(this); | 351 GrAutoResourceCacheValidate atcv(this); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 fEntryBytes, fHighWaterEntryBytes); | 465 fEntryBytes, fHighWaterEntryBytes); |
| 466 SkDebugf("\t\tDetached Entry Count: current %d high %d\n", | 466 SkDebugf("\t\tDetached Entry Count: current %d high %d\n", |
| 467 fClientDetachedCount, fHighWaterClientDetachedCount); | 467 fClientDetachedCount, fHighWaterClientDetachedCount); |
| 468 SkDebugf("\t\tDetached Bytes: current %d high %d\n", | 468 SkDebugf("\t\tDetached Bytes: current %d high %d\n", |
| 469 fClientDetachedBytes, fHighWaterClientDetachedBytes); | 469 fClientDetachedBytes, fHighWaterClientDetachedBytes); |
| 470 } | 470 } |
| 471 | 471 |
| 472 #endif | 472 #endif |
| 473 | 473 |
| 474 /////////////////////////////////////////////////////////////////////////////// | 474 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |