Chromium Code Reviews| 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 main thread: blue square on white backg round.</title> | 11 <title>OffscreenCanvas 2d commit flow on main thread: Four-color squares on whit e 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> | 17 <script> |
| 18 var g_swapsBeforeAck = 15; | 18 var g_swapsBeforeAck = 15; |
| 19 | 19 |
| 20 function main() | 20 function main() |
| 21 { | 21 { |
| 22 draw(); | 22 draw(); |
| 23 waitForFinish(); | 23 waitForFinish(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 function draw() | 26 function draw() |
| 27 { | 27 { |
| 28 var canvas = document.getElementById("c"); | 28 var canvas = document.getElementById("c"); |
| 29 var offscreenCanvas = canvas.transferControlToOffscreen(); | 29 var offscreenCanvas = canvas.transferControlToOffscreen(); |
| 30 var ctx2d = offscreenCanvas.getContext("2d"); | 30 var offscreen2d = offscreenCanvas.getContext("2d"); |
| 31 ctx2d.fillStyle = "blue"; | 31 offscreen2d.fillStyle = "red"; |
| 32 ctx2d.fillRect(0, 0, offscreenCanvas.width, offscreenCanvas.height); | 32 offscreen2d.fillRect(0, 0, 100, 100); |
| 33 ctx2d.commit(); | 33 offscreen2d.fillStyle = "green"; |
| 34 offscreen2d.fillRect(100, 0, 200, 100); | |
|
xidachen
2016/10/13 17:07:50
I think the last two parameters are width && heigh
xlai (Olivia)
2016/10/13 18:48:24
Done.
| |
| 35 offscreen2d.fillStyle = "blue"; | |
| 36 offscreen2d.fillRect(0, 100, 100, 200); | |
| 37 offscreen2d.fillStyle = "black"; | |
| 38 offscreen2d.fillRect(100, 100, 200, 200); | |
| 39 offscreen2d.commit(); | |
| 34 } | 40 } |
| 35 | 41 |
| 36 function waitForFinish() | 42 function waitForFinish() |
| 37 { | 43 { |
| 38 if (g_swapsBeforeAck == 0) { | 44 if (g_swapsBeforeAck == 0) { |
| 39 domAutomationController.setAutomationId(1); | 45 domAutomationController.setAutomationId(1); |
| 40 domAutomationController.send("SUCCESS"); | 46 domAutomationController.send("SUCCESS"); |
| 41 } else { | 47 } else { |
| 42 g_swapsBeforeAck--; | 48 g_swapsBeforeAck--; |
| 43 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; | 49 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; |
| 44 window.webkitRequestAnimationFrame(waitForFinish); | 50 window.webkitRequestAnimationFrame(waitForFinish); |
| 45 } | 51 } |
| 46 } | 52 } |
| 47 </script> | 53 </script> |
| 48 </head> | 54 </head> |
| 49 <body onload="main()"> | 55 <body onload="main()"> |
| 50 <div style="position:relative; width:350px; height:350px; background-color:white "> | 56 <div style="position:relative; width:300px; height:300px; background-color:white "> |
| 51 </div> | 57 </div> |
| 52 <div id="container" style="position:absolute; top:0px; left:0px"> | 58 <div id="container" style="position:absolute; top:0px; left:0px"> |
| 53 <canvas id="c" width="320" height="320" class="nomargin"></canvas> | 59 <canvas id="c" width="200" height="200" class="nomargin"></canvas> |
| 54 </div> | 60 </div> |
| 55 </body> | 61 </body> |
| 56 </html> | 62 </html> |
| OLD | NEW |