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

Side by Side Diff: conformance/canvas/viewport-unchanged-upon-resize.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « conformance/canvas/drawingbuffer-test.html ('k') | conformance/context/00_test_list.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <html>
7 <head>
8 <meta charset="utf-8">
9 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
10 <script src="../../resources/js-test-pre.js"></script>
11 <script src="../resources/webgl-test.js"></script>
12 <script id="vshader" type="x-shader/x-vertex">
13 attribute vec3 g_Position;
14
15 void main()
16 {
17 gl_Position = vec4(g_Position.x, g_Position.y, g_Position.z, 1.0);
18 }
19 </script>
20
21 <script id="fshader" type="x-shader/x-fragment">
22 void main()
23 {
24 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
25 }
26 </script>
27
28 </head>
29 <body>
30 <canvas id="example" width="4px" height="4px"></canvas>
31 <div id="description"></div>
32 <div id="console"></div>
33 <script>
34 description('Verifies that GL viewport does not change when canvas is resized');
35
36 var err;
37 var gl = initWebGL("example", "vshader", "fshader", [ "g_Position" ], [ 0, 0, 1, 1 ], 1);
38
39 var vertices = new Float32Array([
40 1.0, 1.0, 0.0,
41 -1.0, 1.0, 0.0,
42 -1.0, -1.0, 0.0,
43 1.0, 1.0, 0.0,
44 -1.0, -1.0, 0.0,
45 1.0, -1.0, 0.0]);
46 var vbo = gl.createBuffer();
47 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
48 gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
49
50 gl.enableVertexAttribArray(0);
51 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
52
53 // Clear and set up
54 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
55 gl.useProgram(gl.program);
56 // Draw the triangle pair to the frame buffer
57 gl.drawArrays(gl.TRIANGLES, 0, 6);
58
59 // Ensure that the frame buffer is red at the sampled pixel
60 var buf = new Uint8Array(1 * 1 * 4);
61 gl.readPixels(2, 2, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
62 var passed = true;
63 if (buf[0] != 255 ||
64 buf[1] != 0 ||
65 buf[2] != 0 ||
66 buf[3] != 255) {
67 testFailed("Pixel at (2, 2) should have been (255, 0, 0, 255), " +
68 "was (" + buf[0] + ", " + buf[1] + ", " + buf[2] + ", " + buf[3] + ")");
69 passed = false;
70 }
71
72 if (passed) {
73 // Now resize the canvas
74 glErrorShouldBe(gl, gl.NO_ERROR, "No GL errors before resizing the canvas");
75 var canvas = document.getElementById("example");
76 canvas.width = 8;
77 canvas.height = 8;
78 err = gl.getError();
79 // Some implementations might lost the context when resizing
80 if (err == gl.CONTEXT_LOST_WEBGL) {
81 testPassed("canvas lost context on resize");
82 } else {
83 shouldBe("err", "gl.NO_ERROR");
84 // Do another render
85 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
86 gl.drawArrays(gl.TRIANGLES, 0, 6);
87 // This time, because we did not change the viewport, it should
88 // still be (0, 0, 4, 4), so only the lower-left quadrant should
89 // have been filled.
90 var buf = new Uint8Array(1 * 1 * 4);
91 gl.readPixels(6, 6, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
92 var passed = true;
93 if (buf[0] != 0 ||
94 buf[1] != 0 ||
95 buf[2] != 255 ||
96 buf[3] != 255) {
97 testFailed("Pixel at (6, 6) should have been (0, 0, 255, 255), " +
98 "was (" + buf[0] + ", " + buf[1] + ", " + buf[2] + ", " + buf[3 ] + ")");
99 passed = false;
100 }
101 if (passed) {
102 testPassed("Viewport correctly did not change size during canvas resize");
103 }
104 }
105 }
106
107 successfullyParsed = true;
108 </script>
109 <script src="../../resources/js-test-post.js"></script>
110 </body>
111 </html>
112
OLDNEW
« no previous file with comments | « conformance/canvas/drawingbuffer-test.html ('k') | conformance/context/00_test_list.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698