1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/reftest/webgl-color-alpha-test.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +<!DOCTYPE html> 1.5 +<html class="reftest-wait"> 1.6 +<head> 1.7 +<meta charset="UTF-8"> 1.8 + 1.9 +<script type="text/javascript" src="webgl-utils.js"></script> 1.10 +<script type="text/javascript"> 1.11 +/* Color-Alpha Test 1.12 + * 1.13 + * Clear the four quadrants of the canvas as follows: 1.14 + * +------+------+ 1.15 + * | red |green | 1.16 + * | | | 1.17 + * +------+------+ 1.18 + * | blue |white | 1.19 + * | | | 1.20 + * +------+------+ 1.21 + * However, unlike the Color test, clear with a given alpha value. 1.22 + * What effect this has depends on the context-creation args passed 1.23 + * to this page. 1.24 + * 1.25 + * Here we check that we handle various combinations of alpha and 1.26 + * premultipliedAlpha correctly. 1.27 + */ 1.28 + 1.29 +"use strict"; 1.30 + 1.31 +function renderGL(gl, value, alpha) { 1.32 + gl.enable(gl.SCISSOR_TEST); 1.33 + 1.34 + gl.scissor(0, 128, 128, 128); 1.35 + gl.clearColor(value, 0.0, 0.0, alpha); 1.36 + gl.clear(gl.COLOR_BUFFER_BIT); 1.37 + 1.38 + gl.scissor(128, 128, 128, 128); 1.39 + gl.clearColor(0.0, value, 0.0, alpha); 1.40 + gl.clear(gl.COLOR_BUFFER_BIT); 1.41 + 1.42 + gl.scissor(0, 0, 128, 128); 1.43 + gl.clearColor(0.0, 0.0, value, alpha); 1.44 + gl.clear(gl.COLOR_BUFFER_BIT); 1.45 + 1.46 + gl.scissor(128, 0, 128, 128); 1.47 + gl.clearColor(value, value, value, alpha); 1.48 + gl.clear(gl.COLOR_BUFFER_BIT); 1.49 + 1.50 + gl.finish(); 1.51 +} 1.52 + 1.53 +function renderFailure(canvas) { 1.54 + // This will also trigger RAF for us. 1.55 + var context = canvas.getContext("2d"); 1.56 + context.fillText('WebGL failed.', 64, 64); 1.57 +} 1.58 + 1.59 +function runTest() { 1.60 + var canvas = document.getElementById("canvas"); 1.61 + var gl = initGL(canvas); 1.62 + 1.63 + var value = arg("colorVal"); 1.64 + var alpha = arg("alphaVal"); 1.65 + 1.66 + if (gl) 1.67 + renderGL(gl, value, alpha); 1.68 + else 1.69 + renderFailure(canvas); 1.70 + 1.71 + waitForComposite(testComplete); 1.72 +} 1.73 + 1.74 +function testComplete() { 1.75 + document.documentElement.removeAttribute("class"); 1.76 +} 1.77 +</script> 1.78 +</head> 1.79 + 1.80 +<body onload="rAF(runTest);"> 1.81 + <canvas id="canvas" width="256" height="256"></canvas> 1.82 +</body> 1.83 + 1.84 +</html>