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 commit flow on main thread: green square on white backgro
und.</title> | 11 <title>OffscreenCanvas transferToImageBitmap on main thread: green and blue squa
res on white 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 width = 100; |
29 var offscreenCanvas = canvas.transferControlToOffscreen(); | 29 var height = 100; |
30 var gl = offscreenCanvas.getContext("webgl"); | 30 var aCanvas = new OffscreenCanvas(width, height); |
| 31 var gl = aCanvas.getContext('webgl'); |
31 gl.clearColor(0.0, 1.0, 0.0, 1.0); | 32 gl.clearColor(0.0, 1.0, 0.0, 1.0); |
32 gl.clear(gl.COLOR_BUFFER_BIT); | 33 gl.clear(gl.COLOR_BUFFER_BIT); |
33 gl.commit(); | 34 var image1 = aCanvas.transferToImageBitmap(); |
| 35 gl.clearColor(0.0, 0.0, 1.0, 1.0); |
| 36 gl.clear(gl.COLOR_BUFFER_BIT); |
| 37 var image2 = aCanvas.transferToImageBitmap(); |
| 38 |
| 39 var canvas1 = document.getElementById("canvas1"); |
| 40 var ctx1 = canvas1.getContext('bitmaprenderer'); |
| 41 ctx1.transferFromImageBitmap(image1); |
| 42 |
| 43 var canvas2 = document.getElementById('canvas2'); |
| 44 var ctx2 = canvas2.getContext('bitmaprenderer'); |
| 45 ctx2.transferFromImageBitmap(image2); |
34 } | 46 } |
35 | 47 |
36 function waitForFinish() | 48 function waitForFinish() |
37 { | 49 { |
38 if (g_swapsBeforeAck == 0) { | 50 if (g_swapsBeforeAck == 0) { |
39 domAutomationController.setAutomationId(1); | 51 domAutomationController.setAutomationId(1); |
40 domAutomationController.send("SUCCESS"); | 52 domAutomationController.send("SUCCESS"); |
41 } else { | 53 } else { |
42 g_swapsBeforeAck--; | 54 g_swapsBeforeAck--; |
43 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; | 55 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; |
44 window.webkitRequestAnimationFrame(waitForFinish); | 56 window.webkitRequestAnimationFrame(waitForFinish); |
45 } | 57 } |
46 } | 58 } |
47 </script> | 59 </script> |
48 </head> | 60 </head> |
49 <body onload="main()"> | 61 <body onload="main()"> |
50 <div style="position:relative; width:200px; height:200px; background-color:white
"> | 62 <div style="position:relative; width:200px; height:200px; background-color:white
"> |
51 </div> | 63 </div> |
52 <div id="container" style="position:absolute; top:0px; left:0px"> | 64 <div id="container" style="position:absolute; top:0px; left:0px"> |
53 <canvas id="c" width="200" height="200" class="nomargin"></canvas> | 65 <canvas id="canvas1" width="100" height="100" class="nomargin"></canvas> |
| 66 </div> |
| 67 <div id="container" style="position:absolute; top:0px; left:150px"> |
| 68 <canvas id="canvas2" width="100" height="100" class="nomargin"></canvas> |
54 </div> | 69 </div> |
55 </body> | 70 </body> |
56 </html> | 71 </html> |
OLD | NEW |