Bug 1509423 - Disable the gfxCoreText backend and use native HarfBuzz shaping for AAT fonts. r=jrmuizel
authorJonathan Kew <jkew@mozilla.com>
Mon, 20 May 2019 14:29:15 +0000
changeset 474525 7bab77eee3335bab7224c12f05a14b46785742b8
parent 474524 c77c46ac90a55891e1f67ff18fb16029883cc0e6
child 474526 6df30b02e311b72fcee1c45161eec060bc3f9ce9
push id36042
push userdvarga@mozilla.com
push dateTue, 21 May 2019 04:19:40 +0000
treeherdermozilla-central@ca560ff55451 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1509423
milestone69.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 1509423 - Disable the gfxCoreText backend and use native HarfBuzz shaping for AAT fonts. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D31094
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPrefs.h
modules/libpref/init/all.js
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -11,16 +11,17 @@
 
 #include "gfxCoreTextShaper.h"
 #include <algorithm>
 #include "gfxPlatformMac.h"
 #include "gfxContext.h"
 #include "gfxFontUtils.h"
 #include "gfxMacPlatformFontList.h"
 #include "gfxFontConstants.h"
+#include "gfxPrefs.h"
 #include "gfxTextRun.h"
 #include "nsCocoaFeatures.h"
 
 #include "cairo-quartz.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
@@ -194,17 +195,18 @@ bool gfxMacFont::ShapeText(DrawTarget* a
   if (!mIsValid) {
     NS_WARNING("invalid font! expect incorrect text rendering");
     return false;
   }
 
   // Currently, we don't support vertical shaping via CoreText,
   // so we ignore RequiresAATLayout if vertical is requested.
   auto macFontEntry = static_cast<MacOSFontEntry*>(GetFontEntry());
-  if (macFontEntry->RequiresAATLayout() && !aVertical) {
+  if (macFontEntry->RequiresAATLayout() && !aVertical &&
+      gfxPrefs::CoreTextEnabled()) {
     if (!mCoreTextShaper) {
       mCoreTextShaper = MakeUnique<gfxCoreTextShaper>(this);
     }
     if (mCoreTextShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
                                    aScript, aVertical, aRounding,
                                    aShapedText)) {
       PostShapingFixup(aDrawTarget, aText, aOffset, aLength, aVertical,
                        aShapedText);
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -404,16 +404,19 @@ NS_IMPL_ISUPPORTS(SRGBOverrideObserver, 
   "gfx.font_rendering.fallback.always_use_cmaps"
 
 #define GFX_PREF_OPENTYPE_SVG "gfx.font_rendering.opentype_svg.enabled"
 
 #define GFX_PREF_WORD_CACHE_CHARLIMIT "gfx.font_rendering.wordcache.charlimit"
 #define GFX_PREF_WORD_CACHE_MAXENTRIES "gfx.font_rendering.wordcache.maxentries"
 
 #define GFX_PREF_GRAPHITE_SHAPING "gfx.font_rendering.graphite.enabled"
+#if defined(XP_MACOSX)
+#define GFX_PREF_CORETEXT_SHAPING "gfx.font_rendering.coretext.enabled"
+#endif
 
 #define BIDI_NUMERAL_PREF "bidi.numeral"
 
 #define GFX_PREF_CMS_FORCE_SRGB "gfx.color_management.force_srgb"
 
 #define FONT_VARIATIONS_PREF "layout.css.font-variations.enabled"
 
 NS_IMETHODIMP
@@ -2211,16 +2214,20 @@ void gfxPlatform::FontsPrefsChanged(cons
     mWordCacheCharLimit = UNINITIALIZED_VALUE;
     FlushFontAndWordCaches();
   } else if (!strcmp(GFX_PREF_WORD_CACHE_MAXENTRIES, aPref)) {
     mWordCacheMaxEntries = UNINITIALIZED_VALUE;
     FlushFontAndWordCaches();
   } else if (!strcmp(GFX_PREF_GRAPHITE_SHAPING, aPref)) {
     mGraphiteShapingEnabled = UNINITIALIZED_VALUE;
     FlushFontAndWordCaches();
+#if defined(XP_MACOSX)
+  } else if (!strcmp(GFX_PREF_CORETEXT_SHAPING, aPref)) {
+    FlushFontAndWordCaches();
+#endif
   } else if (!strcmp(BIDI_NUMERAL_PREF, aPref)) {
     mBidiNumeralOption = UNINITIALIZED_VALUE;
   } else if (!strcmp(GFX_PREF_OPENTYPE_SVG, aPref)) {
     mOpenTypeSVGEnabled = UNINITIALIZED_VALUE;
     gfxFontCache::GetCache()->AgeAllGenerations();
     gfxFontCache::GetCache()->NotifyGlyphsChanged();
   }
 }
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -493,16 +493,19 @@ class gfxPrefs final {
   DECL_GFX_PREF(Once, "gfx.direct3d11.break-on-error",         Direct3D11BreakOnError, bool, false);
   DECL_GFX_PREF(Once, "gfx.direct3d11.sleep-on-create-device", Direct3D11SleepOnCreateDevice, int32_t, 0);
   DECL_GFX_PREF(Live, "gfx.downloadable_fonts.keep_color_bitmaps", KeepColorBitmaps, bool, false);
   DECL_GFX_PREF(Live, "gfx.downloadable_fonts.validate_variation_tables", ValidateVariationTables, bool, true);
   DECL_GFX_PREF(Live, "gfx.downloadable_fonts.otl_validation", ValidateOTLTables, bool, true);
   DECL_GFX_PREF(Live, "gfx.draw-color-bars",                   CompositorDrawColorBars, bool, false);
   DECL_GFX_PREF(Once, "gfx.e10s.hide-plugins-for-scroll",      HidePluginsForScroll, bool, true);
   DECL_GFX_PREF(Once, "gfx.e10s.font-list.shared",             SharedFontList, bool, false);
+#if defined(XP_MACOSX)
+  DECL_GFX_PREF(Live, "gfx.font_rendering.coretext.enabled",   CoreTextEnabled, bool, false);
+#endif
   DECL_GFX_PREF(Live, "gfx.layerscope.enabled",                LayerScopeEnabled, bool, false);
   DECL_GFX_PREF(Live, "gfx.layerscope.port",                   LayerScopePort, int32_t, 23456);
   // Note that        "gfx.logging.level" is defined in Logging.h.
   DECL_GFX_PREF(Live, "gfx.logging.level",                     GfxLoggingLevel, int32_t, mozilla::gfx::LOG_DEFAULT);
   DECL_GFX_PREF(Once, "gfx.logging.crash.length",              GfxLoggingCrashLength, uint32_t, 16);
   DECL_GFX_PREF(Live, "gfx.logging.painted-pixel-count.enabled",GfxLoggingPaintedPixelCountEnabled, bool, false);
   // The maximums here are quite conservative, we can tighten them if problems show up.
   DECL_GFX_PREF(Once, "gfx.logging.texture-usage.enabled",     GfxLoggingTextureUsageEnabled, bool, false);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -848,16 +848,21 @@ pref("gfx.font_rendering.fallback.always
 // cache shaped word results
 pref("gfx.font_rendering.wordcache.charlimit", 32);
 
 // cache shaped word results
 pref("gfx.font_rendering.wordcache.maxentries", 10000);
 
 pref("gfx.font_rendering.graphite.enabled", true);
 
+#ifdef XP_MACOSX
+// Set to true to revert from HarfBuzz AAT shaping to the old Core Text backend
+pref("gfx.font_rendering.coretext.enabled", false);
+#endif
+
 #ifdef XP_WIN
 pref("gfx.font_rendering.directwrite.use_gdi_table_loading", true);
 #endif
 
 // Disable antialiasing of Ahem, for use in tests
 pref("gfx.font_ahem_antialias_none", false);
 
 #ifdef XP_WIN