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

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:875766c14190
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 cos 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>
22
23 var piConstants = [
24 "const float kPI = 3.14159265358979323846;",
25 "const float kHalfPI = (kPI * 0.5);",
26 "const float k2PI = (kPI * 2.0);"
27 ].join("\n");
28
29 var kPI = Math.PI;
30 var kHalfPI = Math.PI * 0.5;
31 var k2PI = Math.PI * 2.0;
32 var cos = Math.cos; // shorthand
33
34 GLSLGenerator.runReferenceImageTest({
35 feature: "cos",
36 args: "$(type) value",
37 testFunc: "$(func)($(type))",
38 gridRes: 8,
39 tolerance: 3,
40 extra: piConstants,
41 tests: [
42 {
43 source: ["$(output) = vec4(",
44 " $(func)($(input).x * kHalfPI + kHalfPI),",
45 " $(func)($(input).y * kHalfPI),",
46 " 0,",
47 " 1);"].join("\n"),
48 generator: function(x, y, z, w) {
49 return [ cos(x * kHalfPI + kHalfPI),
50 cos(y * kHalfPI),
51 0,
52 1 ];
53 },
54 },
55 {
56 source: ["$(output) = vec4(",
57 " $(func)($(input).xy * vec2(kPI, k2PI)) * 0.5 + vec2(0.5, 0.5),",
58 " 0, 1);"].join("\n"),
59 generator: function(x, y, z, w) {
60 return [ cos(x * kPI) * 0.5 + 0.5,
61 cos(y * k2PI) * 0.5 + 0.5,
62 0,
63 1 ];
64 },
65 },
66 {
67 // FIXME: for some reason, this test requires a higher tolerance when run in a vertex shader.
68 source: ["$(output) = vec4(",
69 " $(func)($(input).xyz * vec3(kPI, k2PI, 4.0)) * ",
70 " 0.5 + vec3(0.5, 0.5, 0.5),",
71 " 1);"].join("\n"),
72 generator: function(x, y, z, w) {
73 return [ cos(x * kPI) * 0.5 + 0.5,
74 cos(y * k2PI) * 0.5 + 0.5,
75 cos(z * 4.0) * 0.5 + 0.5,
76 1 ];
77 },
78 tolerance: 7,
79 },
80 {
81 source: ["$(output) = ",
82 " $(func)($(input) * vec4(k2PI, 4.0, kHalfPI, kPI)) *",
83 " 0.5 + vec4(0.5, 0.5, 0.5, 1);",
84 ].join("\n"),
85 generator: function(x, y, z, w) {
86 return [ cos(x * k2PI) * 0.5 + 0.5,
87 cos(y * 4.0) * 0.5 + 0.5,
88 cos(z * kHalfPI) * 0.5 + 0.5,
89 cos(w * kPI) * 0.5 + 1.0 ];
90 },
91 },
92 ]
93 });
94 successfullyParsed = true;
95 </script>
96 </body>
97 </html>
98

mercurial