tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

2d.layer.non-invertible-matrix.with-render-states.plain-layer.html (1720B)


      1 <!DOCTYPE html>
      2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
      3 <meta charset="UTF-8">
      4 <link rel="match" href="2d.layer.non-invertible-matrix.with-render-states.plain-layer-expected.html">
      5 <title>Canvas test: 2d.layer.non-invertible-matrix.with-render-states.plain-layer</title>
      6 <h1>2d.layer.non-invertible-matrix.with-render-states.plain-layer</h1>
      7 <p class="desc">Test drawing layers when the transform is not invertible.</p>
      8 <canvas id="canvas" width="200" height="200">
      9  <p class="fallback">FAIL (fallback content)</p>
     10 </canvas>
     11 <script>
     12  const canvas = new OffscreenCanvas(200, 200);
     13  const ctx = canvas.getContext('2d');
     14 
     15  ctx.fillStyle = 'blue';
     16  ctx.fillRect(30, 30, 50, 50);
     17 
     18  // Anything below will be non-rasterizable.
     19  ctx.scale(1, 0);
     20 
     21  ctx.globalAlpha = 0.8;
     22  ctx.globalCompositeOperation = 'multiply';
     23  ctx.shadowOffsetX = 0;
     24  ctx.shadowOffsetY = 20;
     25  ctx.shadowColor = 'rgba(255, 165, 0, 0.6)';
     26  ctx.filter = 'blur(10px)';
     27 
     28  // Open the layer with a non-invertible matrix. The whole layer will be
     29  // non-rasterizable.
     30  ctx.beginLayer();
     31 
     32  // Because the transform is global, the matrix is still non-invertible.
     33  ctx.fillStyle = 'rgba(225, 0, 0, 1)';
     34  ctx.fillRect(40, 70, 50, 50);
     35 
     36  // Set a valid matrix in the middle of the layer. This makes the global
     37  // matrix invertible again, but because because the layer was opened with a
     38  // non-invertible matrix, the whole layer remains non-rasterizable.
     39  ctx.setTransform(1, 0, 0, 1, 0, 0);
     40 
     41  ctx.fillStyle = 'green';
     42  ctx.fillRect(70, 40, 50, 50);
     43 
     44  ctx.endLayer();
     45 
     46  const outputCanvas = document.getElementById("canvas");
     47  outputCanvas.getContext('2d').drawImage(canvas, 0, 0);
     48 </script>