Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>WebGL texture2D GLSL conformance test.</title>
11 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
12 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
13 <script src="../../../resources/js-test-pre.js"></script>
14 <script src="../../resources/webgl-test.js"> </script>
15 <script src="../../resources/webgl-test-utils.js"> </script>
16 </head>
17 <body>
18 <canvas id="example" width="32" height="32"></canvas>
19 <div id="description"></div>
20 <div id="console"></div>
21 <script id="vshader0" type="x-shader/x-vertex">
22 attribute vec4 vPosition;
23 attribute vec2 texCoord0;
24 varying vec2 texCoord;
25 void main() {
26 gl_Position = vPosition;
27 texCoord = texCoord0;
28 }
29 </script>
30 <script id="fshader0" type="x-shader/x-vertex">
31 precision mediump float;
32 uniform sampler2D tex;
33 uniform float divisor;
34 varying vec2 texCoord;
35 void main() {
36 gl_FragData[0] = texture2DProj(tex, vec3(texCoord, divisor));
37 }
38 </script>
39 <script id="vshader1" type="x-shader/x-vertex">
40 attribute vec4 vPosition;
41 attribute vec2 texCoord0;
42 varying vec2 texCoord;
43 void main() {
44 gl_Position = vPosition;
45 texCoord = texCoord0;
46 }
47 </script>
48 <script id="fshader1" type="x-shader/x-vertex">
49 precision mediump float;
50 uniform sampler2D tex;
51 uniform float divisor;
52 varying vec2 texCoord;
53 void main() {
54 gl_FragData[0] = texture2DProj(tex, vec4(texCoord, 123.0, divisor));
55 }
56 </script>
57 <script>
58 description("tests GLSL texture2DProj function with");
60 var wtu = WebGLTestUtils;
61 var gl = wtu.create3DContext("example", {antialias: false});
63 wtu.setupUnitQuad(gl, 0, 1);
64 var tex = gl.createTexture();
65 gl.bindTexture(gl.TEXTURE_2D, tex);
66 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
67 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
68 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
69 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
71 var c = document.createElement("canvas");
72 c.width = 16;
73 c.height = 16;
74 var ctx = c.getContext("2d");
75 ctx.fillStyle = "rgb(0,255,0)";
76 ctx.fillRect(0, 0, 16, 16);
77 ctx.fillStyle = "rgb(0,0,255)";
78 ctx.fillRect(0, 0, 8, 8);
79 ctx.fillRect(8, 8, 8, 8);
81 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c);
83 for (var ss = 0; ss < 2; ++ss) {
84 debug("");
85 debug(ss ? "testing vec4 version" : "testing vec3 version");
86 var program = wtu.setupProgram(
87 gl, ['vshader' + ss, 'fshader' + ss],
88 ['vPosition', 'texCoord0'], [0, 1]);
89 gl.useProgram(program);
90 var loc = gl.getUniformLocation(program, "divisor");
92 for (var ii = 0; ii < 3; ++ii) {
93 var denominator = Math.pow(2, ii);
94 gl.uniform1f(loc, 1 / denominator);
95 wtu.drawQuad(gl);
96 var size = 16 / denominator;
97 for (var yy = 0; yy < 32; yy += size) {
98 for (var xx = 0; xx < 32; xx += size) {
99 var odd = (xx / size + yy / size) % 2;
100 var color = odd ? [0, 255, 0, 255] : [0, 0, 255, 255];
101 var msg = "" + xx + ", " + yy + ", " + size + ", " + size + " should be " + (odd ? "green" : "blue");
102 wtu.checkCanvasRect(gl, xx, yy, size, size, color, msg);
103 }
104 }
105 }
106 }
107 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
109 successfullyParsed = true;
111 </script>
112 <script>finishTest();</script>
114 </body>
115 </html>