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

Side by Side Diff: content/test/data/gpu/pixel_webgl_context_restore.html

Issue 188073002: Added pixel test that ensures WebGL content can render properly after a context loss and restore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/test/gpu/page_sets/pixel_tests.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.json. This will ensure 5 associated test in content/test/gpu/page_sets/pixel_tests.json. 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>WebGL Test: Green Triangle over Black Background</title> 11 <title>WebGL Test: Yellow Triangle over Black Background with context loss and r estore</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 17
18 <script id="shader-vs" type="x-shader/x-vertex"> 18 <script id="shader-vs" type="x-shader/x-vertex">
19 attribute vec3 pos; 19 attribute vec3 pos;
20 void main(void) 20 void main(void)
21 { 21 {
22 gl_Position = vec4(pos, 1.0); 22 gl_Position = vec4(pos, 1.0);
23 } 23 }
24 </script> 24 </script>
25 25
26 <script id="shader-fs" type="x-shader/x-fragment"> 26 <script id="shader-fs" type="x-shader/x-fragment">
27 precision mediump float; 27 precision mediump float;
28 void main(void) 28 void main(void)
29 { 29 {
30 gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); 30 gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
31 } 31 }
32 </script> 32 </script>
33 33
34 <script> 34 <script>
35 var g_swapsBeforeAck = 15; 35 var g_swapsBeforeAck = 15;
36 var gl; 36 var gl;
37 var lose_context_ext;
37 38
38 function main() 39 function main()
39 { 40 {
40 var canvas = document.getElementById("c"); 41 var canvas = document.getElementById("c");
41 gl = initGL(canvas); 42 gl = initGL(canvas);
43
44 canvas.addEventListener("webglcontextlost", function(ev) {
45 ev.preventDefault();
46 }, false);
47 canvas.addEventListener("webglcontextrestored", function(ev) {
48 if (setup(gl)) {
49 drawSomeFrames();
50 } else {
51 domAutomationController.setAutomationId(1);
52 domAutomationController.send("FAILURE");
53 }
54 }, false);
55
42 if (gl && setup(gl)) { 56 if (gl && setup(gl)) {
43 drawSomeFrames(); 57 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
58
59 lose_context_ext.loseContext();
60 setTimeout(function() {
61 lose_context_ext.restoreContext();
62 }, 3000);
44 } else { 63 } else {
45 domAutomationController.setAutomationId(1); 64 domAutomationController.setAutomationId(1);
46 domAutomationController.send("FAILURE"); 65 domAutomationController.send("FAILURE");
47 } 66 }
48 } 67 }
49 68
50 function drawSomeFrames() 69 function drawSomeFrames()
51 { 70 {
52 if (g_swapsBeforeAck == 0) { 71 if (g_swapsBeforeAck == 0) {
53 domAutomationController.setAutomationId(1); 72 domAutomationController.setAutomationId(1);
(...skipping 16 matching lines...) Expand all
70 gl = canvas.getContext("webgl"); 89 gl = canvas.getContext("webgl");
71 } catch (e) { } 90 } catch (e) { }
72 } 91 }
73 return gl; 92 return gl;
74 } 93 }
75 94
76 function setupShader(gl, source, type) { 95 function setupShader(gl, source, type) {
77 var shader = gl.createShader(type); 96 var shader = gl.createShader(type);
78 gl.shaderSource(shader, source); 97 gl.shaderSource(shader, source);
79 gl.compileShader(shader); 98 gl.compileShader(shader);
99 lose_context_ext = gl.getExtension("WEBGL_lose_context");
100 if (!lose_context_ext)
101 return null;
80 if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) 102 if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))
81 return null; 103 return null;
82 return shader; 104 return shader;
83 } 105 }
84 106
85 function setupProgram(gl, vs_id, fs_id) { 107 function setupProgram(gl, vs_id, fs_id) {
86 var vs_node = document.getElementById(vs_id); 108 var vs_node = document.getElementById(vs_id);
87 var fs_node = document.getElementById(fs_id); 109 var fs_node = document.getElementById(fs_id);
88 if (!vs_node || !fs_node) 110 if (!vs_node || !fs_node)
89 return null; 111 return null;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 157 }
136 </script> 158 </script>
137 </head> 159 </head>
138 <body onload="main()"> 160 <body onload="main()">
139 <div style="position:relative; width:200px; height:200px; background-color:black "></div> 161 <div style="position:relative; width:200px; height:200px; background-color:black "></div>
140 <div style="position:absolute; top:0px; left:0px"> 162 <div style="position:absolute; top:0px; left:0px">
141 <canvas id="c" width="200" height="200" class="nomargin"></canvas> 163 <canvas id="c" width="200" height="200" class="nomargin"></canvas>
142 </div> 164 </div>
143 </body> 165 </body>
144 </html> 166 </html>
OLDNEW
« no previous file with comments | « no previous file | content/test/gpu/page_sets/pixel_tests.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698