content/canvas/test/webgl-conformance/conformance/glsl/functions/glsl-function-cos.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/webgl-conformance/conformance/glsl/functions/glsl-function-cos.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,98 @@
     1.4 +<!--
     1.5 +Copyright (c) 2011 The Chromium Authors. All rights reserved.
     1.6 +Use of this source code is governed by a BSD-style license that can be
     1.7 +found in the LICENSE file.
     1.8 + -->
     1.9 +<!DOCTYPE html>
    1.10 +<html>
    1.11 +<head>
    1.12 +<meta charset="utf-8">
    1.13 +  <title>GLSL cos function test</title>
    1.14 +  <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
    1.15 +  <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
    1.16 +  <script src="../../../resources/js-test-pre.js"></script>
    1.17 +  <script src="../../resources/webgl-test.js"> </script>
    1.18 +  <script src="../../resources/webgl-test-utils.js"> </script>
    1.19 +  <script src="../../resources/glsl-generator.js"> </script>
    1.20 +</head>
    1.21 +<body>
    1.22 +<div id="description"></div>
    1.23 +<div id="console"></div>
    1.24 +<script>
    1.25 +
    1.26 +var piConstants = [
    1.27 +  "const float kPI     = 3.14159265358979323846;",
    1.28 +  "const float kHalfPI = (kPI * 0.5);",
    1.29 +  "const float k2PI    = (kPI * 2.0);"
    1.30 +].join("\n");
    1.31 +
    1.32 +var kPI = Math.PI;
    1.33 +var kHalfPI = Math.PI * 0.5;
    1.34 +var k2PI = Math.PI * 2.0;
    1.35 +var cos = Math.cos;  // shorthand
    1.36 +
    1.37 +GLSLGenerator.runReferenceImageTest({
    1.38 +  feature: "cos",
    1.39 +  args: "$(type) value",
    1.40 +  testFunc: "$(func)($(type))",
    1.41 +  gridRes: 8,
    1.42 +  tolerance: 3,
    1.43 +  extra: piConstants,
    1.44 +  tests: [
    1.45 +    {
    1.46 +      source: ["$(output) = vec4(",
    1.47 +               "    $(func)($(input).x * kHalfPI + kHalfPI),",
    1.48 +               "    $(func)($(input).y * kHalfPI),",
    1.49 +               "    0,",
    1.50 +               "    1);"].join("\n"),
    1.51 +      generator: function(x, y, z, w) {
    1.52 +	return [ cos(x * kHalfPI + kHalfPI),
    1.53 +		 cos(y * kHalfPI),
    1.54 +		 0,
    1.55 +		 1 ];
    1.56 +      },
    1.57 +    },
    1.58 +    {
    1.59 +      source: ["$(output) = vec4(",
    1.60 +	       "    $(func)($(input).xy * vec2(kPI, k2PI)) * 0.5 + vec2(0.5, 0.5),",
    1.61 +	       "    0, 1);"].join("\n"),
    1.62 +      generator: function(x, y, z, w) {
    1.63 +	return [ cos(x * kPI) * 0.5 + 0.5,
    1.64 +		 cos(y * k2PI) * 0.5 + 0.5,
    1.65 +		 0,
    1.66 +		 1 ];
    1.67 +      },
    1.68 +    },
    1.69 +    {
    1.70 +      // FIXME: for some reason, this test requires a higher tolerance when run in a vertex shader.
    1.71 +      source: ["$(output) = vec4(",
    1.72 +	       "    $(func)($(input).xyz * vec3(kPI, k2PI, 4.0)) * ",
    1.73 +	       "    0.5 + vec3(0.5, 0.5, 0.5),",
    1.74 +	       "    1);"].join("\n"),
    1.75 +      generator: function(x, y, z, w) {
    1.76 +	return [ cos(x * kPI) * 0.5 + 0.5,
    1.77 +		 cos(y * k2PI) * 0.5 + 0.5,
    1.78 +		 cos(z * 4.0) * 0.5 + 0.5,
    1.79 +		 1 ];
    1.80 +      },
    1.81 +      tolerance: 7,
    1.82 +    },
    1.83 +    {
    1.84 +      source: ["$(output) = ",
    1.85 +	       "    $(func)($(input) * vec4(k2PI, 4.0, kHalfPI, kPI)) *",
    1.86 +	       "    0.5 + vec4(0.5, 0.5, 0.5, 1);",
    1.87 +	      ].join("\n"),
    1.88 +      generator: function(x, y, z, w) {
    1.89 +	return [ cos(x * k2PI) * 0.5 + 0.5,
    1.90 +		 cos(y * 4.0) * 0.5 + 0.5,
    1.91 +		 cos(z * kHalfPI) * 0.5 + 0.5,
    1.92 +		 cos(w * kPI) * 0.5 + 1.0 ];
    1.93 +      },
    1.94 +    },
    1.95 +  ]
    1.96 +});
    1.97 +successfullyParsed = true;
    1.98 +</script>
    1.99 +</body>
   1.100 +</html>
   1.101 +

mercurial