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.
michael@0 | 1 | <!-- |
michael@0 | 2 | Copyright (c) 2011 The Chromium Authors. All rights reserved. |
michael@0 | 3 | Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | found in the LICENSE file. |
michael@0 | 5 | --> |
michael@0 | 6 | <!DOCTYPE html> |
michael@0 | 7 | <html> |
michael@0 | 8 | <head> |
michael@0 | 9 | <meta charset="utf-8"> |
michael@0 | 10 | <title>WebGL texture2D GLSL conformance test.</title> |
michael@0 | 11 | <link rel="stylesheet" href="../../../resources/js-test-style.css"/> |
michael@0 | 12 | <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/> |
michael@0 | 13 | <script src="../../../resources/js-test-pre.js"></script> |
michael@0 | 14 | <script src="../../resources/webgl-test.js"> </script> |
michael@0 | 15 | <script src="../../resources/webgl-test-utils.js"> </script> |
michael@0 | 16 | </head> |
michael@0 | 17 | <body> |
michael@0 | 18 | <canvas id="example" width="256" height="256" style="width: 16px; height: 16px;"></canvas> |
michael@0 | 19 | <div id="description"></div> |
michael@0 | 20 | <div id="console"></div> |
michael@0 | 21 | <script id="vshader2d" type="x-shader/x-vertex"> |
michael@0 | 22 | attribute vec4 vPosition; |
michael@0 | 23 | attribute vec2 texCoord0; |
michael@0 | 24 | varying vec2 texCoord; |
michael@0 | 25 | void main() { |
michael@0 | 26 | gl_Position = vPosition; |
michael@0 | 27 | texCoord = texCoord0; |
michael@0 | 28 | } |
michael@0 | 29 | </script> |
michael@0 | 30 | <script id="fshader2d" type="x-shader/x-fragment"> |
michael@0 | 31 | precision mediump float; |
michael@0 | 32 | uniform sampler2D tex; |
michael@0 | 33 | uniform float bias; |
michael@0 | 34 | varying vec2 texCoord; |
michael@0 | 35 | void main() { |
michael@0 | 36 | gl_FragData[0] = texture2D(tex, texCoord, bias); |
michael@0 | 37 | } |
michael@0 | 38 | </script> |
michael@0 | 39 | <script> |
michael@0 | 40 | description("tests GLSL texture2D function with bias"); |
michael@0 | 41 | |
michael@0 | 42 | var wtu = WebGLTestUtils; |
michael@0 | 43 | var canvas = document.getElementById("example"); |
michael@0 | 44 | |
michael@0 | 45 | shouldBe("canvas.width", "256"); |
michael@0 | 46 | shouldBe("canvas.height", "256"); |
michael@0 | 47 | |
michael@0 | 48 | var gl = wtu.create3DContext(canvas); |
michael@0 | 49 | var program = wtu.setupProgram( |
michael@0 | 50 | gl, ['vshader2d', 'fshader2d'], ['vPosition', 'texCoord0'], [0, 1]); |
michael@0 | 51 | wtu.setupUnitQuad(gl, 0, 1); |
michael@0 | 52 | |
michael@0 | 53 | var colors = [ |
michael@0 | 54 | {name: 'red', color:[255, 0, 0, 255]}, |
michael@0 | 55 | {name: 'green', color:[0, 255, 0, 255]}, |
michael@0 | 56 | {name: 'blue', color:[0, 0, 255, 255]}, |
michael@0 | 57 | {name: 'yellow', color:[255, 255, 0, 255]}, |
michael@0 | 58 | {name: 'magenta', color:[255, 0, 255, 255]}, |
michael@0 | 59 | {name: 'cyan', color:[0, 255, 255, 255]}, |
michael@0 | 60 | {name: 'pink', color:[255, 128, 128, 255]}, |
michael@0 | 61 | {name: 'gray', color:[128, 128, 128, 255]}, |
michael@0 | 62 | {name: 'light green', color:[128, 255, 128, 255]}, |
michael@0 | 63 | ]; |
michael@0 | 64 | |
michael@0 | 65 | shouldBe("colors.length", "9"); |
michael@0 | 66 | |
michael@0 | 67 | var tex = gl.createTexture(); |
michael@0 | 68 | gl.bindTexture(gl.TEXTURE_2D, tex); |
michael@0 | 69 | gl.texParameteri( |
michael@0 | 70 | gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); |
michael@0 | 71 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); |
michael@0 | 72 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); |
michael@0 | 73 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); |
michael@0 | 74 | |
michael@0 | 75 | for (var ii = 0; ii < colors.length; ++ii) { |
michael@0 | 76 | var color = colors[ii]; |
michael@0 | 77 | var size = Math.pow(2, colors.length - ii - 1); |
michael@0 | 78 | wtu.fillTexture(gl, tex, size, size, color.color, ii); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | var loc = gl.getUniformLocation(program, "bias"); |
michael@0 | 82 | |
michael@0 | 83 | for (var ii = 0; ii < colors.length; ++ii) { |
michael@0 | 84 | gl.uniform1f(loc, ii); |
michael@0 | 85 | var color = colors[ii]; |
michael@0 | 86 | wtu.drawQuad(gl); |
michael@0 | 87 | wtu.checkCanvas( |
michael@0 | 88 | gl, color.color, |
michael@0 | 89 | "256x256 texture drawn to 256x256 dest with bias = " + ii + |
michael@0 | 90 | " should be " + color.name); |
michael@0 | 91 | } |
michael@0 | 92 | glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors."); |
michael@0 | 93 | |
michael@0 | 94 | successfullyParsed = true; |
michael@0 | 95 | |
michael@0 | 96 | </script> |
michael@0 | 97 | <script>finishTest();</script> |
michael@0 | 98 | |
michael@0 | 99 | </body> |
michael@0 | 100 | </html> |
michael@0 | 101 | |
michael@0 | 102 |