OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 |
| 3 <!-- READ BEFORE UPDATING: |
| 4 If this test is updated make sure to increment the "revision" value of the |
| 5 associated test in content/test/gpu/page_sets/pixel_tests.py. This will ensure |
| 6 that the baseline images are regenerated on the next run. |
| 7 --> |
| 8 |
| 9 <html> |
| 10 <head> |
| 11 <title>OffscreenCanvas commit flow With Resize: Blue Rectangle on white backgrou
nd.</title> |
| 12 <style type="text/css"> |
| 13 .nomargin { |
| 14 margin: 0px auto; |
| 15 } |
| 16 </style> |
| 17 <script id="myWorker" type="text/worker"> |
| 18 self.onmessage = function(e) { |
| 19 var transferredCanvas = e.data; |
| 20 var offscreen2d = transferredCanvas.getContext("2d"); |
| 21 offscreen2d.fillStyle = "blue"; |
| 22 offscreen2d.fillRect(0, 0, 200, 200); |
| 23 offscreen2d.commit(); |
| 24 |
| 25 // Change the size of offscreenCanvas from 200X200 to 100X300 |
| 26 transferredCanvas.width = 100; |
| 27 transferredCanvas.height = 300; |
| 28 offscreen2d.fillStyle = "blue"; |
| 29 offscreen2d.fillRect(0, 0, 200, 200); |
| 30 offscreen2d.commit(); |
| 31 self.postMessage(""); |
| 32 }; |
| 33 </script> |
| 34 <script> |
| 35 var g_swapsBeforeAck = 15; |
| 36 |
| 37 function makeWorker(script) |
| 38 { |
| 39 var blob = new Blob([script]); |
| 40 return new Worker(URL.createObjectURL(blob)); |
| 41 } |
| 42 |
| 43 function waitForFinish() |
| 44 { |
| 45 if (g_swapsBeforeAck == 0) { |
| 46 domAutomationController.setAutomationId(1); |
| 47 domAutomationController.send("SUCCESS"); |
| 48 } else { |
| 49 g_swapsBeforeAck--; |
| 50 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; |
| 51 window.webkitRequestAnimationFrame(waitForFinish); |
| 52 } |
| 53 } |
| 54 |
| 55 function main() |
| 56 { |
| 57 var canvas2D = document.getElementById("c"); |
| 58 var offscreenCanvas = canvas2D.transferControlToOffscreen(); |
| 59 var worker = makeWorker(document.getElementById("myWorker").textContent); |
| 60 worker.postMessage(offscreenCanvas, [offscreenCanvas]); |
| 61 worker.onmessage = function (e) { |
| 62 waitForFinish(); |
| 63 }; |
| 64 } |
| 65 </script> |
| 66 </head> |
| 67 <body onload="main()"> |
| 68 <div style="position:relative; width:300px; height:300px; background-color:white
"> |
| 69 </div> |
| 70 <div id="container" style="position:absolute; top:0px; left:0px"> |
| 71 <canvas id="c" width="200" height="200" class="nomargin"></canvas> |
| 72 </div> |
| 73 </body> |
| 74 </html> |
OLD | NEW |