| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 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 "SkGlyphCache.h" | 10 #include "SkGlyphCache.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 fCacheCountLimit = newCount; | 480 fCacheCountLimit = newCount; |
| 481 this->internalPurge(); | 481 this->internalPurge(); |
| 482 return prevCount; | 482 return prevCount; |
| 483 } | 483 } |
| 484 | 484 |
| 485 void SkGlyphCache_Globals::purgeAll() { | 485 void SkGlyphCache_Globals::purgeAll() { |
| 486 SkAutoMutexAcquire ac(fMutex); | 486 SkAutoMutexAcquire ac(fMutex); |
| 487 this->internalPurge(fTotalMemoryUsed); | 487 this->internalPurge(fTotalMemoryUsed); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void SkGlyphCache::VisitAllCaches(bool (*proc)(SkGlyphCache*, void*), | |
| 491 void* context) { | |
| 492 SkGlyphCache_Globals& globals = getGlobals(); | |
| 493 SkAutoMutexAcquire ac(globals.fMutex); | |
| 494 SkGlyphCache* cache; | |
| 495 | |
| 496 globals.validate(); | |
| 497 | |
| 498 for (cache = globals.internalGetHead(); cache != NULL; cache = cache->fNext)
{ | |
| 499 if (proc(cache, context)) { | |
| 500 break; | |
| 501 } | |
| 502 } | |
| 503 | |
| 504 globals.validate(); | |
| 505 } | |
| 506 | |
| 507 /* This guy calls the visitor from within the mutext lock, so the visitor | 490 /* This guy calls the visitor from within the mutext lock, so the visitor |
| 508 cannot: | 491 cannot: |
| 509 - take too much time | 492 - take too much time |
| 510 - try to acquire the mutext again | 493 - try to acquire the mutext again |
| 511 - call a fontscaler (which might call into the cache) | 494 - call a fontscaler (which might call into the cache) |
| 512 */ | 495 */ |
| 513 SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface, | 496 SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface, |
| 514 const SkDescriptor* desc, | 497 const SkDescriptor* desc, |
| 515 bool (*proc)(const SkGlyphCache*, void*), | 498 bool (*proc)(const SkGlyphCache*, void*), |
| 516 void* context) { | 499 void* context) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 return tls ? tls->getCacheSizeLimit() : 0; | 740 return tls ? tls->getCacheSizeLimit() : 0; |
| 758 } | 741 } |
| 759 | 742 |
| 760 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { | 743 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { |
| 761 if (0 == bytes) { | 744 if (0 == bytes) { |
| 762 SkGlyphCache_Globals::DeleteTLS(); | 745 SkGlyphCache_Globals::DeleteTLS(); |
| 763 } else { | 746 } else { |
| 764 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); | 747 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); |
| 765 } | 748 } |
| 766 } | 749 } |
| OLD | NEW |