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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

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.)

     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 Test
     9  *
    10  * Clear the four quadrants of the canvas as follows:
    11  * +------+------+
    12  * | red  |green |
    13  * |      |      |
    14  * +------+------+
    15  * | blue |white |
    16  * |      |      |
    17  * +------+------+
    18  *
    19  * This is for checking that we're getting the right colors when
    20  * we ask for them. This combined with the Orientation test assure
    21  * that we are getting the correct colors in the correct places.
    22  */
    24 "use strict";
    26 function renderGL(gl) {
    27   gl.enable(gl.SCISSOR_TEST);
    29   gl.scissor(0, 128, 128, 128);
    30   gl.clearColor(1.0, 0.0, 0.0, 1.0);
    31   gl.clear(gl.COLOR_BUFFER_BIT);
    33   gl.scissor(128, 128, 128, 128);
    34   gl.clearColor(0.0, 1.0, 0.0, 1.0);
    35   gl.clear(gl.COLOR_BUFFER_BIT);
    37   gl.scissor(0, 0, 128, 128);
    38   gl.clearColor(0.0, 0.0, 1.0, 1.0);
    39   gl.clear(gl.COLOR_BUFFER_BIT);
    41   gl.scissor(128, 0, 128, 128);
    42   gl.clearColor(1.0, 1.0, 1.0, 1.0);
    43   gl.clear(gl.COLOR_BUFFER_BIT);
    45   gl.finish();
    46 }
    48 function renderFailure(canvas) {
    49   // This will also trigger RAF for us.
    50   var context = canvas.getContext("2d");
    51   context.fillText('WebGL failed.', 64, 64);
    52 }
    54 function runTest() {
    55   var canvas = document.getElementById("canvas");
    56   var gl = initGL(canvas);
    58   if (gl)
    59     renderGL(gl);
    60   else
    61     renderFailure(canvas);
    63   waitForComposite(testComplete);
    64 }
    66 function testComplete() {
    67   document.documentElement.removeAttribute("class");
    68 }
    69 </script>
    70 </head>
    72 <body onload="rAF(runTest);">
    73   <canvas id="canvas" width="256" height="256"></canvas>
    74 </body>
    76 </html>

mercurial