Reduce overhead of SkFontHost_FreeType::onFilterRec.
authorbungeman <bungeman@google.com>
Wed, 21 Jan 2015 19:19:22 +0000 (11:19 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 21 Jan 2015 19:19:22 +0000 (11:19 -0800)
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

index 459abbc..167c38b 100644 (file)
@@ -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();