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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/copy-tex-image-and-sub-image-2d.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 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
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2010 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 <link rel="stylesheet" href="../resources/js-test-style.css"/>
9 <script src="../resources/js-test-pre.js"></script>
10 <script src="resources/webgl-test.js"></script>
11 <script src="resources/webgl-test-utils.js"></script>
12
13 <script>
14 var successfullyParsed = false;
15
16 function init()
17 {
18 if (window.initNonKhronosFramework) {
19 window.initNonKhronosFramework(true);
20 }
21
22 description('Verify copyTexImage2D and copyTexSubImage2D');
23
24 runTest();
25 }
26
27 var gl = null;
28 var wtu = WebGLTestUtils;
29
30 function runTestIteration(antialias)
31 {
32 var canvas = document.getElementById(
33 antialias ? "antialiasOn" : "antialiasOff");
34 var attribs = antialias ? { antialias: false } : undefined;
35 gl = wtu.create3DContext(canvas, attribs);
36 var program = wtu.setupTexturedQuad(gl);
37 var textureLoc = gl.getUniformLocation(program, "tex");
38 glErrorShouldBe(gl, gl.NO_ERROR, "During Initialization");
39
40 gl.colorMask(1, 1, 1, 1);
41 gl.disable(gl.BLEND);
42 debug('Testing copyTexImage2D');
43
44 // Red canvas
45 gl.clearColor(1, 0, 0, 1);
46 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
47
48 var texture = gl.createTexture();
49 // Bind the texture to texture unit 0
50 gl.bindTexture(gl.TEXTURE_2D, texture);
51 // Set up texture
52 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
53 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
54 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
55 gl.uniform1i(textureLoc, 0);
56
57 var colors = [
58 [1, 0, 0, 1],
59 [0, 1, 0, 1],
60 [0, 0, 1, 1],
61 [0.5, 0.5, 0.5, 0.5],
62 ];
63 var count = 0;
64 for (var yy = -2; yy <= 2; ++yy) {
65 for (var xx = -2; xx <= 2; ++xx) {
66 for (var ii = 0; ii < 2; ++ii) {
67 var texColor = colors[count];
68 var clearColor = colors[(count + 1) % colors.length];
69 // clear to some color
70 gl.clearColor(texColor[0], texColor[1], texColor[2], texColor[3]);
71 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
72
73 // copy that color to the texture.
74 switch (ii) {
75 case 0:
76 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, xx, yy, 2, 2, 0);
77 glErrorShouldBe(gl, gl.NO_ERROR,
78 "using copyTexImage2D: x =" + xx + ", y = " + yy);
79 break;
80 case 1:
81 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, xx, yy, 2, 2);
82 glErrorShouldBe(gl, gl.NO_ERROR,
83 "using copyTexSubImage2D: x =" + xx + ", y = " + yy);
84 break;
85 }
86
87 // clear to some other color.
88 gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[ 3]);
89 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
90
91 // Draw the triangles
92 wtu.drawQuad(gl);
93
94 // check the rendering results
95 for (var iy = 0; iy < 2; ++iy) {
96 for (var ix = 0; ix < 2; ++ix) {
97 var x = xx + ix;
98 var y = yy + iy;
99 var expectedColor = (x < 0 || y < 0 || x >= 2 || y >= 2) ?
100 [0,0,0,0] :
101 [Math.floor(255 * texColor[0]),
102 Math.floor(255 * texColor[1]),
103 Math.floor(255 * texColor[2]),
104 Math.floor(255 * texColor[3])];
105 wtu.checkCanvasRect(gl, ix, iy, 1, 1, expectedColor,
106 "" + ix + ", " + iy + " should render " + expectedColor + " (+ /-1)", 1);
107 }
108 }
109 count = (count + 1) % colors.length;
110 }
111 }
112 }
113
114 debug("");
115 }
116
117 function runTest(antialias)
118 {
119 debug("Testing with antialias on");
120 runTestIteration(true);
121 debug("Testing with antialias off");
122 runTestIteration(false);
123
124 finishTest();
125 }
126 </script>
127 </head>
128 <body onload="init()">
129 <canvas id="antialiasOn" width="2px" height="2px"></canvas>
130 <canvas id="antialiasOff" width="2px" height="2px"></canvas>
131 <div id="description"></div>
132 <div id="console"></div>
133 </body>
134 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698