Bug 1250787 - ensure that subpixel text is disabled for Skia's Cairo font host so that font rendering matches our font metrics. r=mchang
authorLee Salzman <lsalzman@mozilla.com>
Wed, 24 Feb 2016 20:35:38 -0500
changeset 321863 2af0755ca43865a02976427f53d5c2835e8ccdce
parent 321862 d429066578eb056ca2b9cd110cca8b63490c4d9b
child 321864 7989e73486d116c5ccbecffa8bec41ad252f53f8
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1250787
milestone47.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 1250787 - ensure that subpixel text is disabled for Skia's Cairo font host so that font rendering matches our font metrics. r=mchang
gfx/2d/DrawTargetSkia.cpp
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -585,36 +585,40 @@ DrawTargetSkia::FillGlyphs(ScaledFont *a
 
   AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
   paint.mPaint.setTypeface(skiaFont->GetSkTypeface());
   paint.mPaint.setTextSize(SkFloatToScalar(skiaFont->mSize));
   paint.mPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
 
   bool shouldLCDRenderText = ShouldLCDRenderText(aFont->GetType(), aOptions.mAntialiasMode);
   paint.mPaint.setLCDRenderText(shouldLCDRenderText);
-  paint.mPaint.setSubpixelText(true);
 
   if (aRenderingOptions && aRenderingOptions->GetType() == FontType::CAIRO) {
     const GlyphRenderingOptionsCairo* cairoOptions =
       static_cast<const GlyphRenderingOptionsCairo*>(aRenderingOptions);
 
     paint.mPaint.setHinting(GfxHintingToSkiaHinting(cairoOptions->GetHinting()));
 
     if (cairoOptions->GetAutoHinting()) {
       paint.mPaint.setAutohinted(true);
     }
 
     if (cairoOptions->GetAntialiasMode() == AntialiasMode::NONE) {
       paint.mPaint.setAntiAlias(false);
     }
-  } else if (aFont->GetType() == FontType::MAC && shouldLCDRenderText) {
-    // SkFontHost_mac only supports subpixel antialiasing when hinting is turned off.
-    paint.mPaint.setHinting(SkPaint::kNo_Hinting);
   } else {
-    paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
+    // SkFontHost_cairo does not support subpixel text, so only enable it for other font hosts.
+    paint.mPaint.setSubpixelText(true);
+
+    if (aFont->GetType() == FontType::MAC && shouldLCDRenderText) {
+      // SkFontHost_mac only supports subpixel antialiasing when hinting is turned off.
+      paint.mPaint.setHinting(SkPaint::kNo_Hinting);
+    } else {
+      paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
+    }
   }
 
   std::vector<uint16_t> indices;
   std::vector<SkPoint> offsets;
   indices.resize(aBuffer.mNumGlyphs);
   offsets.resize(aBuffer.mNumGlyphs);
 
   for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {