From fb2fdcca206fbcac6254a9524c2d06dc98dd5421 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 17 Oct 2012 15:49:36 +0000 Subject: wrap check for gLCDSupported w/ a guard, so we don't have to grab the mutex on every call to FilterRec. Review URL: https://codereview.appspot.com/6713052 git-svn-id: http://skia.googlecode.com/svn/trunk@5978 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_FreeType.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/ports') diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index dc7666e723..529fd6019f 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -144,6 +144,19 @@ static bool InitFreetype() { return true; } +// Lazy, once, wrapper to ask the FreeType Library if it can support LCD text +static bool is_lcd_supported() { + if (!gLCDSupportValid) { + SkAutoMutexAcquire ac(gFTMutex); + + if (!gLCDSupportValid) { + InitFreetype(); + FT_Done_FreeType(gFTLibrary); + } + } + return gLCDSupport; +} + class SkScalerContext_FreeType : public SkScalerContext_FreeType_Base { public: SkScalerContext_FreeType(const SkDescriptor* desc); @@ -648,14 +661,7 @@ void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface*) { rec->fTextSize = SkIntToScalar(1 << 14); } - SkAutoMutexAcquire ac(gFTMutex); - - if (!gLCDSupportValid) { - InitFreetype(); - FT_Done_FreeType(gFTLibrary); - } - - if (!gLCDSupport && isLCD(*rec)) { + if (!is_lcd_supported() && isLCD(*rec)) { // If the runtime Freetype library doesn't support LCD mode, we disable // it here. rec->fMaskFormat = SkMask::kA8_Format; -- cgit v1.2.3