Bug 1457154 - use fallback for color glyphs with transparency in WR. r=gankro
authorLee Salzman <lsalzman@mozilla.com>
Thu, 03 May 2018 22:53:55 -0400
changeset 416894 693b1b3389fb013086aa57b2ef6e230e8c4b39d5
parent 416893 9843544b2a42d8f4ce8c74245594178570aa3c3c
child 416895 1a0c61c2cf60a2c0e4bf7035effd467dd6185f65
push id33941
push usershindli@mozilla.com
push dateFri, 04 May 2018 08:36:02 +0000
treeherdermozilla-central@8994f35fe5fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgankro
bugs1457154
milestone61.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 1457154 - use fallback for color glyphs with transparency in WR. r=gankro MozReview-Commit-ID: 3Z00aJs26DV
gfx/thebes/gfxContext.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxTextRun.cpp
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -254,16 +254,25 @@ public:
     /**
      * Gets the current color.  It's returned in the device color space.
      * returns false if there is something other than a color
      *         set as the current source (pattern, surface, etc)
      */
     bool GetDeviceColor(mozilla::gfx::Color& aColorOut);
 
     /**
+     * Returns true if color is neither opaque nor transparent (i.e. alpha is not 0
+     * or 1), and false otherwise. If true, aColorOut is set on output.
+     */
+    bool HasNonOpaqueNonTransparentColor(mozilla::gfx::Color& aColorOut) {
+        return GetDeviceColor(aColorOut) &&
+               0.f < aColorOut.a && aColorOut.a < 1.f;
+    }
+
+    /**
      * Set a solid color in the sRGB color space to use for drawing.
      * If CMS is not enabled, the color is treated as a device-space color
      * and this call is identical to SetDeviceColor().
      */
     void SetColor(const mozilla::gfx::Color& aColor);
 
     /**
      * Uses a pattern for drawing.
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2163,26 +2163,28 @@ gfxFont::Draw(const gfxTextRun *aTextRun
     if (!fontParams.scaledFont) {
         return;
     }
 
     auto* textDrawer = aRunParams.context->GetTextDrawer();
 
     fontParams.needsOblique = IsSyntheticOblique();
     fontParams.haveSVGGlyphs = GetFontEntry()->TryGetSVGData(this);
-
-    if (fontParams.haveSVGGlyphs && textDrawer) {
-        textDrawer->FoundUnsupportedFeature();
-        return;
-    }
-
     fontParams.haveColorGlyphs = GetFontEntry()->TryGetColorGlyphs();
     fontParams.contextPaint = aRunParams.runContextPaint;
 
     if (textDrawer) {
+        Color color;
+        if (fontParams.haveSVGGlyphs ||
+            (fontParams.haveColorGlyphs &&
+             aRunParams.context->HasNonOpaqueNonTransparentColor(color))) {
+            textDrawer->FoundUnsupportedFeature();
+            return;
+        }
+
         fontParams.isVerticalFont = aRunParams.isVerticalRun;
     } else {
         fontParams.isVerticalFont =
             aOrientation == gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT;
     }
 
     gfxContextMatrixAutoSaveRestore matrixRestore;
     layout::TextDrawTarget::AutoRestoreWRGlyphFlags glyphFlagsRestore;
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -542,29 +542,16 @@ HasSyntheticBoldOrColor(const gfxTextRun
                 return true;
             }
 #endif
         }
     }
     return false;
 }
 
-// Returns true if color is neither opaque nor transparent (i.e. alpha is not 0
-// or 1), and false otherwise. If true, aCurrentColorOut is set on output.
-static bool
-HasNonOpaqueNonTransparentColor(gfxContext *aContext, Color& aCurrentColorOut)
-{
-    if (aContext->GetDeviceColor(aCurrentColorOut)) {
-        if (0.f < aCurrentColorOut.a && aCurrentColorOut.a < 1.f) {
-            return true;
-        }
-    }
-    return false;
-}
-
 // helper class for double-buffering drawing with non-opaque color
 struct MOZ_STACK_CLASS BufferAlphaColor {
     explicit BufferAlphaColor(gfxContext *aContext)
         : mContext(aContext)
     {
 
     }
 
@@ -630,17 +617,17 @@ gfxTextRun::Draw(Range aRange, gfx::Poin
 
     // synthetic bolding draws glyphs twice ==> colors with opacity won't draw
     // correctly unless first drawn without alpha
     BufferAlphaColor syntheticBoldBuffer(aParams.context);
     Color currentColor;
     bool needToRestore = false;
 
     if (aParams.drawMode & DrawMode::GLYPH_FILL &&
-        HasNonOpaqueNonTransparentColor(aParams.context, currentColor) &&
+        aParams.context->HasNonOpaqueNonTransparentColor(currentColor) &&
         HasSyntheticBoldOrColor(this, aRange) &&
         !aParams.context->GetTextDrawer()) {
 
         needToRestore = true;
         // Measure text; use the bounding box to determine the area we need
         // to buffer.
         gfxTextRun::Metrics metrics = MeasureText(
             aRange, gfxFont::LOOSE_INK_EXTENTS,