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

Side by Side Diff: src/core/SkGlyphCache.cpp

Issue 18484005: allow createScalerContext to return null, and then have the GDI backend trigger that if we fail to … (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « include/core/SkTypeface.h ('k') | src/core/SkScalerContext.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 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
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
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 }
OLDNEW
« no previous file with comments | « include/core/SkTypeface.h ('k') | src/core/SkScalerContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698