Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / rendering / clear-after-copyTexImage2D.html
blob576b0cc6cebe3cc894c9d88cc44cbef17d8330a7
1 <!--
2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>WebGL clear after copyTexImage2D with a non-pure color</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"></script>
15 </head>
16 <body>
17 <div id="description"></div>
18 <div id="console"></div>
19 <canvas id="canvas" width="128" height="128"> </canvas>
20 <script>
21 "use strict";
22 // This test verifies a Intel D3D driver bug.
23 var wtu = WebGLTestUtils;
24 var gl = wtu.create3DContext("canvas", {"antialias" : "true"});
26 function testClearAfterCopyTexImage2DWithoutPureOneOrZero(clearColor, expectedColor)
28 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
29 gl.clearColor(0, 0, 0, 1);
30 gl.clear(gl.COLOR_BUFFER_BIT);
32 var width = 16;
33 var height = 16;
34 var texture = gl.createTexture();
35 gl.bindTexture(gl.TEXTURE_2D, texture);
36 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, width, height, 0);
37 gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
38 gl.clear(gl.COLOR_BUFFER_BIT);
40 wtu.checkCanvasRect(gl, 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, expectedColor);
42 gl.bindTexture(gl.TEXTURE_2D, null);
43 gl.deleteTexture(texture);
46 description("Test that if clear with a color that has non-0/1 RGB components after copyTexImage2D, the final render color should be consistent with the clear color.");
48 for(var index = 0; index < 3; index++)
50 var clearColor = [0, 0, 0, 1];
51 var expectedColor = [0, 0, 0, 255];
52 clearColor[index] = 0.8;
53 expectedColor[index] = 255 * clearColor[index];
54 testClearAfterCopyTexImage2DWithoutPureOneOrZero(clearColor, expectedColor);
57 debug("");
58 var successfullyParsed = true;
60 </script>
61 <script src="../../js/js-test-post.js"></script>
63 </body>
64 </html>