|
1 <!DOCTYPE html> |
|
2 <html class="reftest-wait"> |
|
3 <head> |
|
4 <meta charset="UTF-8"> |
|
5 |
|
6 <script type="text/javascript" src="webgl-utils.js"></script> |
|
7 <script type="text/javascript"> |
|
8 /* Color-Alpha Test |
|
9 * |
|
10 * Clear the four quadrants of the canvas as follows: |
|
11 * +------+------+ |
|
12 * | red |green | |
|
13 * | | | |
|
14 * +------+------+ |
|
15 * | blue |white | |
|
16 * | | | |
|
17 * +------+------+ |
|
18 * However, unlike the Color test, clear with a given alpha value. |
|
19 * What effect this has depends on the context-creation args passed |
|
20 * to this page. |
|
21 * |
|
22 * Here we check that we handle various combinations of alpha and |
|
23 * premultipliedAlpha correctly. |
|
24 */ |
|
25 |
|
26 "use strict"; |
|
27 |
|
28 function renderGL(gl, value, alpha) { |
|
29 gl.enable(gl.SCISSOR_TEST); |
|
30 |
|
31 gl.scissor(0, 128, 128, 128); |
|
32 gl.clearColor(value, 0.0, 0.0, alpha); |
|
33 gl.clear(gl.COLOR_BUFFER_BIT); |
|
34 |
|
35 gl.scissor(128, 128, 128, 128); |
|
36 gl.clearColor(0.0, value, 0.0, alpha); |
|
37 gl.clear(gl.COLOR_BUFFER_BIT); |
|
38 |
|
39 gl.scissor(0, 0, 128, 128); |
|
40 gl.clearColor(0.0, 0.0, value, alpha); |
|
41 gl.clear(gl.COLOR_BUFFER_BIT); |
|
42 |
|
43 gl.scissor(128, 0, 128, 128); |
|
44 gl.clearColor(value, value, value, alpha); |
|
45 gl.clear(gl.COLOR_BUFFER_BIT); |
|
46 |
|
47 gl.finish(); |
|
48 } |
|
49 |
|
50 function renderFailure(canvas) { |
|
51 // This will also trigger RAF for us. |
|
52 var context = canvas.getContext("2d"); |
|
53 context.fillText('WebGL failed.', 64, 64); |
|
54 } |
|
55 |
|
56 function runTest() { |
|
57 var canvas = document.getElementById("canvas"); |
|
58 var gl = initGL(canvas); |
|
59 |
|
60 var value = arg("colorVal"); |
|
61 var alpha = arg("alphaVal"); |
|
62 |
|
63 if (gl) |
|
64 renderGL(gl, value, alpha); |
|
65 else |
|
66 renderFailure(canvas); |
|
67 |
|
68 waitForComposite(testComplete); |
|
69 } |
|
70 |
|
71 function testComplete() { |
|
72 document.documentElement.removeAttribute("class"); |
|
73 } |
|
74 </script> |
|
75 </head> |
|
76 |
|
77 <body onload="rAF(runTest);"> |
|
78 <canvas id="canvas" width="256" height="256"></canvas> |
|
79 </body> |
|
80 |
|
81 </html> |