X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2Fskia%2Fsrc%2Fports%2FSkFontHost_FreeType.cpp;h=cb7ce8028dccd4e92d81b1e8ce63fc3b08c4b438;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=79520a8a035e1a28c7ec58ed7265398a913f9785;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/skia/src/ports/SkFontHost_FreeType.cpp b/src/third_party/skia/src/ports/SkFontHost_FreeType.cpp index 79520a8..cb7ce80 100644 --- a/src/third_party/skia/src/ports/SkFontHost_FreeType.cpp +++ b/src/third_party/skia/src/ports/SkFontHost_FreeType.cpp @@ -1,4 +1,4 @@ - + /* * Copyright 2006 The Android Open Source Project * @@ -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,17 +161,22 @@ static bool InitFreetype() { return true; } -// Lazy, once, wrapper to ask the FreeType Library if it can support LCD text -static bool is_lcd_supported() { +// Called while holding gFTMutex. +static void determine_lcd_support(bool* lcdSupported) { if (!gLCDSupportValid) { - SkAutoMutexAcquire ac(gFTMutex); - - if (!gLCDSupportValid) { - InitFreetype(); - FT_Done_FreeType(gFTLibrary); - } + // This will determine LCD support as a side effect. + InitFreetype(); + FT_Done_FreeType(gFTLibrary); } - return gLCDSupport; + SkASSERT(gLCDSupportValid); + *lcdSupported = gLCDSupport; +} + +// Lazy, once, wrapper to ask the FreeType Library if it can support LCD text +static bool is_lcd_supported() { + static bool lcdSupported = false; + SkOnce(&gLCDSupportValid, &gFTMutex, determine_lcd_support, &lcdSupported); + return lcdSupported; } class SkScalerContext_FreeType : public SkScalerContext_FreeType_Base {