Bug 1294207 - Detect if FreeType supports lcd filtering in SkFontHost_cairo. r=gw280, a=ritu
authorLee Salzman <lsalzman@mozilla.com>
Wed, 10 Aug 2016 18:23:34 -0400
changeset 347726 2893f7dad7dfc81aa7d9771e117008b0e3cdafd6
parent 347725 3784a68ebabe70682746270b4cd7b705c9a60694
child 347727 a03522ef5152fee0dffb5bc3c4416cd166e17d7a
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw280, ritu
bugs1294207
milestone50.0a2
Bug 1294207 - Detect if FreeType supports lcd filtering in SkFontHost_cairo. r=gw280, a=ritu MozReview-Commit-ID: AZkcZG4PegJ
gfx/skia/skia/src/ports/SkFontHost_cairo.cpp
--- a/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp
+++ b/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp
@@ -62,16 +62,22 @@ void SkInitCairoFT(bool fontHintingEnabl
     gFontHintingEnabled = fontHintingEnabled;
 #if SK_CAN_USE_DLOPEN
     gSetLcdFilter = (FT_Error (*)(FT_Library, FT_LcdFilter))dlsym(RTLD_DEFAULT, "FT_Library_SetLcdFilter");
     gGlyphSlotEmbolden = (void (*)(FT_GlyphSlot))dlsym(RTLD_DEFAULT, "FT_GlyphSlot_Embolden");
 #else
     gSetLcdFilter = &FT_Library_SetLcdFilter;
     gGlyphSlotEmbolden = &FT_GlyphSlot_Embolden;
 #endif
+    // FT_Library_SetLcdFilter may be provided but have no effect if FreeType
+    // is built without FT_CONFIG_OPTION_SUBPIXEL_RENDERING.
+    if (gSetLcdFilter &&
+        gSetLcdFilter(nullptr, FT_LCD_FILTER_NONE) == FT_Err_Unimplemented_Feature) {
+        gSetLcdFilter = nullptr;
+    }
 }
 
 #ifndef CAIRO_HAS_FC_FONT
 typedef struct _FcPattern FcPattern;
 #endif
 
 template<> struct SkTUnref<FcPattern> {
     void operator()(FcPattern* pattern) {