aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_FreeType.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-17 15:49:36 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-17 15:49:36 +0000
commitfb2fdcca206fbcac6254a9524c2d06dc98dd5421 (patch)
treee1708eadb20ce27eba4779635f61feeff17d8242 /src/ports/SkFontHost_FreeType.cpp
parentf6fc3fcadd343fad8d89d34749146d7e3c43d95b (diff)
wrap check for gLCDSupported w/ a guard, so we don't have to grab the mutex
on every call to FilterRec. Review URL: https://codereview.appspot.com/6713052 git-svn-id: http://skia.googlecode.com/svn/trunk@5978 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkFontHost_FreeType.cpp')
-rw-r--r--src/ports/SkFontHost_FreeType.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index dc7666e723..529fd6019f 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -144,6 +144,19 @@ static bool InitFreetype() {
return true;
}
+// Lazy, once, wrapper to ask the FreeType Library if it can support LCD text
+static bool is_lcd_supported() {
+ if (!gLCDSupportValid) {
+ SkAutoMutexAcquire ac(gFTMutex);
+
+ if (!gLCDSupportValid) {
+ InitFreetype();
+ FT_Done_FreeType(gFTLibrary);
+ }
+ }
+ return gLCDSupport;
+}
+
class SkScalerContext_FreeType : public SkScalerContext_FreeType_Base {
public:
SkScalerContext_FreeType(const SkDescriptor* desc);
@@ -648,14 +661,7 @@ void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface*) {
rec->fTextSize = SkIntToScalar(1 << 14);
}
- SkAutoMutexAcquire ac(gFTMutex);
-
- if (!gLCDSupportValid) {
- InitFreetype();
- FT_Done_FreeType(gFTLibrary);
- }
-
- if (!gLCDSupport && isLCD(*rec)) {
+ if (!is_lcd_supported() && isLCD(*rec)) {
// If the runtime Freetype library doesn't support LCD mode, we disable
// it here.
rec->fMaskFormat = SkMask::kA8_Format;