OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta charset="utf-8"> | 4 <meta charset="utf-8"> |
5 <title>GPU Feature Testing: Canvas2D</title> | 5 <title>GPU Feature Testing: Canvas2D</title> |
6 <script> | 6 <script> |
| 7 var frameCount = 0; |
| 8 var context = null; |
| 9 |
7 function init() { | 10 function init() { |
8 var canvas = document.createElement("canvas"); | 11 var canvas = document.getElementById("da-canvas"); |
9 if (!canvas) | 12 if (!canvas) |
10 return null; | 13 return; |
11 // Make sure canvas is large enough to trigger gpu acceleration. | |
12 canvas.width = 500; | |
13 canvas.height = 500; | |
14 var context = null; | |
15 try { | 14 try { |
16 context = canvas.getContext("2d"); | 15 context = canvas.getContext("2d"); |
17 } catch(e) {} | 16 } catch(e) {} |
18 return context; | |
19 } | 17 } |
20 | 18 |
21 function runTest() { | 19 function runTest() { |
22 var c2d = init(); | 20 init(); |
23 if (c2d) { | 21 if (context) |
24 // Initialization was triggered lazily on the first draw. | 22 window.webkitRequestAnimationFrame(draw); |
25 c2d.fillRect(0, 0, 1, 1); | 23 else |
| 24 endTest(); |
| 25 } |
| 26 |
| 27 function draw() { |
| 28 frameCount++; |
| 29 document.body.style.backgroundColor = (frameCount & 1) ? "red" : "blue"; |
| 30 context.fillRect(0, 0, 500, frameCount*100); |
| 31 if (frameCount == 5) { |
| 32 endTest(); |
| 33 } else { |
| 34 window.webkitRequestAnimationFrame(draw); |
26 } | 35 } |
| 36 } |
| 37 |
| 38 function endTest() { |
27 domAutomationController.setAutomationId(1); | 39 domAutomationController.setAutomationId(1); |
28 domAutomationController.send("FINISHED"); | 40 domAutomationController.send("FINISHED"); |
29 } | 41 } |
30 </script> | 42 </script> |
31 </head> | 43 </head> |
32 <body onload="runTest()"> | 44 <body onload="runTest()"> |
33 Canvas2D should trigger GPU process launch if accelerated-2d-canvas is allowed. | 45 Canvas2D should trigger GPU process launch if accelerated-2d-canvas is allowed. |
| 46 <canvas id="da-canvas" width="500" height="500"></canvas> |
34 </body> | 47 </body> |
35 </html> | 48 </html> |
OLD | NEW |