Commit e2e9d9b1 authored by Jonathan Kew's avatar Jonathan Kew
Browse files

Bug 1912431 - Don't apply global alpha when creating a cached color glyph. a=RyanVM

The reftest here currently fails on Android for what appears to be an
unrelated reason: reftest-analyzer shows that in the *reference* case,
all but the last line of text is completely missing.

I'm not sure what's failing there (but it fails similarly without this
patch, anyhow); we should investigate that as a separate bug.

Original Revision: https://phabricator.services.mozilla.com/D219024

Differential Revision: https://phabricator.services.mozilla.com/D219886
parent f45db8ab
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="utf-8" />
</head>
<body>
<style>
  canvas { display: block; }
</style>
<script>
function createCanvas(alpha) {
  const canvas = document.createElement("canvas");
  canvas.width = 500;
  canvas.height = 50;
  canvas.style.opacity = alpha;

  document.body.appendChild(canvas);

  const ctx = canvas.getContext('2d');
  ctx.font = "20px Arial";
  ctx.fillText("Text: ABC, Clocks: \ud83d\udd52 \ud83d\udd53 \ud83d\udd54 \ud83d\udd55.", 50, 30);
}

createCanvas(0);
createCanvas(0.25);
createCanvas(0.5);
createCanvas(0.75);
createCanvas(1);
</script>
</body>
</html>
+30 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="utf-8" />
</head>
<body>

<script>
const canvas = document.createElement("canvas");
canvas.width = 500;
canvas.height = 300;

document.body.appendChild(canvas);

const ctx = canvas.getContext('2d');
ctx.font = "20px Arial";

function createLabel(alpha) {
  ctx.globalAlpha = alpha;
  ctx.fillText("Text: ABC, Clocks: \ud83d\udd52 \ud83d\udd53 \ud83d\udd54 \ud83d\udd55.", 50, 30 + 200 * alpha);
}

createLabel(0);
createLabel(0.25);
createLabel(0.5);
createLabel(0.75);
createLabel(1);
</script>
</body>
</html>
+1 −0
Original line number Diff line number Diff line
@@ -46,3 +46,4 @@ random-if(gtkWidget) fuzzy-if(Android,0-125,0-106) == 1845828-1.html 1845828-1-r
fuzzy-if(!winWidget,0-1,0-4) fuzzy-if(winWidget,14-14,245-314) == 1853216-1.html 1853216-1-ref.html
fuzzy-if(winWidget,0-1,0-13) == 1873708-emoji-canvas-filter.html 1873708-emoji-canvas-filter-ref.html
!= 1870240-colrv1-cycle.html 1870240-colrv1-cycle-notref.html
fuzzy(0-2,0-3864) random-if(Android) == 1912431-emoji-globalAlpha.html 1912431-emoji-globalAlpha-ref.html
+2 −1
Original line number Diff line number Diff line
@@ -2730,9 +2730,10 @@ bool gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext,
      RefPtr target =
          Factory::CreateDrawTarget(BackendType::SKIA, size, format);
      if (target) {
        // Use OP_OVER to create the glyph snapshot.
        // Use OP_OVER and opaque alpha to create the glyph snapshot.
        DrawOptions drawOptions(aFontParams.drawOptions);
        drawOptions.mCompositionOp = CompositionOp::OP_OVER;
        drawOptions.mAlpha = 1.0f;
        bool ok = false;
        if (paintGraph) {
          ok = COLRFonts::PaintGlyphGraph(