2d.layer.non-invertible-matrix.shadow.w.html (2083B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <html class="reftest-wait"> 5 <link rel="match" href="2d.layer.non-invertible-matrix.shadow-expected.html"> 6 <title>Canvas test: 2d.layer.non-invertible-matrix.shadow</title> 7 <h1>2d.layer.non-invertible-matrix.shadow</h1> 8 <p class="desc">Test drawing layers when the transform is not invertible.</p> 9 <canvas id="canvas" width="200" height="200"> 10 <p class="fallback">FAIL (fallback content)</p> 11 </canvas> 12 <script id='myWorker' type='text/worker'> 13 self.onmessage = function(e) { 14 const canvas = new OffscreenCanvas(200, 200); 15 const ctx = canvas.getContext('2d'); 16 17 ctx.fillStyle = 'blue'; 18 ctx.fillRect(30, 30, 50, 50); 19 20 // Anything below will be non-rasterizable. 21 ctx.scale(1, 0); 22 23 ctx.shadowOffsetX = 0; 24 ctx.shadowOffsetY = 20; 25 ctx.shadowColor = 'rgba(255, 165, 0, 0.6)'; 26 27 // Open the layer with a non-invertible matrix. The whole layer will be 28 // non-rasterizable. 29 ctx.beginLayer(); 30 31 // Because the transform is global, the matrix is still non-invertible. 32 ctx.fillStyle = 'rgba(225, 0, 0, 1)'; 33 ctx.fillRect(40, 70, 50, 50); 34 35 // Set a valid matrix in the middle of the layer. This makes the global 36 // matrix invertible again, but because because the layer was opened with a 37 // non-invertible matrix, the whole layer remains non-rasterizable. 38 ctx.setTransform(1, 0, 0, 1, 0, 0); 39 40 ctx.fillStyle = 'green'; 41 ctx.fillRect(70, 40, 50, 50); 42 43 ctx.endLayer(); 44 45 const bitmap = canvas.transferToImageBitmap(); 46 self.postMessage(bitmap, bitmap); 47 }; 48 </script> 49 <script> 50 const blob = new Blob([document.getElementById('myWorker').textContent]); 51 const worker = new Worker(URL.createObjectURL(blob)); 52 worker.addEventListener('message', msg => { 53 const outputCtx = document.getElementById("canvas").getContext('2d'); 54 outputCtx.drawImage(msg.data, 0, 0); 55 document.documentElement.classList.remove("reftest-wait"); 56 }); 57 worker.postMessage(null); 58 </script> 59 </html>