From d4742fa550bafce5225cd267437eadef177c5945 Mon Sep 17 00:00:00 2001 From: bungeman Date: Wed, 21 Jan 2015 11:19:22 -0800 Subject: [PATCH] Reduce overhead of SkFontHost_FreeType::onFilterRec. The current code is using AutoFTAccess just to access the FT_Library. However, it does not need to resolve the FT_Face, just the FT_Library. This unecessary overhead and is removed by this change. The longer term solution is for SkFontMgr to initialize FreeType. Review URL: https://codereview.chromium.org/835583003 --- src/ports/SkFontHost_FreeType.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 459abbc..167c38b 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -697,11 +697,15 @@ void SkTypeface_FreeType::onFilterRec(SkScalerContextRec* rec) const { rec->fTextSize = SkIntToScalar(1 << 14); } - AutoFTAccess fta(this); - if (!gFTLibrary->isLCDSupported() && isLCD(*rec)) { - // If the runtime Freetype library doesn't support LCD mode, we disable - // it here. - rec->fMaskFormat = SkMask::kA8_Format; + { + // TODO: re-work so that FreeType is set-up and selected by the SkFontMgr. + SkAutoMutexAcquire ama(gFTMutex); + ref_ft_library(); + if (!gFTLibrary->isLCDSupported() && isLCD(*rec)) { + // If the runtime Freetype library doesn't support LCD, disable it here. + rec->fMaskFormat = SkMask::kA8_Format; + } + unref_ft_library(); } SkPaint::Hinting h = rec->getHinting(); -- 2.7.4