Bug 1318769 - make SkFontHost_cairo match cairo-ft's handling of FcPattern embeddedbitmap option. r=jfkthame
authorLee Salzman <lsalzman@mozilla.com>
Sun, 01 Jan 2017 09:25:15 -0500
changeset 327754 277613c558063693692b27a4c052328d2c703971
parent 327753 c32cbdff356e009c58fe6d30344997090812a6cf
child 327762 31ffcb82ced81bb75faa800d2b7e883a3761a03b
push id85266
push userlsalzman@mozilla.com
push dateSun, 01 Jan 2017 14:25:27 +0000
treeherdermozilla-inbound@277613c55806 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1318769
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1318769 - make SkFontHost_cairo match cairo-ft's handling of FcPattern embeddedbitmap option. r=jfkthame 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) {