Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 11 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 12 | <script src="../resources/webgl-test.js"></script> |
michael@0 | 13 | <script src="../resources/webgl-test-utils.js"></script> |
michael@0 | 14 | <script id="fshader" type="x-shader/x-fragment"> |
michael@0 | 15 | precision mediump float; |
michael@0 | 16 | |
michael@0 | 17 | uniform sampler2D tex; |
michael@0 | 18 | varying vec2 texCoord; |
michael@0 | 19 | |
michael@0 | 20 | void main() |
michael@0 | 21 | { |
michael@0 | 22 | float intensity = texture2D(tex, texCoord).a; |
michael@0 | 23 | gl_FragColor = vec4(intensity, intensity, intensity, 1.0); |
michael@0 | 24 | } |
michael@0 | 25 | </script> |
michael@0 | 26 | |
michael@0 | 27 | </head> |
michael@0 | 28 | <body> |
michael@0 | 29 | <canvas id="example" width="256px" height="1px"></canvas> |
michael@0 | 30 | <div id="description"></div> |
michael@0 | 31 | <div id="console"></div> |
michael@0 | 32 | <script> |
michael@0 | 33 | description('Tests texSubImage2D upload path from Uint8Array'); |
michael@0 | 34 | |
michael@0 | 35 | var wtu = WebGLTestUtils; |
michael@0 | 36 | var canvas = document.getElementById("example"); |
michael@0 | 37 | var gl = wtu.create3DContext(canvas); |
michael@0 | 38 | gl.disable(gl.DITHER); |
michael@0 | 39 | var program = wtu.setupProgram( |
michael@0 | 40 | gl, |
michael@0 | 41 | [wtu.setupSimpleTextureVertexShader(gl), "fshader"], |
michael@0 | 42 | ['vPosition', 'texCoord0']); |
michael@0 | 43 | wtu.setupUnitQuad(gl); |
michael@0 | 44 | var textureWidth = 256; |
michael@0 | 45 | var textureHeight = 1; |
michael@0 | 46 | |
michael@0 | 47 | textureLoc = gl.getUniformLocation(program, "tex"); |
michael@0 | 48 | |
michael@0 | 49 | var texture = gl.createTexture(); |
michael@0 | 50 | gl.bindTexture(gl.TEXTURE_2D, texture); |
michael@0 | 51 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
michael@0 | 52 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
michael@0 | 53 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); |
michael@0 | 54 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); |
michael@0 | 55 | // Allocate the texture object |
michael@0 | 56 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, textureWidth, textureHeight, 0, gl.ALPHA, gl.UNSIGNED_BYTE, null); |
michael@0 | 57 | // Prepare the image data |
michael@0 | 58 | var array = new Uint8Array(textureWidth); |
michael@0 | 59 | for (var i = 0; i < textureWidth; i++) |
michael@0 | 60 | array[i] = i; |
michael@0 | 61 | // Fill the texture object with data -- this is actually the code path being tested |
michael@0 | 62 | gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, textureWidth, textureHeight, gl.ALPHA, gl.UNSIGNED_BYTE, array); |
michael@0 | 63 | |
michael@0 | 64 | // Clear and set up |
michael@0 | 65 | gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
michael@0 | 66 | gl.bindTexture(gl.TEXTURE_2D, texture); |
michael@0 | 67 | gl.useProgram(program); |
michael@0 | 68 | gl.uniform1i(textureLoc, 0); |
michael@0 | 69 | // Draw the texture to the frame buffer |
michael@0 | 70 | gl.drawArrays(gl.TRIANGLES, 0, 6); |
michael@0 | 71 | |
michael@0 | 72 | // Read back the frame buffer |
michael@0 | 73 | var buf = new Uint8Array(textureWidth * textureHeight * 4); |
michael@0 | 74 | gl.readPixels(0, 0, textureWidth, textureHeight, gl.RGBA, gl.UNSIGNED_BYTE, buf); |
michael@0 | 75 | |
michael@0 | 76 | // Verify the frame buffer's contents |
michael@0 | 77 | var passed = true; |
michael@0 | 78 | for (var i = 0; i < textureWidth; i++) { |
michael@0 | 79 | var val = i; |
michael@0 | 80 | if (buf[4 * i + 0] != val || |
michael@0 | 81 | buf[4 * i + 1] != val || |
michael@0 | 82 | buf[4 * i + 2] != val) { |
michael@0 | 83 | testFailed("pixel at (" + i + ", 0) was (" + |
michael@0 | 84 | buf[4 * i + 0] + ", " + |
michael@0 | 85 | buf[4 * i + 1] + ", " + |
michael@0 | 86 | buf[4 * i + 2] + "), should be (" + |
michael@0 | 87 | val + ", " + val + ", " + val + ")"); |
michael@0 | 88 | passed = false; |
michael@0 | 89 | break; |
michael@0 | 90 | } |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | if (passed) |
michael@0 | 94 | testPassed(""); |
michael@0 | 95 | |
michael@0 | 96 | successfullyParsed = true; |
michael@0 | 97 | </script> |
michael@0 | 98 | <script>finishTest();</script> |
michael@0 | 99 | </body> |
michael@0 | 100 | </html> |