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

Side by Side Diff: src/core/SkTypefaceCache.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: Update comments. 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
« no previous file with comments | « src/core/SkTRefArray.h ('k') | src/gpu/GrContext.cpp » ('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 2011 Google Inc. 3 * Copyright 2011 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 return NULL; 63 return NULL;
64 } 64 }
65 65
66 void SkTypefaceCache::purge(int numToPurge) { 66 void SkTypefaceCache::purge(int numToPurge) {
67 int count = fArray.count(); 67 int count = fArray.count();
68 int i = 0; 68 int i = 0;
69 while (i < count) { 69 while (i < count) {
70 SkTypeface* face = fArray[i].fFace; 70 SkTypeface* face = fArray[i].fFace;
71 bool strong = fArray[i].fStrong; 71 bool strong = fArray[i].fStrong;
72 if ((strong && face->getRefCnt() == 1) || 72 if ((strong && face->unique()) || (!strong && face->weak_expired())) {
73 (!strong && face->weak_expired()))
74 {
75 if (strong) { 73 if (strong) {
76 face->unref(); 74 face->unref();
77 } else { 75 } else {
78 face->weak_unref(); 76 face->weak_unref();
79 } 77 }
80 fArray.remove(i); 78 fArray.remove(i);
81 --count; 79 --count;
82 if (--numToPurge == 0) { 80 if (--numToPurge == 0) {
83 return; 81 return;
84 } 82 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return false; 136 return false;
139 } 137 }
140 #endif 138 #endif
141 139
142 void SkTypefaceCache::Dump() { 140 void SkTypefaceCache::Dump() {
143 #ifdef SK_DEBUG 141 #ifdef SK_DEBUG
144 SkAutoMutexAcquire ama(gMutex); 142 SkAutoMutexAcquire ama(gMutex);
145 (void)Get().findByProcAndRef(DumpProc, NULL); 143 (void)Get().findByProcAndRef(DumpProc, NULL);
146 #endif 144 #endif
147 } 145 }
OLDNEW
« no previous file with comments | « src/core/SkTRefArray.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698