Bug 1318769 - make SkFontHost_cairo match cairo-ft's handling of FcPattern embeddedbitmap option. r=jfkthame a=jcristau
authorLee Salzman <lsalzman@mozilla.com>
Sun, 01 Jan 2017 09:25:15 -0500
changeset 353355 50730a14e12aa217baa8612ea740654f39d11a63
parent 353354 c827f0883eef1c6c37c54aaf2a425e8a165de988
child 353356 601f420a4734ce8327ad334198d3f4c9ae805fef
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame, jcristau
bugs1318769
milestone52.0a2
Bug 1318769 - make SkFontHost_cairo match cairo-ft's handling of FcPattern embeddedbitmap option. r=jfkthame a=jcristau MozReview-Commit-ID: BSDuwZfKi1a
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
@@ -327,16 +327,18 @@ SkScalerContext_CairoFT::SkScalerContext
     cairo_matrix_init_identity(&ctMatrix);
 
     cairo_font_options_t *fontOptions = cairo_font_options_create();
     fScaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctMatrix, fontOptions);
     cairo_font_options_destroy(fontOptions);
 
     computeShapeMatrix(matrix);
 
+    fRec.fFlags |= SkScalerContext::kEmbeddedBitmapText_Flag;
+
 #ifdef CAIRO_HAS_FC_FONT
     resolvePattern(pattern);
 #endif
 
     FT_Int32 loadFlags = FT_LOAD_DEFAULT;
 
     if (SkMask::kBW_Format == fRec.fMaskFormat) {
         if (fRec.getHinting() == SkPaint::kNo_Hinting) {
@@ -409,28 +411,33 @@ SkScalerContext_CairoFT::~SkScalerContex
 #ifdef CAIRO_HAS_FC_FONT
 void SkScalerContext_CairoFT::parsePattern(FcPattern* pattern)
 {
     FcBool antialias, autohint, bitmap, embolden, hinting, vertical;
 
     if (FcPatternGetBool(pattern, FC_AUTOHINT, 0, &autohint) == FcResultMatch && autohint) {
         fRec.fFlags |= SkScalerContext::kForceAutohinting_Flag;
     }
-    if (FcPatternGetBool(pattern, FC_EMBEDDED_BITMAP, 0, &bitmap) == FcResultMatch && bitmap) {
-        fRec.fFlags |= SkScalerContext::kEmbeddedBitmapText_Flag;
-    }
     if (FcPatternGetBool(pattern, FC_EMBOLDEN, 0, &embolden) == FcResultMatch && embolden) {
         fRec.fFlags |= SkScalerContext::kEmbolden_Flag;
     }
     if (FcPatternGetBool(pattern, FC_VERTICAL_LAYOUT, 0, &vertical) == FcResultMatch && vertical) {
         fRec.fFlags |= SkScalerContext::kVertical_Flag;
     }
 
-    if (fRec.fMaskFormat != SkMask::kBW_Format &&
-        (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &antialias) != FcResultMatch || antialias)) {
+    // Match cairo-ft's handling of embeddedbitmap:
+    // If AA is explicitly disabled, leave bitmaps enabled.
+    // Otherwise, disable embedded bitmaps unless explicitly enabled.
+    if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &antialias) == FcResultMatch && !antialias) {
+        fRec.fMaskFormat = SkMask::kBW_Format;
+    } else if (FcPatternGetBool(pattern, FC_EMBEDDED_BITMAP, 0, &bitmap) != FcResultMatch || !bitmap) {
+        fRec.fFlags &= ~SkScalerContext::kEmbeddedBitmapText_Flag;
+    }
+
+    if (fRec.fMaskFormat != SkMask::kBW_Format) {
         int rgba;
         if (!isLCD(fRec) ||
             FcPatternGetInteger(pattern, FC_RGBA, 0, &rgba) != FcResultMatch) {
             rgba = FC_RGBA_UNKNOWN;
         }
         switch (rgba) {
         case FC_RGBA_RGB:
             break;
@@ -465,18 +472,16 @@ void SkScalerContext_CairoFT::parsePatte
                 fLcdFilter = FT_LCD_FILTER_LIGHT;
                 break;
             case FC_LCD_LEGACY:
             default:
                 fLcdFilter = FT_LCD_FILTER_LEGACY;
                 break;
             }
         }
-    } else {
-        fRec.fMaskFormat = SkMask::kBW_Format;
     }
 
     if (fRec.getHinting() != SkPaint::kNo_Hinting) {
         // Hinting was requested, so check if the fontconfig pattern needs to override it.
         // If hinting is either explicitly enabled by fontconfig or not configured, try to
         // parse the hint style. Otherwise, ensure hinting is disabled.
         int hintstyle;
         if (FcPatternGetBool(pattern, FC_HINTING, 0, &hinting) != FcResultMatch || hinting) {