OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE HTML> | |
2 | |
3 <!-- READ BEFORE UPDATING: | |
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 | |
6 that the baseline images are regenerated on the next run. | |
7 --> | |
8 | |
9 <html> | |
10 <head> | |
11 <title>OffscreenCanvas commit with style resize: green rectangle with yellow bor deron white background.</title> | |
12 <style type="text/css"> | |
13 .nomargin { | |
14 margin: 0px auto; | |
15 } | |
16 </style> | |
17 <script> | |
18 var g_swapsBeforeAck = 15; | |
19 | |
20 function main() | |
21 { | |
22 var canvas = document.getElementById("c"); | |
23 window.requestAnimationFrame(function() { | |
24 canvas.style.width = '100px'; | |
25 canvas.style.height = '200px'; | |
26 canvas.style.border = '10px solid yellow'; | |
27 window.requestAnimationFrame(function() { | |
28 var offscreenCanvas = canvas.transferControlToOffscreen(); | |
29 drawTriangle(offscreenCanvas); | |
30 }); | |
31 }); | |
32 waitForFinish(); | |
33 } | |
34 | |
35 function drawTriangle(canvas) | |
36 { | |
37 var gl = canvas.getContext("webgl"); | |
38 gl.clearColor(0, 1, 0, 1); | |
39 gl.clear(gl.COLOR_BUFFER_BIT); | |
40 | |
41 var prog = gl.createProgram(); | |
42 var vs = gl.createShader(gl.VERTEX_SHADER); | |
43 gl.shaderSource(vs, ['attribute vec2 pos;', | |
44 'void main() {', | |
45 ' gl_Position = vec4(pos, 0., 1.);', | |
46 '}'].join('\n')); | |
47 gl.compileShader(vs); | |
48 if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) { | |
49 throw 'failed to compiled shader'; | |
50 } | |
51 gl.attachShader(prog, vs); | |
52 | |
53 var fs = gl.createShader(gl.FRAGMENT_SHADER); | |
54 gl.shaderSource(fs, ['void main() {', | |
55 ' gl_FragColor = vec4(1.);', | |
56 '}'].join('\n')); | |
57 gl.compileShader(fs); | |
58 if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) { | |
59 throw 'failed to compiled shader'; | |
60 } | |
61 gl.attachShader(prog, fs); | |
62 | |
63 gl.linkProgram(prog); | |
64 if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) { | |
65 throw "Could not link the shader program!"; | |
66 } | |
67 gl.useProgram(prog); | |
68 | |
69 gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); | |
70 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-.5,0, 0,.5, .5,0]), gl.STATI C_DRAW); | |
71 var attr = gl.getAttribLocation(prog, 'pos'); | |
72 gl.enableVertexAttribArray(attr); | |
73 gl.vertexAttribPointer(attr, 2, gl.FLOAT, false, 0, 0); | |
74 | |
75 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3); | |
76 | |
77 gl.commit(); | |
78 } | |
79 | |
80 function waitForFinish() | |
81 { | |
82 if (g_swapsBeforeAck == 0) { | |
83 domAutomationController.setAutomationId(1); | |
84 domAutomationController.send("SUCCESS"); | |
85 } else { | |
86 g_swapsBeforeAck--; | |
87 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; | |
88 window.webkitRequestAnimationFrame(waitForFinish); | |
Justin Novosad
2016/11/18 15:07:27
the "webkit" prefix is obsolete please don't use i
xlai (Olivia)
2016/11/22 16:55:59
Done.
| |
89 } | |
90 } | |
91 </script> | |
92 </head> | |
93 <body onload="main()"> | |
94 <div style="position:relative; width:300px; height:300px; background-color:white "> | |
95 </div> | |
96 <div id="container" style="position:absolute; top:0px; left:0px"> | |
97 <canvas id="c" width="300" height="300" class="nomargin"></canvas> | |
98 </div> | |
99 </body> | |
100 </html> | |
OLD | NEW |