content/canvas/test/webgl-conformance/conformance/glsl/functions/glsl-function-distance.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 <!--
     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>GLSL distance function test</title>
    11   <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
    12   <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
    13   <script src="../../../resources/js-test-pre.js"></script>
    14   <script src="../../resources/webgl-test.js"> </script>
    15   <script src="../../resources/webgl-test-utils.js"> </script>
    16   <script src="../../resources/glsl-generator.js"> </script>
    17 </head>
    18 <body>
    19 <div id="description"></div>
    20 <div id="console"></div>
    21 <script>
    23 GLSLGenerator.runFeatureTest({
    24   feature: "distance",
    25   args: "$(type) p1, $(type) p2",
    26   baseArgs: "value$(field)",
    27   testFunc: "$(func)($(type),$(type))",
    28   emuFuncs: [
    29     { type: "float",
    30       code: [
    31         "float $(func)_emu($(args)) {",
    32         "   return abs(p1 - p2);",
    33         "}"].join("\n")
    34     },
    35     { type: "vec2",
    36       code: [
    37         "float $(func)_emu($(args)) {",
    38         "   return length(p1 - p2);",
    39         "}"].join("\n")
    40     },
    41     { type: "vec3",
    42       code: [
    43         "float $(func)_emu($(args)) {",
    44         "   return length(p1 - p2);",
    45         "}"].join("\n")
    46     },
    47     { type: "vec4",
    48       code: [
    49         "float $(func)_emu($(args)) {",
    50         "   return length(p1 - p2);",
    51         "}"].join("\n")
    52     }
    53   ],
    54   gridRes: 8,
    55   tests: [
    56     ["$(output) = vec4(",
    57      "    $(func)(",
    58      "        $(input).x * 8.0 - 4.0,", 
    59      "        $(input).y * 8.0 - 4.0) / 8.0,",
    60      "    0,",
    61      "    0,",
    62      "    1);"].join("\n"),
    63     ["$(output) = vec4(",
    64      "    0,",
    65      "    $(func)(",
    66      "        $(input).xy * 8.0 - 4.0,",
    67      "        $(input).wz * 8.0 - 4.0) / 8.0,", 
    68      "    0, 1);"].join("\n"),
    69     ["$(output) = vec4(",
    70      "    0, 0,",
    71      "    $(func)(",
    72      "        $(input).xyz * 8.0 - 4.0,",
    73      "        $(input).yzw * 8.0 - 4.0) / 8.0,",
    74      "    1);"].join("\n"),
    75     ["$(output) = vec4(",
    76      "    $(func)(",
    77      "        vec4($(input).xyz, 0) * 8.0 - 4.0,",
    78      "        vec4(0, $(input).wzy) * 8.0 - 4.0) / 8.0,",
    79      "    0, 0, 1);",
    80     ].join("\n")
    81   ]
    82 });
    83 successfullyParsed = true;
    84 </script>
    85 </body>
    86 </html>

mercurial