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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/tex-image-and-sub-image-2d-with-image.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 <script>
13 var wtu = WebGLTestUtils;
14 var gl = null;
15 var textureLoc = null;
16 var successfullyParsed = false;
17
18 function init()
19 {
20 if (window.initNonKhronosFramework) {
21 window.initNonKhronosFramework(true);
22 }
23
24 description('Verify texImage2D and texSubImage2D code paths taking Images');
25
26 var canvas = document.getElementById("example");
27 gl = wtu.create3DContext(canvas);
28 var program = wtu.setupTexturedQuad(gl);
29
30 gl.clearColor(0,0,0,1);
31 gl.clearDepth(1);
32
33 textureLoc = gl.getUniformLocation(gl.program, "tex");
34
35 wtu.loadTexture(gl, "resources/red-green.png", runTest);
36 }
37
38 // These two declarations need to be global for "shouldBe" to see them
39 var buf = null;
40 var idx = 0;
41 var pixel = [0, 0, 0];
42 var correctColor = null;
43
44 function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor)
45 {
46 debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
47 ' with flipY=' + flipY);
48 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
49 // Disable any writes to the alpha channel
50 gl.colorMask(1, 1, 1, 0);
51 var texture = gl.createTexture();
52 // Bind the texture to texture unit 0
53 gl.bindTexture(gl.TEXTURE_2D, texture);
54 // Set up texture parameters
55 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
56 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
57 // Set up pixel store parameters
58 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
59 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
60 gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
61 // Upload the image into the texture
62 if (useTexSubImage2D) {
63 // Initialize the texture to black first
64 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, image.width, image.height, 0,
65 gl.RGBA, gl.UNSIGNED_BYTE, null);
66 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, imag e);
67 } else {
68 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imag e);
69 }
70
71 // Point the uniform sampler to texture unit 0
72 gl.uniform1i(textureLoc, 0);
73 // Draw the triangles
74 wtu.drawQuad(gl, [0, 0, 0, 255]);
75 // Check a few pixels near the top and bottom and make sure they have
76 // the right color.
77 debug("Checking lower left corner");
78 wtu.checkCanvasRect(gl, 4, 4, 2, 2, bottomColor,
79 "shouldBe " + bottomColor);
80 debug("Checking upper left corner");
81 wtu.checkCanvasRect(gl, 4, gl.canvas.height - 8, 2, 2, topColor,
82 "shouldBe " + topColor);
83 }
84
85 function runTest(image)
86 {
87 var red = [255, 0, 0];
88 var green = [0, 255, 0];
89 runOneIteration(image, false, true, red, green);
90 runOneIteration(image, false, false, green, red);
91 runOneIteration(image, true, true, red, green);
92 runOneIteration(image, true, false, green, red);
93
94 finishTest();
95 }
96
97 </script>
98 </head>
99 <body onload="init()">
100 <canvas id="example" width="32px" height="32px"></canvas>
101 <div id="description"></div>
102 <div id="console"></div>
103 </body>
104 </html>
105
106
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698