Chromium Code Reviews| Index: src/ports/SkFontHost_FreeType.cpp |
| diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp |
| index fe32ebb42a7fe33c7e7758738cc40f26f7afaa8d..9aa9283f801f6bf477a96e50531669b608206241 100644 |
| --- a/src/ports/SkFontHost_FreeType.cpp |
| +++ b/src/ports/SkFontHost_FreeType.cpp |
| @@ -6,6 +6,7 @@ |
| * found in the LICENSE file. |
| */ |
| +#include "SkAdvancedTypefaceMetrics.h" |
| #include "SkBitmap.h" |
| #include "SkCanvas.h" |
| #include "SkColorPriv.h" |
| @@ -18,7 +19,7 @@ |
| #include "SkMask.h" |
| #include "SkMaskGamma.h" |
| #include "SkOTUtils.h" |
| -#include "SkAdvancedTypefaceMetrics.h" |
| +#include "SkOnce.h" |
| #include "SkScalerContext.h" |
| #include "SkStream.h" |
| #include "SkString.h" |
| @@ -160,16 +161,22 @@ static bool InitFreetype() { |
| return true; |
| } |
| +static void determine_lcd_support(int) { |
| + SkAutoMutexAcquire lock(gFTMutex); |
| + if (!gLCDSupportValid) { |
| + // This will determine LCD support as a side effect. |
| + InitFreetype(); |
| + FT_Done_FreeType(gFTLibrary); |
| + } |
| + SkASSERT(gLCDSupportValid); |
| +} |
| + |
| // Lazy, once, wrapper to ask the FreeType Library if it can support LCD text |
| static bool is_lcd_supported() { |
| - if (!gLCDSupportValid) { |
| - SkAutoMutexAcquire ac(gFTMutex); |
| + SK_DECLARE_STATIC_ONCE(once); |
| + SkOnce(&once, determine_lcd_support, 0); |
| - if (!gLCDSupportValid) { |
| - InitFreetype(); |
| - FT_Done_FreeType(gFTLibrary); |
| - } |
| - } |
| + SkAutoMutexAcquire lock(gFTMutex); |
|
bungeman-skia
2014/02/05 18:02:04
Why are we still taking this lock, just to return
mtklein
2014/02/05 18:10:26
You know, that's a thought provoking question.
I
|
| return gLCDSupport; |
| } |