| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 /* Release the mutex now, before we create a new entry (which might have | 587 /* Release the mutex now, before we create a new entry (which might have |
| 588 side-effects like trying to access the cache/mutex (yikes!) | 588 side-effects like trying to access the cache/mutex (yikes!) |
| 589 */ | 589 */ |
| 590 ac.release(); // release the mutex now | 590 ac.release(); // release the mutex now |
| 591 insideMutex = false; // can't use globals anymore | 591 insideMutex = false; // can't use globals anymore |
| 592 | 592 |
| 593 // Check if we can create a scaler-context before creating the glyphcache. | 593 // Check if we can create a scaler-context before creating the glyphcache. |
| 594 // If not, we may have exhausted OS/font resources, so try purging the | 594 // If not, we may have exhausted OS/font resources, so try purging the |
| 595 // cache once and try again. | 595 // cache once and try again. |
| 596 { | 596 { |
| 597 SkScalerContext* ctx = typeface->createScalerContext(desc); | 597 // pass true the first time, to notice if the scalercontext failed, |
| 598 // so we can try the purge. |
| 599 SkScalerContext* ctx = typeface->createScalerContext(desc, true); |
| 598 if (!ctx) { | 600 if (!ctx) { |
| 599 getSharedGlobals().purgeAll(); | 601 getSharedGlobals().purgeAll(); |
| 600 ctx = typeface->createScalerContext(desc); | 602 ctx = typeface->createScalerContext(desc, false); |
| 601 if (!ctx) { | 603 SkASSERT(ctx); |
| 602 sk_throw(); | |
| 603 } | |
| 604 } | 604 } |
| 605 cache = SkNEW_ARGS(SkGlyphCache, (typeface, desc, ctx)); | 605 cache = SkNEW_ARGS(SkGlyphCache, (typeface, desc, ctx)); |
| 606 } | 606 } |
| 607 | 607 |
| 608 FOUND_IT: | 608 FOUND_IT: |
| 609 | 609 |
| 610 AutoValidate av(cache); | 610 AutoValidate av(cache); |
| 611 | 611 |
| 612 if (proc(cache, context)) { // stay detached | 612 if (proc(cache, context)) { // stay detached |
| 613 if (insideMutex) { | 613 if (insideMutex) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 return tls ? tls->getFontCacheLimit() : 0; | 779 return tls ? tls->getFontCacheLimit() : 0; |
| 780 } | 780 } |
| 781 | 781 |
| 782 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { | 782 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { |
| 783 if (0 == bytes) { | 783 if (0 == bytes) { |
| 784 SkGlyphCache_Globals::DeleteTLS(); | 784 SkGlyphCache_Globals::DeleteTLS(); |
| 785 } else { | 785 } else { |
| 786 SkGlyphCache_Globals::GetTLS().setFontCacheLimit(bytes); | 786 SkGlyphCache_Globals::GetTLS().setFontCacheLimit(bytes); |
| 787 } | 787 } |
| 788 } | 788 } |
| OLD | NEW |