Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: content/test/data/gpu/pixel_webgl_util.js

Issue 2023153002: Add more WebGL pixel tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments fmor kbr. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // TODO: We should test premultiplyAlpha as well.
27 function initGL(canvas, antialias, alpha)
27 { 28 {
28 var gl = null; 29 var gl = null;
29 try { 30 try {
30 gl = canvas.getContext("experimental-webgl"); 31 gl = canvas.getContext("experimental-webgl",
32 {"alpha": alpha, "antialias":antialias});
31 } catch (e) {} 33 } catch (e) {}
32 if (!gl) { 34 if (!gl) {
33 try { 35 try {
34 gl = canvas.getContext("webgl"); 36 gl = canvas.getContext("webgl");
35 } catch (e) { } 37 } catch (e) { }
36 } 38 }
37 return gl; 39 return gl;
38 } 40 }
39 41
40 function setupShader(gl, source, type) { 42 function setupShader(gl, source, type) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 gl.disable(gl.DEPTH_TEST); 88 gl.disable(gl.DEPTH_TEST);
87 if (gl.getError() != gl.NO_ERROR) 89 if (gl.getError() != gl.NO_ERROR)
88 return false; 90 return false;
89 return true; 91 return true;
90 } 92 }
91 93
92 function drawTriangle(gl) { 94 function drawTriangle(gl) {
93 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 95 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
94 gl.drawArrays(gl.TRIANGLES, 0, 3); 96 gl.drawArrays(gl.TRIANGLES, 0, 3);
95 } 97 }
98
99 var g_swapsBeforeAckUtil = 15;
100 var g_glUtil;
101
102 function makeMain(antialias, alpha)
103 {
104 return function() {
105 var canvas = document.getElementById("c");
106 g_glUtil = initGL(canvas, antialias, alpha);
107 if (g_glUtil && setup(g_glUtil)) {
108 drawSomeFramesUtil();
109 } else {
110 domAutomationController.setAutomationId(1);
111 domAutomationController.send("FAILURE");
112 }
113 };
114 }
115
116 function drawSomeFramesUtil()
117 {
118 if (g_swapsBeforeAckUtil == 0) {
119 domAutomationController.setAutomationId(1);
120 domAutomationController.send("SUCCESS");
121 } else {
122 g_swapsBeforeAckUtil--;
123 drawTriangle(g_glUtil);
124 window.webkitRequestAnimationFrame(drawSomeFramesUtil);
125 }
126 }
OLDNEW
« no previous file with comments | « content/test/data/gpu/pixel_webgl_noaa_noalpha.html ('k') | content/test/gpu/gpu_tests/pixel_expectations.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698