Bug 1277404. Set font gamma for windows fonts to 1.8 and force skia to use cleartype fonts on non-opaque surfaces. r=lsalzman
authorMason Chang <mchang@mozilla.com>
Mon, 06 Jun 2016 10:00:33 -0700
changeset 325793 0ae7b65e1c12135b5452b635608f311d5dac99d9
parent 325792 7a197b8bd00acc1e8baa6e9b9f93b2ee2809783e
child 325794 4264b01fd313c2709d2d70865c6fd7e31924df71
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1277404
milestone49.0a1
Bug 1277404. Set font gamma for windows fonts to 1.8 and force skia to use cleartype fonts on non-opaque surfaces. r=lsalzman
gfx/2d/DrawTargetSkia.cpp
gfx/skia/generate_mozbuild.py
gfx/skia/moz.build
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -1067,16 +1067,24 @@ DrawTargetSkia::FillGlyphs(ScaledFont *a
       // To accomplish this we have to explicitly disable hinting,
       // and disable LCDRenderText.
       paint.mPaint.setHinting(SkPaint::kNo_Hinting);
     } else {
       paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
     }
   }
 
+  if (!shouldLCDRenderText && aFont->GetType() == FontType::GDI) {
+    // If we have non LCD GDI text, Cairo currently always uses cleartype fonts and
+    // converts them to grayscale. Force Skia to do the same, otherwise we use
+    // GDI fonts with the ANTIALIASED_QUALITY which is generally bolder than
+    // Cleartype fonts.
+    paint.mPaint.setFlags(paint.mPaint.getFlags() | SkPaint::kGenA8FromLCD_Flag);
+  }
+
   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++) {
     indices[i] = aBuffer.mGlyphs[i].mIndex;
     offsets[i].fX = SkFloatToScalar(aBuffer.mGlyphs[i].mPosition.x);
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -68,17 +68,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in {
     'gonk',
     'qt',
   }:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     DEFINES['UNICODE'] = True
     DEFINES['_UNICODE'] = True
-    DEFINES['SK_FONT_HOST_USE_SYSTEM_SETTINGS'] = 1
+    # These are the usual dwrite default rendering param values
+    DEFINES['SK_GAMMA_EXPONENT'] = 1.8
+    DEFINES['SK_GAMMA_CONTRAST'] = 0.5
     UNIFIED_SOURCES += [
         'skia/src/fonts/SkFontMgr_indirect.cpp',
         'skia/src/fonts/SkRemotableFontMgr.cpp',
     ]
 
 # We should autogenerate these SSE related flags.
 
 if CONFIG['_MSC_VER']:
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -604,17 +604,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in {
     'gonk',
     'qt',
   }:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     DEFINES['UNICODE'] = True
     DEFINES['_UNICODE'] = True
-    DEFINES['SK_FONT_HOST_USE_SYSTEM_SETTINGS'] = 1
+    # These are the usual dwrite default rendering param values
+    DEFINES['SK_GAMMA_EXPONENT'] = 1.8
+    DEFINES['SK_GAMMA_CONTRAST'] = 0.5
     UNIFIED_SOURCES += [
         'skia/src/fonts/SkFontMgr_indirect.cpp',
         'skia/src/fonts/SkRemotableFontMgr.cpp',
     ]
 
 # We should autogenerate these SSE related flags.
 
 if CONFIG['_MSC_VER']: