-
+
/*
* Copyright 2006 The Android Open Source Project
*
* found in the LICENSE file.
*/
+#include "SkAdvancedTypefaceMetrics.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkMask.h"
#include "SkMaskGamma.h"
#include "SkOTUtils.h"
-#include "SkAdvancedTypefaceMetrics.h"
+#include "SkOnce.h"
#include "SkScalerContext.h"
#include "SkStream.h"
#include "SkString.h"
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 {