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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/textures/gl-pixelstorei.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <title>WebGL pixelStorei Test</title>
33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
34 <script src="../../resources/js-test-pre.js"></script>
35 <script src="../resources/webgl-test.js"> </script>
36 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></s cript>
37 </head>
38 <body>
39 <canvas id="example" width="50" height="50"></canvas>
40 <canvas id="2d00" width="50" height="50"></canvas>
41 <canvas id="2d01" width="50" height="50"></canvas>
42 <canvas id="2d02" width="50" height="50"></canvas>
43 <canvas id="2d03" width="50" height="50"></canvas>
44 <div id="description"></div>
45 <div id="console"></div>
46 <script id="vshader" type="x-shader/x-vertex">
47 attribute vec4 vPosition;
48 void main() {
49 gl_Position = vPosition;
50 }
51 </script>
52
53 <script id="fshader" type="x-shader/x-fragment">
54 void main() {
55 gl_FragColor = vec4(1.0,0.0,0.0,1.0);
56 }
57 </script>
58
59 <script>
60 function fail(x,y, name, buf, shouldBe) {
61 var i = (y*50+x) * 4;
62 var reason = "pixel in "+name+" at ("+x+","+y+") is ("+buf[i]+","+buf[i+1]+"," +buf[i+2]+","+buf[i+3]+"), should be "+shouldBe;
63 testFailed(reason);
64 }
65
66 function pass(name) {
67 testPassed("drawing is correct in " + name);
68 }
69
70 function init() {
71 description("This test checks that drawImage and readPixels are not effected b y gl.Pixelstorei(gl.PACK_ALIGNMENT) and visa versa");
72
73 debug("There should be 5 red triangles on 5 black squares above");
74 debug("");
75
76 var canvas3d = document.getElementById("example");
77 gl = initWebGL("example");
78 program = setupProgram(gl, "vshader", "fshader", [ "vPosition"]);
79
80 var vertexObject = gl.createBuffer();
81 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
82 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0 .5,0 ]), gl.STATIC_DRAW);
83 gl.enableVertexAttribArray(0);
84 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
85
86 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
87 gl.drawArrays(gl.TRIANGLES, 0, 3);
88
89
90 function checkData(buf, name) {
91 // Test several locations
92 // First line should be all black
93 for (var i = 0; i < 50; ++i) {
94 if (buf[i*4] != 0 || buf[i*4+1] != 0 || buf[i*4+2] != 0 || buf[i*4+3] != 2 55) {
95 fail(i, 0, name, buf, "(0,0,0,255)");
96 return;
97 }
98 }
99
100 // Line 25 should be red for at least 6 red pixels starting 22 pixels in
101 var offset = (25*50+22) * 4;
102 for (var i = 0; i < 6; ++i) {
103 if (buf[offset+i*4] != 255 || buf[offset+i*4+1] != 0 || buf[offset+i*4+2] != 0 || buf[offset+i*4+3] != 255) {
104 fail(22 + i, 25, name, buf, "(255,0,0,255)");
105 return;
106 }
107 }
108
109 // Last line should be all black
110 offset = (49*50) * 4;
111 for (var i = 0; i < 50; ++i) {
112 if (buf[offset+i*4] != 0 || buf[offset+i*4+1] != 0 || buf[offset+i*4+2] != 0 || buf[offset+i*4+3] != 255) {
113 fail(i, 49, name, buf, "(0,0,0,255)");
114 return;
115 }
116 }
117
118 pass(name);
119 }
120
121 function checkColors() {
122 var buf = new Uint8Array(50 * 50 * 4);
123 gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, buf);
124 checkData(buf, "3d context");
125 var imgData = ctx2d.getImageData(0, 0, 50, 50);
126 checkData(imgData.data, "2d context");
127 }
128
129 var table = [1, 2, 4, 8];
130 for (var ii = 0; ii < table.length; ++ii) {
131 gl.pixelStorei(gl.PACK_ALIGNMENT, table[ii]);
132 ctx2d = document.getElementById("2d0" + ii).getContext("2d");
133 ctx2d.globalCompositeOperation = 'copy';
134 ctx2d.drawImage(canvas3d, 0, 0);
135 checkColors();
136 assertMsg(gl.getParameter(gl.PACK_ALIGNMENT) == table[ii],
137 "PACK_ALIGNMENT is " + table[ii]);
138 }
139 }
140
141 init();
142 successfullyParsed = true;
143 </script>
144 <script src="../../resources/js-test-post.js"></script>
145
146 </body>
147 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698