| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 | 2 |
| 3 <!-- READ BEFORE UPDATING: | 3 <!-- READ BEFORE UPDATING: |
| 4 If this test is updated make sure to increment the "revision" value of the | 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 | 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. | 6 that the baseline images are regenerated on the next run. |
| 7 --> | 7 --> |
| 8 | 8 |
| 9 <html> | 9 <html> |
| 10 <head> | 10 <head> |
| 11 <title>OffscreenCanvas 2d commit flow on worker thread: Four-color square on whi
te background.</title> | 11 <title>OffscreenCanvas 2d commit flow on worker thread: Four-color square on whi
te background.</title> |
| 12 <style type="text/css"> | 12 <style type="text/css"> |
| 13 .nomargin { | 13 .nomargin { |
| 14 margin: 0px auto; | 14 margin: 0px auto; |
| 15 } | 15 } |
| 16 </style> | 16 </style> |
| 17 <script id="myWorker" type="text/worker"> | 17 <script id="myWorker" type="text/worker"> |
| 18 |
| 19 var g_offscreen2d; |
| 20 var g_animationFrameNumber = 0; |
| 21 |
| 18 self.onmessage = function(e) { | 22 self.onmessage = function(e) { |
| 19 var transferredCanvas = e.data; | 23 var transferredCanvas = e.data; |
| 20 var offscreen2d = transferredCanvas.getContext("2d"); | 24 g_offscreen2d = transferredCanvas.getContext("2d"); |
| 25 drawLoop(); |
| 26 } |
| 27 |
| 28 function drawLoop() |
| 29 { |
| 30 if (g_animationFrameNumber < 3) { |
| 31 offscreen2d.fillStyle = "red"; |
| 32 offscreen2d.fillRect(0, 0, 200, 200); |
| 33 g_animationFrameNumber++; |
| 34 offscreen2d.commit().then(drawLoop); |
| 35 } else { |
| 21 offscreen2d.fillStyle = "red"; | 36 offscreen2d.fillStyle = "red"; |
| 22 offscreen2d.fillRect(0, 0, 100, 100); | 37 offscreen2d.fillRect(0, 0, 100, 100); |
| 23 offscreen2d.fillStyle = "green"; | 38 offscreen2d.fillStyle = "green"; |
| 24 offscreen2d.fillRect(100, 0, 100, 100); | 39 offscreen2d.fillRect(100, 0, 100, 100); |
| 25 offscreen2d.fillStyle = "blue"; | 40 offscreen2d.fillStyle = "blue"; |
| 26 offscreen2d.fillRect(0, 100, 100, 100); | 41 offscreen2d.fillRect(0, 100, 100, 100); |
| 27 offscreen2d.fillStyle = "black"; | 42 offscreen2d.fillStyle = "black"; |
| 28 offscreen2d.fillRect(100, 100, 100, 100); | 43 offscreen2d.fillRect(100, 100, 100, 100); |
| 29 offscreen2d.commit(); | 44 offscreen2d.commit() |
| 45 |
| 46 // The following fill is never committed |
| 47 offscreen2d.fillStyle = "blue"; |
| 48 offscreen2d.fillRect(0, 0, 200, 200); |
| 30 self.postMessage(""); | 49 self.postMessage(""); |
| 31 }; | 50 } |
| 51 } |
| 32 </script> | 52 </script> |
| 33 <script> | 53 <script> |
| 34 var g_swapsBeforeAck = 15; | 54 var g_swapsBeforeAck = 15; |
| 35 | 55 |
| 36 function makeWorker(script) | 56 function makeWorker(script) |
| 37 { | 57 { |
| 38 var blob = new Blob([script]); | 58 var blob = new Blob([script]); |
| 39 return new Worker(URL.createObjectURL(blob)); | 59 return new Worker(URL.createObjectURL(blob)); |
| 40 } | 60 } |
| 41 | 61 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 64 </script> | 84 </script> |
| 65 </head> | 85 </head> |
| 66 <body onload="main()"> | 86 <body onload="main()"> |
| 67 <div style="position:relative; width:300px; height:300px; background-color:white
"> | 87 <div style="position:relative; width:300px; height:300px; background-color:white
"> |
| 68 </div> | 88 </div> |
| 69 <div id="container" style="position:absolute; top:0px; left:0px"> | 89 <div id="container" style="position:absolute; top:0px; left:0px"> |
| 70 <canvas id="c" width="200" height="200" class="nomargin"></canvas> | 90 <canvas id="c" width="200" height="200" class="nomargin"></canvas> |
| 71 </div> | 91 </div> |
| 72 </body> | 92 </body> |
| 73 </html> | 93 </html> |
| OLD | NEW |