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

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

Issue 2417773003: Fix content upside down when call OffscreenCanvas's commit (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « no previous file | content/test/data/gpu/pixel_offscreenCanvas_webgl_commit_worker.html » ('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.py. This will ensure 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. 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>OffscreenCanvas commit flow on main thread: green square on white backgro und.</title> 11 <title>OffscreenCanvas commit flow on main thread: green square on white backgro und.</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 <script> 17 <script>
18 var g_swapsBeforeAck = 15; 18 var g_swapsBeforeAck = 15;
19 19
20 function main() 20 function main()
21 { 21 {
22 draw(); 22 draw();
23 waitForFinish(); 23 waitForFinish();
24 } 24 }
25 25
26 function drawTriangle(canvas)
27 {
28 var gl = canvas.getContext("webgl");
29 gl.clearColor(0, 1, 0, 1);
30 gl.clear(gl.COLOR_BUFFER_BIT);
31
32 var prog = gl.createProgram();
33 var vs = gl.createShader(gl.VERTEX_SHADER);
34 gl.shaderSource(vs, ['attribute vec2 pos;',
35 'void main() {',
36 ' gl_Position = vec4(pos, 0., 1.);',
37 '}'].join('\n'));
38 gl.compileShader(vs);
39 if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) {
40 throw 'failed to compiled shader';
41 }
42 gl.attachShader(prog, vs);
43
44 var fs = gl.createShader(gl.FRAGMENT_SHADER);
45 gl.shaderSource(fs, ['void main() {',
46 ' gl_FragColor = vec4(1.);',
47 '}'].join('\n'));
48 gl.compileShader(fs);
49 if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) {
50 throw 'failed to compiled shader';
51 }
52 gl.attachShader(prog, fs);
53
54 gl.linkProgram(prog);
55 if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) {
56 throw "Could not link the shader program!";
57 }
58 gl.useProgram(prog);
59
60 gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
61 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-.5,0, 0,.5, .5,0]), gl.STATI C_DRAW);
62 var attr = gl.getAttribLocation(prog, 'pos');
63 gl.enableVertexAttribArray(attr);
64 gl.vertexAttribPointer(attr, 2, gl.FLOAT, false, 0, 0);
65
66 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3);
67
68 gl.commit();
69 }
70
26 function draw() 71 function draw()
27 { 72 {
28 var canvas = document.getElementById("c"); 73 var canvas = document.getElementById("c");
29 var offscreenCanvas = canvas.transferControlToOffscreen(); 74 var offscreenCanvas = canvas.transferControlToOffscreen();
30 var gl = offscreenCanvas.getContext("webgl"); 75 drawTriangle(offscreenCanvas);
31 gl.clearColor(0.0, 1.0, 0.0, 1.0);
32 gl.clear(gl.COLOR_BUFFER_BIT);
33 gl.commit();
34 } 76 }
35 77
36 function waitForFinish() 78 function waitForFinish()
37 { 79 {
38 if (g_swapsBeforeAck == 0) { 80 if (g_swapsBeforeAck == 0) {
39 domAutomationController.setAutomationId(1); 81 domAutomationController.setAutomationId(1);
40 domAutomationController.send("SUCCESS"); 82 domAutomationController.send("SUCCESS");
41 } else { 83 } else {
42 g_swapsBeforeAck--; 84 g_swapsBeforeAck--;
43 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; 85 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1;
44 window.webkitRequestAnimationFrame(waitForFinish); 86 window.webkitRequestAnimationFrame(waitForFinish);
45 } 87 }
46 } 88 }
47 </script> 89 </script>
48 </head> 90 </head>
49 <body onload="main()"> 91 <body onload="main()">
50 <div style="position:relative; width:200px; height:200px; background-color:white "> 92 <div style="position:relative; width:300px; height:300px; background-color:white ">
51 </div> 93 </div>
52 <div id="container" style="position:absolute; top:0px; left:0px"> 94 <div id="container" style="position:absolute; top:0px; left:0px">
53 <canvas id="c" width="200" height="200" class="nomargin"></canvas> 95 <canvas id="c" width="300" height="300" class="nomargin"></canvas>
54 </div> 96 </div>
55 </body> 97 </body>
56 </html> 98 </html>
OLDNEW
« no previous file with comments | « no previous file | content/test/data/gpu/pixel_offscreenCanvas_webgl_commit_worker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698