diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-17 15:49:36 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-17 15:49:36 +0000 |
commit | fb2fdcca206fbcac6254a9524c2d06dc98dd5421 (patch) | |
tree | e1708eadb20ce27eba4779635f61feeff17d8242 | |
parent | f6fc3fcadd343fad8d89d34749146d7e3c43d95b (diff) |
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
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
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; |