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.

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

mercurial