chromium/third_party/blink/web_tests/external/wpt/html/canvas/element/layers/2d.layer.ctm.ctx-filter.html

<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<link rel="match" href="2d.layer.ctm.ctx-filter-expected.html">
<title>Canvas test: 2d.layer.ctm.ctx-filter</title>
<h1>2d.layer.ctm.ctx-filter</h1>
<p class="desc">Checks that parent transforms don't affect context filters.</p>
<canvas id="canvas" width="200" height="200">
  <p class="fallback">FAIL (fallback content)</p>
</canvas>
<script>
  const canvas = document.getElementById("canvas");
  const ctx = canvas.getContext('2d');

  ctx.fillStyle = 'grey';
  ctx.translate(30, 90);
  ctx.scale(2, 2);
  ctx.rotate(Math.PI / 2);

  // The transform doesn't apply to context filter on normal draw calls.
  ctx.save();
  ctx.filter = 'drop-shadow(10px 10px 0px red)';
  ctx.fillRect(-30, -5, 60, 10);
  ctx.restore();

  // Likewise, the transform doesn't apply to context filter applied on layer.
  ctx.save();
  ctx.filter = 'drop-shadow(10px 10px 0px green)';
  ctx.beginLayer();
  ctx.fillRect(-30, -25, 60, 10);
  ctx.endLayer();
  ctx.restore();

  // Filters inside layers aren't affected by transform either.
  ctx.beginLayer();
  ctx.filter = 'drop-shadow(5px 5px 0px blue)';
  ctx.fillRect(-30, -45, 60, 10);
  ctx.endLayer();
</script>