1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/textures/texture-transparent-pixels-initialized.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +<!-- 1.5 +Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.6 + 1.7 +Redistribution and use in source and binary forms, with or without 1.8 +modification, are permitted provided that the following conditions are 1.9 +met: 1.10 + 1.11 + * Redistributions of source code must retain the above copyright 1.12 +notice, this list of conditions and the following disclaimer. 1.13 + * Redistributions in binary form must reproduce the above 1.14 +copyright notice, this list of conditions and the following disclaimer 1.15 +in the documentation and/or other materials provided with the 1.16 +distribution. 1.17 + * Neither the name of Google Inc. nor the names of its 1.18 +contributors may be used to endorse or promote products derived from 1.19 +this software without specific prior written permission. 1.20 + 1.21 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.22 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.23 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.24 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.25 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.26 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.27 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.28 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.29 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.30 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.31 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.32 +--> 1.33 +<!DOCTYPE html> 1.34 +<html> 1.35 +<head> 1.36 +<meta charset="utf-8"> 1.37 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.38 +<script src="../../resources/js-test-pre.js"></script> 1.39 +<script src="../resources/webgl-test.js"></script> 1.40 +<script src="../resources/webgl-test-utils.js"></script> 1.41 +<script> 1.42 +var wtu = WebGLTestUtils; 1.43 +var gl = null; 1.44 +var textureLoc = null; 1.45 +var successfullyParsed = false; 1.46 + 1.47 +function init() 1.48 +{ 1.49 + if (window.initNonKhronosFramework) { 1.50 + window.initNonKhronosFramework(true); 1.51 + } 1.52 + 1.53 + description('Tests there is no garbage in transparent regions of images uploaded as textures'); 1.54 + 1.55 + wtu = WebGLTestUtils; 1.56 + gl = wtu.create3DContext("example"); 1.57 + var program = wtu.setupTexturedQuad(gl); 1.58 + gl.clearColor(0.5,0.5,0.5,1); 1.59 + gl.clearDepth(1); 1.60 + 1.61 + textureLoc = gl.getUniformLocation(program, "tex"); 1.62 + 1.63 + // The input texture has 8 characters; take the leftmost one 1.64 + var coeff = 1.0 / 8.0; 1.65 + var texCoords = new Float32Array([ 1.66 + coeff, 1.0, 1.67 + 0.0, 1.0, 1.68 + 0.0, 0.0, 1.69 + coeff, 1.0, 1.70 + 0.0, 0.0, 1.71 + coeff, 0.0]); 1.72 + 1.73 + var vbo = gl.createBuffer(); 1.74 + gl.bindBuffer(gl.ARRAY_BUFFER, vbo); 1.75 + gl.bufferData(gl.ARRAY_BUFFER, texCoords, gl.STATIC_DRAW); 1.76 + gl.enableVertexAttribArray(1); 1.77 + gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0); 1.78 + 1.79 + texture = wtu.loadTexture(gl, "../resources/bug-32888-texture.png", runTest); 1.80 +} 1.81 + 1.82 +// These two declarations need to be global for "shouldBe" to see them 1.83 +var buf = null; 1.84 +var idx = 0; 1.85 + 1.86 +function runTest() 1.87 +{ 1.88 + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 1.89 + gl.enable(gl.BLEND); 1.90 + gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); 1.91 + // Bind the texture to texture unit 0 1.92 + gl.bindTexture(gl.TEXTURE_2D, texture); 1.93 + // Point the uniform sampler to texture unit 0 1.94 + gl.uniform1i(textureLoc, 0); 1.95 + // Draw the triangles 1.96 + wtu.drawQuad(gl, [0, 0, 0, 255]); 1.97 + 1.98 + // Spot check a couple of 2x2 regions in the upper and lower left 1.99 + // corners; they should be the rgb values in the texture. 1.100 + color = [0, 0, 0]; 1.101 + debug("Checking lower left corner"); 1.102 + wtu.checkCanvasRect(gl, 1, gl.canvas.height - 3, 2, 2, color, 1.103 + "shouldBe " + color); 1.104 + debug("Checking upper left corner"); 1.105 + wtu.checkCanvasRect(gl, 1, 1, 2, 2, color, 1.106 + "shouldBe " + color); 1.107 + 1.108 + finishTest(); 1.109 +} 1.110 +</script> 1.111 +</head> 1.112 +<body onload="init()"> 1.113 +<canvas id="example" width="32px" height="32px"></canvas> 1.114 +<div id="description"></div> 1.115 +<div id="console"></div> 1.116 +</body> 1.117 +</html>