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

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

Issue 18770007: Add a 'unique' method to SkRefCnt, document the usage, and add support. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 318
319 while (NULL != entry) { 319 while (NULL != entry) {
320 GrAutoResourceCacheValidate atcv(this); 320 GrAutoResourceCacheValidate atcv(this);
321 321
322 if (fEntryCount <= fMaxCount && fEntryBytes <= fMaxBytes) { 322 if (fEntryCount <= fMaxCount && fEntryBytes <= fMaxBytes) {
323 withinBudget = true; 323 withinBudget = true;
324 break; 324 break;
325 } 325 }
326 326
327 GrResourceEntry* prev = iter.prev(); 327 GrResourceEntry* prev = iter.prev();
328 if (1 == entry->fResource->getRefCnt()) { 328 if (entry->fResource->unique()) {
329 changed = true; 329 changed = true;
330 330
331 // remove from our cache 331 // remove from our cache
332 fCache.remove(entry->key(), entry); 332 fCache.remove(entry->key(), entry);
333 333
334 // remove from our llist 334 // remove from our llist
335 this->internalDetach(entry); 335 this->internalDetach(entry);
336 delete entry; 336 delete entry;
337 } 337 }
338 entry = prev; 338 entry = prev;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 fEntryBytes, fHighWaterEntryBytes); 458 fEntryBytes, fHighWaterEntryBytes);
459 SkDebugf("\t\tDetached Entry Count: current %d high %d\n", 459 SkDebugf("\t\tDetached Entry Count: current %d high %d\n",
460 fClientDetachedCount, fHighWaterClientDetachedCount); 460 fClientDetachedCount, fHighWaterClientDetachedCount);
461 SkDebugf("\t\tDetached Bytes: current %d high %d\n", 461 SkDebugf("\t\tDetached Bytes: current %d high %d\n",
462 fClientDetachedBytes, fHighWaterClientDetachedBytes); 462 fClientDetachedBytes, fHighWaterClientDetachedBytes);
463 } 463 }
464 464
465 #endif 465 #endif
466 466
467 /////////////////////////////////////////////////////////////////////////////// 467 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« src/core/SkPathRef.h ('K') | « src/gpu/GrEffect.cpp ('k') | src/image/SkSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698