| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |