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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/tex-image-and-sub-image-2d-with-image-data.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 var imageData = null;
18
19 function init()
20 {
21 if (window.initNonKhronosFramework) {
22 window.initNonKhronosFramework(true);
23 }
24
25 description('Verify texImage2D and texSubImage2D code paths taking ImageData ');
26
27 var canvas2d = document.getElementById("texcanvas");
28 var context2d = canvas2d.getContext("2d");
29 imageData = context2d.createImageData(1, 2);
30 var data = imageData.data;
31 data[0] = 255;
32 data[1] = 0;
33 data[2] = 0;
34 data[3] = 255;
35 data[4] = 0;
36 data[5] = 255;
37 data[6] = 0;
38 data[7] = 0;
39
40 wtu = WebGLTestUtils;
41 var canvas = document.getElementById("example");
42 gl = wtu.create3DContext(canvas);
43 var program = wtu.setupTexturedQuad(gl);
44 gl.clearColor(0,0,0,1);
45 gl.clearDepth(1);
46 gl.disable(gl.BLEND);
47
48 textureLoc = gl.getUniformLocation(program, "tex");
49
50 runTest();
51 }
52
53 // These two declarations need to be global for "shouldBe" to see them
54 var buf = null;
55 var idx = 0;
56 var pixel = [0, 0, 0, 1];
57 var correctColor = null;
58
59 function runOneIteration(useTexSubImage2D, flipY, premultiplyAlpha, topColor, bo ttomColor)
60 {
61 debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
62 ' with flipY=' + flipY + ' and premultiplyAlpha=' + premultiplyAlpha);
63 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
64 // Enable writes to the RGBA channels
65 gl.colorMask(1, 1, 1, 0);
66 var texture = gl.createTexture();
67 // Bind the texture to texture unit 0
68 gl.bindTexture(gl.TEXTURE_2D, texture);
69 // Set up texture parameters
70 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
71 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
72 // Set up pixel store parameters
73 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
74 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha);
75 // Upload the image into the texture
76 if (useTexSubImage2D) {
77 // Initialize the texture to black first
78 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 2, 0,
79 gl.RGBA, gl.UNSIGNED_BYTE, null);
80 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, imag eData);
81 } else {
82 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imag eData);
83 }
84
85 // Point the uniform sampler to texture unit 0
86 gl.uniform1i(textureLoc, 0);
87 // Draw the triangles
88 wtu.drawQuad(gl, [0, 0, 0, 255]);
89
90 // Read back the rendering results
91 buf = new Uint8Array(1 * 2 * 4);
92 gl.readPixels(0, 0, 1, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
93 // Check the top pixel and bottom pixel and make sure they have
94 // the right color.
95 debug("Checking bottom pixel");
96 wtu.checkCanvasRect(gl, 0, 0, 1, 1, bottomColor, "shouldBe " + bottomColor);
97 debug("Checking top pixel");
98 wtu.checkCanvasRect(gl, 0, 1, 1, 1, topColor, "shouldBe " + topColor);
99 }
100
101 function runTest()
102 {
103 var red = [255, 0, 0, 255];
104 var green = [0, 255, 0, 255];
105 var redPremultiplyAlpha = [255, 0, 0, 255];
106 var greenPremultiplyAlpha = [0, 0, 0, 255];
107
108 runOneIteration(false, true, false,
109 red, green);
110 runOneIteration(false, false, false,
111 green, red);
112 runOneIteration(false, true, true,
113 redPremultiplyAlpha, greenPremultiplyAlpha);
114 runOneIteration(false, false, true,
115 greenPremultiplyAlpha, redPremultiplyAlpha);
116 runOneIteration(true, true, false,
117 red, green);
118 runOneIteration(true, false, false,
119 green, red);
120 runOneIteration(true, true, true,
121 redPremultiplyAlpha, greenPremultiplyAlpha);
122 runOneIteration(true, false, true,
123 greenPremultiplyAlpha, redPremultiplyAlpha);
124
125 finishTest();
126 }
127 </script>
128 </head>
129 <body onload="init()">
130 <canvas id="texcanvas" width="1px" height="2px"></canvas>
131 <canvas id="example" width="1px" height="2px"></canvas>
132 <div id="description"></div>
133 <div id="console"></div>
134 </body>
135 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698