| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2006 The Android Open Source Project | 2  * Copyright 2006 The Android Open Source Project | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #include "SkGlyphCache.h" | 8 #include "SkGlyphCache.h" | 
| 9 #include "SkGlyphCache_Globals.h" | 9 #include "SkGlyphCache_Globals.h" | 
| 10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" | 
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 501     this->internalPurge(fTotalMemoryUsed); | 501     this->internalPurge(fTotalMemoryUsed); | 
| 502 } | 502 } | 
| 503 | 503 | 
| 504 /*  This guy calls the visitor from within the mutext lock, so the visitor | 504 /*  This guy calls the visitor from within the mutext lock, so the visitor | 
| 505     cannot: | 505     cannot: | 
| 506     - take too much time | 506     - take too much time | 
| 507     - try to acquire the mutext again | 507     - try to acquire the mutext again | 
| 508     - call a fontscaler (which might call into the cache) | 508     - call a fontscaler (which might call into the cache) | 
| 509 */ | 509 */ | 
| 510 SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface, | 510 SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface, | 
| 511                               const SkDescriptor* desc, | 511                                        const SkScalerContextEffects& effects, | 
| 512                               bool (*proc)(const SkGlyphCache*, void*), | 512                                        const SkDescriptor* desc, | 
| 513                               void* context) { | 513                                        bool (*proc)(const SkGlyphCache*, void*), | 
|  | 514                                        void* context) { | 
| 514     if (!typeface) { | 515     if (!typeface) { | 
| 515         typeface = SkTypeface::GetDefaultTypeface(); | 516         typeface = SkTypeface::GetDefaultTypeface(); | 
| 516     } | 517     } | 
| 517     SkASSERT(desc); | 518     SkASSERT(desc); | 
| 518 | 519 | 
| 519     SkGlyphCache_Globals& globals = get_globals(); | 520     SkGlyphCache_Globals& globals = get_globals(); | 
| 520     SkGlyphCache*         cache; | 521     SkGlyphCache*         cache; | 
| 521 | 522 | 
| 522     { | 523     { | 
| 523         Exclusive ac(globals.fLock); | 524         Exclusive ac(globals.fLock); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 535             } | 536             } | 
| 536         } | 537         } | 
| 537     } | 538     } | 
| 538 | 539 | 
| 539     // Check if we can create a scaler-context before creating the glyphcache. | 540     // Check if we can create a scaler-context before creating the glyphcache. | 
| 540     // If not, we may have exhausted OS/font resources, so try purging the | 541     // If not, we may have exhausted OS/font resources, so try purging the | 
| 541     // cache once and try again. | 542     // cache once and try again. | 
| 542     { | 543     { | 
| 543         // pass true the first time, to notice if the scalercontext failed, | 544         // pass true the first time, to notice if the scalercontext failed, | 
| 544         // so we can try the purge. | 545         // so we can try the purge. | 
| 545         SkScalerContext* ctx = typeface->createScalerContext(desc, true); | 546         SkScalerContext* ctx = typeface->createScalerContext(effects, desc, true
     ); | 
| 546         if (!ctx) { | 547         if (!ctx) { | 
| 547             get_globals().purgeAll(); | 548             get_globals().purgeAll(); | 
| 548             ctx = typeface->createScalerContext(desc, false); | 549             ctx = typeface->createScalerContext(effects, desc, false); | 
| 549             SkASSERT(ctx); | 550             SkASSERT(ctx); | 
| 550         } | 551         } | 
| 551         cache = new SkGlyphCache(typeface, desc, ctx); | 552         cache = new SkGlyphCache(typeface, desc, ctx); | 
| 552     } | 553     } | 
| 553 | 554 | 
| 554     AutoValidate av(cache); | 555     AutoValidate av(cache); | 
| 555 | 556 | 
| 556     if (!proc(cache, context)) {   // need to reattach | 557     if (!proc(cache, context)) {   // need to reattach | 
| 557         globals.attachCacheToHead(cache); | 558         globals.attachCacheToHead(cache); | 
| 558         cache = nullptr; | 559         cache = nullptr; | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 813 } | 814 } | 
| 814 | 815 | 
| 815 void SkGraphics::PurgeFontCache() { | 816 void SkGraphics::PurgeFontCache() { | 
| 816     get_globals().purgeAll(); | 817     get_globals().purgeAll(); | 
| 817     SkTypefaceCache::PurgeAll(); | 818     SkTypefaceCache::PurgeAll(); | 
| 818 } | 819 } | 
| 819 | 820 | 
| 820 // TODO(herb): clean up TLS apis. | 821 // TODO(herb): clean up TLS apis. | 
| 821 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } | 822 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } | 
| 822 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } | 823 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } | 
| OLD | NEW | 
|---|