Bug 1267363. Disable hinting on osx fonts only if we have expclity grayscale AA. r=mstange a=ritu
authorMason Chang <mchang@mozilla.com>
Tue, 26 Apr 2016 13:14:15 -0400
changeset 332686 073d760767b48085128d6c82eba60d2f80657aaa
parent 332685 bbb254427173b0f778f61cef31fbcad18b36d4bf
child 332687 469db9271b529794f485204e87407de39e147b62
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, ritu
bugs1267363
milestone48.0a2
Bug 1267363. Disable hinting on osx fonts only if we have expclity grayscale AA. r=mstange a=ritu
gfx/2d/DrawTargetSkia.cpp
layout/reftests/canvas/reftest.list
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -632,20 +632,29 @@ DrawTargetSkia::FillGlyphs(ScaledFont *a
 
     if (cairoOptions->GetAntialiasMode() == AntialiasMode::NONE) {
       paint.mPaint.setAntiAlias(false);
     }
   } else {
     // SkFontHost_cairo does not support subpixel text, so only enable it for other font hosts.
     paint.mPaint.setSubpixelText(true);
 
-    if (aFont->GetType() == FontType::MAC) {
+    if (aFont->GetType() == FontType::MAC &&
+       (shouldLCDRenderText || aOptions.mAntialiasMode == AntialiasMode::GRAY)) {
+      // SkFontHost_mac only enables CG Font Smoothing if hinting is disabled.
+      // CG Font Smoothing normally enables subpixel AA in CG, but Skia supports
+      // font smoothing with grayscale AA.
       // SkFontHost_mac only supports subpixel antialiasing when hinting is turned off.
-      // For grayscale AA, we want to disable font smoothing as the only time we should
-      // use grayscale AA is with explicit -moz-osx-font-smoothing
+      // We can get grayscale AA if we have -moz-osx-font-smoothing: grayscale
+      // explicitly enabled or for transparent surfaces.
+      // If we have AA grayscale explicit through the draw options,
+      // then we want to disable font smoothing.
+      // If we have a transparent surface, shouldLCDRenderText will be false. But unless
+      // grayscale font smoothing is explicitly requested, we still want Skia to use
+      // CG Font smoothing.
       paint.mPaint.setHinting(SkPaint::kNo_Hinting);
     } else {
       paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
     }
   }
 
   std::vector<uint16_t> indices;
   std::vector<SkPoint> offsets;
--- a/layout/reftests/canvas/reftest.list
+++ b/layout/reftests/canvas/reftest.list
@@ -23,17 +23,17 @@ random-if(cocoaWidget) == subpixel-1.htm
 != text-rtl-left.html text-rtl-right.html
 
 == text-ltr-left.html text-rtl-left.html
 
 == text-ltr-alignment-test.html text-ltr-alignment-ref.html
 == text-rtl-alignment-test.html text-rtl-alignment-ref.html
 
 fuzzy-if((B2G||Mulet)&&azureSkiaGL,1,256) == text-horzline-with-bottom.html text-horzline.html # Initial mulet triage: parity with B2G/B2G Desktop
-fuzzy-if((B2G||Mulet)&&azureSkiaGL,1,256) == text-horzline-with-top.html text-horzline.html # Initial mulet triage: parity with B2G/B2G Desktop
+fuzzy-if((B2G||Mulet)&&azureSkiaGL,1,256) fails-if(azureSkia&&OSX>=1008) == text-horzline-with-top.html text-horzline.html # Initial mulet triage: parity with B2G/B2G Desktop
 
 != text-big-stroke.html text-blank.html
 != text-big-stroke.html text-big-fill.html
 
 == text-context-state-test.html text-context-state-ref.html
 == text-font-inherit.html text-big-fill.html
 == text-space-replace-test.html text-space-replace-ref.html