OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // READ BEFORE UPDATING: | 5 // READ BEFORE UPDATING: |
6 // If this file is updated, make sure to increment the "revision" value of any | 6 // If this file is updated, make sure to increment the "revision" value of any |
7 // tests that use this file in content/test/gpu/page_sets/pixel_tests.py. This | 7 // tests that use this file in content/test/gpu/page_sets/pixel_tests.py. This |
8 // will ensure that the baseline images are regenerated on the next run. | 8 // will ensure that the baseline images are regenerated on the next run. |
9 | 9 |
10 var vertexShader = [ | 10 var vertexShader = [ |
11 "attribute vec3 pos;", | 11 "attribute vec3 pos;", |
12 "void main(void)", | 12 "void main(void)", |
13 "{", | 13 "{", |
14 " gl_Position = vec4(pos, 1.0);", | 14 " gl_Position = vec4(pos, 1.0);", |
15 "}" | 15 "}" |
16 ].join("\n"); | 16 ].join("\n"); |
17 | 17 |
18 var fragmentShader = [ | 18 var fragmentShader = [ |
19 "precision mediump float;", | 19 "precision mediump float;", |
20 "void main(void)", | 20 "void main(void)", |
21 "{", | 21 "{", |
22 " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);", | 22 " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);", |
23 "}" | 23 "}" |
24 ].join("\n"); | 24 ].join("\n"); |
25 | 25 |
26 function initGL(canvas) | 26 function initGL(canvas, antialias, alpha) |
27 { | 27 { |
28 var gl = null; | 28 var gl = null; |
29 try { | 29 try { |
30 gl = canvas.getContext("experimental-webgl"); | 30 gl = canvas.getContext("experimental-webgl", |
31 {"alpha": alpha, "antialias":antialias}); | |
Ken Russell (switch to Gerrit)
2016/06/01 02:06:07
Could you add a TODO about testing premultiplyAlph
erikchen
2016/06/01 17:07:03
Done.
| |
31 } catch (e) {} | 32 } catch (e) {} |
32 if (!gl) { | 33 if (!gl) { |
33 try { | 34 try { |
34 gl = canvas.getContext("webgl"); | 35 gl = canvas.getContext("webgl"); |
35 } catch (e) { } | 36 } catch (e) { } |
36 } | 37 } |
37 return gl; | 38 return gl; |
38 } | 39 } |
39 | 40 |
40 function setupShader(gl, source, type) { | 41 function setupShader(gl, source, type) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 gl.disable(gl.DEPTH_TEST); | 87 gl.disable(gl.DEPTH_TEST); |
87 if (gl.getError() != gl.NO_ERROR) | 88 if (gl.getError() != gl.NO_ERROR) |
88 return false; | 89 return false; |
89 return true; | 90 return true; |
90 } | 91 } |
91 | 92 |
92 function drawTriangle(gl) { | 93 function drawTriangle(gl) { |
93 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); | 94 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
94 gl.drawArrays(gl.TRIANGLES, 0, 3); | 95 gl.drawArrays(gl.TRIANGLES, 0, 3); |
95 } | 96 } |
97 | |
98 var g_swapsBeforeAckUtil = 15; | |
99 var g_glUtil; | |
100 | |
101 function makeMain(antialias, alpha) | |
102 { | |
103 return function() { | |
104 var canvas = document.getElementById("c"); | |
105 g_glUtil = initGL(canvas, antialias, alpha); | |
106 if (g_glUtil && setup(g_glUtil)) { | |
107 drawSomeFramesUtil(); | |
108 } else { | |
109 domAutomationController.setAutomationId(1); | |
110 domAutomationController.send("FAILURE"); | |
111 } | |
112 }; | |
113 } | |
114 | |
115 function drawSomeFramesUtil() | |
116 { | |
117 if (g_swapsBeforeAckUtil == 0) { | |
118 domAutomationController.setAutomationId(1); | |
119 domAutomationController.send("SUCCESS"); | |
120 } else { | |
121 g_swapsBeforeAckUtil--; | |
122 drawTriangle(g_glUtil); | |
123 window.webkitRequestAnimationFrame(drawSomeFramesUtil); | |
124 } | |
125 } | |
OLD | NEW |