content/canvas/test/webgl-conformance/conformance/rendering/gl-scissor-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 <!--
     2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
     3 Use of this source code is governed by a BSD-style license that can be
     4 found in the LICENSE file.
     5  -->
     6 <!DOCTYPE html>
     7 <html>
     8 <head>
     9 <meta charset="utf-8">
    10 <title>WebGL Scissor Test</title>
    11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
    12 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
    13 <script src="../../debug/webgl-debug.js"></script>
    14 <script src="../../resources/js-test-pre.js"></script>
    15 <script src="../resources/webgl-test-utils.js"></script>
    16 </head>
    17 <body>
    18 <div id="description"></div>
    19 <div id="console"></div>
    20 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"> </canvas>
    21 <script>
    22 description("Check if glScissor setting works.");
    24 debug("");
    25 debug("Canvas.getContext");
    27 var wtu = WebGLTestUtils;
    28 var gl = wtu.create3DContext(document.getElementById("canvas"));
    29 if (!gl) {
    30   testFailed("context does not exist");
    31 } else {
    32   testPassed("context exists");
    34   debug("");
    36   gl.clearColor(0,0,0,0);
    37   gl.clear(gl.COLOR_BUFFER_BIT);
    39   // clear a portion of our FBO
    40   gl.enable(gl.SCISSOR_TEST);
    41   gl.scissor(0, 0, 1, 1);
    42   gl.clearColor(0,1,0,1);
    43   gl.clear(gl.COLOR_BUFFER_BIT);
    45   var b = new Uint8Array(2 * 2 * 4);
    46   gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, b);
    48   function checkPixel(b, x, y, color) {
    49     var offset = (y * 2 + x) * 4;
    50     var match = true;
    51     for (var c = 0; c < 4; ++c) {
    52       if (b[offset + c] != color[c] * 255) {
    53         match = false;
    54         break;
    55       }
    56     }
    57     assertMsg(match, "pixel at " + x + ", " + y + " is expected value");
    58   }
    60   checkPixel(b, 0, 0, [0, 1, 0, 1]);
    61   checkPixel(b, 1, 0, [0, 0, 0, 0]);
    62   checkPixel(b, 0, 1, [0, 0, 0, 0]);
    63   checkPixel(b, 1, 1, [0, 0, 0, 0]);
    64 }
    66 debug("");
    67 successfullyParsed = true;
    69 </script>
    70 <script>finishTest();</script>
    72 </body>
    73 </html>

mercurial