content/canvas/test/reftest/webgl-color-alpha-test.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE html>
michael@0 2 <html class="reftest-wait">
michael@0 3 <head>
michael@0 4 <meta charset="UTF-8">
michael@0 5
michael@0 6 <script type="text/javascript" src="webgl-utils.js"></script>
michael@0 7 <script type="text/javascript">
michael@0 8 /* Color-Alpha Test
michael@0 9 *
michael@0 10 * Clear the four quadrants of the canvas as follows:
michael@0 11 * +------+------+
michael@0 12 * | red |green |
michael@0 13 * | | |
michael@0 14 * +------+------+
michael@0 15 * | blue |white |
michael@0 16 * | | |
michael@0 17 * +------+------+
michael@0 18 * However, unlike the Color test, clear with a given alpha value.
michael@0 19 * What effect this has depends on the context-creation args passed
michael@0 20 * to this page.
michael@0 21 *
michael@0 22 * Here we check that we handle various combinations of alpha and
michael@0 23 * premultipliedAlpha correctly.
michael@0 24 */
michael@0 25
michael@0 26 "use strict";
michael@0 27
michael@0 28 function renderGL(gl, value, alpha) {
michael@0 29 gl.enable(gl.SCISSOR_TEST);
michael@0 30
michael@0 31 gl.scissor(0, 128, 128, 128);
michael@0 32 gl.clearColor(value, 0.0, 0.0, alpha);
michael@0 33 gl.clear(gl.COLOR_BUFFER_BIT);
michael@0 34
michael@0 35 gl.scissor(128, 128, 128, 128);
michael@0 36 gl.clearColor(0.0, value, 0.0, alpha);
michael@0 37 gl.clear(gl.COLOR_BUFFER_BIT);
michael@0 38
michael@0 39 gl.scissor(0, 0, 128, 128);
michael@0 40 gl.clearColor(0.0, 0.0, value, alpha);
michael@0 41 gl.clear(gl.COLOR_BUFFER_BIT);
michael@0 42
michael@0 43 gl.scissor(128, 0, 128, 128);
michael@0 44 gl.clearColor(value, value, value, alpha);
michael@0 45 gl.clear(gl.COLOR_BUFFER_BIT);
michael@0 46
michael@0 47 gl.finish();
michael@0 48 }
michael@0 49
michael@0 50 function renderFailure(canvas) {
michael@0 51 // This will also trigger RAF for us.
michael@0 52 var context = canvas.getContext("2d");
michael@0 53 context.fillText('WebGL failed.', 64, 64);
michael@0 54 }
michael@0 55
michael@0 56 function runTest() {
michael@0 57 var canvas = document.getElementById("canvas");
michael@0 58 var gl = initGL(canvas);
michael@0 59
michael@0 60 var value = arg("colorVal");
michael@0 61 var alpha = arg("alphaVal");
michael@0 62
michael@0 63 if (gl)
michael@0 64 renderGL(gl, value, alpha);
michael@0 65 else
michael@0 66 renderFailure(canvas);
michael@0 67
michael@0 68 waitForComposite(testComplete);
michael@0 69 }
michael@0 70
michael@0 71 function testComplete() {
michael@0 72 document.documentElement.removeAttribute("class");
michael@0 73 }
michael@0 74 </script>
michael@0 75 </head>
michael@0 76
michael@0 77 <body onload="rAF(runTest);">
michael@0 78 <canvas id="canvas" width="256" height="256"></canvas>
michael@0 79 </body>
michael@0 80
michael@0 81 </html>

mercurial