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: Four-color squares on whit
e background.</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 drawLoop(); |
23 waitForFinish(); | |
24 } | 23 } |
25 | 24 |
26 function draw() | 25 var g_animationFrameNumber = 0; |
| 26 |
| 27 function drawLoop() |
27 { | 28 { |
28 var canvas = document.getElementById("c"); | 29 var canvas = document.getElementById("c"); |
29 var offscreenCanvas = canvas.transferControlToOffscreen(); | 30 var offscreenCanvas = canvas.transferControlToOffscreen(); |
30 var offscreen2d = offscreenCanvas.getContext("2d"); | 31 var offscreen2d = offscreenCanvas.getContext("2d"); |
31 offscreen2d.fillStyle = "red"; | 32 if (g_animationFrameNumber < 3) { |
32 offscreen2d.fillRect(0, 0, 100, 100); | 33 offscreen2d.fillStyle = "red"; |
33 offscreen2d.fillStyle = "green"; | 34 offscreen2d.fillRect(0, 0, 200, 200); |
34 offscreen2d.fillRect(100, 0, 100, 100); | 35 g_animationFrameNumber++; |
35 offscreen2d.fillStyle = "blue"; | 36 offscreen2d.commit().then(drawLoop); |
36 offscreen2d.fillRect(0, 100, 100, 100); | 37 } else { |
37 offscreen2d.fillStyle = "black"; | 38 offscreen2d.fillStyle = "red"; |
38 offscreen2d.fillRect(100, 100, 100, 100); | 39 offscreen2d.fillRect(0, 0, 100, 100); |
39 offscreen2d.commit(); | 40 offscreen2d.fillStyle = "green"; |
| 41 offscreen2d.fillRect(100, 0, 100, 100); |
| 42 offscreen2d.fillStyle = "blue"; |
| 43 offscreen2d.fillRect(0, 100, 100, 100); |
| 44 offscreen2d.fillStyle = "black"; |
| 45 offscreen2d.fillRect(100, 100, 100, 100); |
| 46 offscreen2d.commit(); |
| 47 |
| 48 // The following fill is never committed |
| 49 offscreen2d.fillStyle = "blue"; |
| 50 offscreen2d.fillRect(0, 0, 200, 200); |
| 51 waitForFinish(); |
| 52 } |
40 } | 53 } |
41 | 54 |
42 function waitForFinish() | 55 function waitForFinish() |
43 { | 56 { |
44 if (g_swapsBeforeAck == 0) { | 57 if (g_swapsBeforeAck == 0) { |
45 domAutomationController.setAutomationId(1); | 58 domAutomationController.setAutomationId(1); |
46 domAutomationController.send("SUCCESS"); | 59 domAutomationController.send("SUCCESS"); |
47 } else { | 60 } else { |
48 g_swapsBeforeAck--; | 61 g_swapsBeforeAck--; |
49 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; | 62 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; |
50 window.webkitRequestAnimationFrame(waitForFinish); | 63 window.webkitRequestAnimationFrame(waitForFinish); |
51 } | 64 } |
52 } | 65 } |
53 </script> | 66 </script> |
54 </head> | 67 </head> |
55 <body onload="main()"> | 68 <body onload="main()"> |
56 <div style="position:relative; width:300px; height:300px; background-color:white
"> | 69 <div style="position:relative; width:300px; height:300px; background-color:white
"> |
57 </div> | 70 </div> |
58 <div id="container" style="position:absolute; top:0px; left:0px"> | 71 <div id="container" style="position:absolute; top:0px; left:0px"> |
59 <canvas id="c" width="200" height="200" class="nomargin"></canvas> | 72 <canvas id="c" width="200" height="200" class="nomargin"></canvas> |
60 </div> | 73 </div> |
61 </body> | 74 </body> |
62 </html> | 75 </html> |
OLD | NEW |