| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <meta charset="utf-8"> | 4 <meta charset="utf-8"> |
| 5 <title>WebGL required buffer clear behaviour test</title> | 5 <title>WebGL required buffer clear behaviour test</title> |
| 6 <link rel="stylesheet" href="../resources/js-test-style.css"/> | 6 <link rel="stylesheet" href="../resources/js-test-style.css"/> |
| 7 <script src="../resources/js-test-pre.js"></script> | 7 <script src="../resources/js-test-pre.js"></script> |
| 8 <script src="resources/webgl-test.js"> </script> | 8 <script src="resources/webgl-test.js"> </script> |
| 9 <script src="resources/webgl-test-utils.js"> </script> | 9 <script src="resources/webgl-test-utils.js"> </script> |
| 10 <style type="text/css"> | 10 <style type="text/css"> |
| 11 body { | 11 body { |
| 12 height: 3000px; | 12 height: 3000px; |
| 13 } | 13 } |
| 14 </style> | 14 </style> |
| 15 <script type="text/javascript"> | 15 <script type="text/javascript"> |
| 16 | 16 |
| 17 var iter = 0; | 17 var iter = 0; |
| 18 var gl; | 18 var gl1; |
| 19 | 19 |
| 20 var wtu = WebGLTestUtils; | 20 var wtu = WebGLTestUtils; |
| 21 | 21 |
| 22 function checkPixel(gl, x, y, c) { | |
| 23 var buf = new Uint8Array(4); | |
| 24 gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); | |
| 25 | |
| 26 return buf[0] == c[0] && | |
| 27 buf[1] == c[1] && | |
| 28 buf[2] == c[2] && | |
| 29 buf[3] == c[3]; | |
| 30 } | |
| 31 | |
| 32 function timer() { | 22 function timer() { |
| 33 if (iter == 0) { | 23 if (iter == 0) { |
| 34 » // some random hacky stuff to make sure that we get a compositing step | 24 // some random hacky stuff to make sure that we get a compositing step |
| 35 » window.scrollBy(0, 10); | 25 window.scrollBy(0, 10); |
| 36 » window.scrollBy(0, -10); | 26 window.scrollBy(0, -10); |
| 37 » iter++; | 27 iter++; |
| 38 | 28 |
| 39 » setTimeout(timer, 500); | 29 setTimeout(timer, 500); |
| 40 } else if (iter == 1) { | 30 } else if (iter == 1) { |
| 41 » // scissor was set earlier | 31 function clear(gl) { |
| 42 » gl.clearColor(0, 0, 1, 1); | 32 // scissor was set earlier |
| 43 » gl.clear(gl.COLOR_BUFFER_BIT); | 33 gl.clearColor(0, 0, 1, 1); |
| 34 gl.clear(gl.COLOR_BUFFER_BIT); |
| 44 | 35 |
| 45 » wtu.checkCanvasRect(gl, 0, 10, 10, 10, [0, 0, 255, 255], "cleared corner
should be blue, stencil should be preserved"); | 36 wtu.checkCanvasRect(gl, 0, 10, 10, 10, [0, 0, 255, 255], "cleared co
rner should be blue, stencil should be preserved"); |
| 46 » wtu.checkCanvasRect(gl, 0, 0, 10, 10, [0, 0, 0, 0], "remainder of buffer
should be cleared"); | 37 wtu.checkCanvasRect(gl, 0, 0, 10, 10, [0, 0, 0, 0], "remainder of bu
ffer should be cleared"); |
| 38 } |
| 39 clear(gl1); |
| 47 | 40 |
| 48 » finishTest(); | 41 finishTest(); |
| 49 } | 42 } |
| 50 } | 43 } |
| 51 | 44 |
| 52 function go() { | 45 function go() { |
| 53 description("This test ensures WebGL implementations correctly clear the dra
wing buffer on composite if preserveDrawingBuffer is false."); | 46 description("This test ensures WebGL implementations correctly clear the dra
wing buffer on composite if preserveDrawingBuffer is false."); |
| 54 | 47 |
| 55 debug(""); | 48 debug(""); |
| 56 | 49 |
| 57 gl = create3DContext(document.getElementById("c")); | 50 gl1 = create3DContext(document.getElementById("c")); |
| 58 if (!gl) { | 51 if (!gl1) { |
| 59 » finishTest(); | 52 finishTest(); |
| 60 » return; | 53 return; |
| 61 } | 54 } |
| 62 | 55 |
| 63 shouldBeTrue('gl.getContextAttributes().preserveDrawingBuffer == false'); | 56 shouldBeTrue("gl1 != null"); |
| 57 shouldBeTrue('gl1.getContextAttributes().preserveDrawingBuffer == false'); |
| 64 | 58 |
| 65 gl.clearColor(1, 0, 0, 1); | 59 function init(gl) { |
| 66 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); | 60 gl.clearColor(1, 0, 0, 1); |
| 61 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_B
IT); |
| 67 | 62 |
| 68 // enable scissor here, before compositing, to make sure it's correctly | 63 // enable scissor here, before compositing, to make sure it's correctly |
| 69 // ignored and restored | 64 // ignored and restored |
| 70 gl.scissor(0, 10, 10, 10); | 65 gl.scissor(0, 10, 10, 10); |
| 71 gl.enable(gl.SCISSOR_TEST); | 66 gl.enable(gl.SCISSOR_TEST); |
| 67 } |
| 68 |
| 69 init(gl1); |
| 72 | 70 |
| 73 setTimeout(timer, 500); | 71 setTimeout(timer, 500); |
| 74 } | 72 } |
| 75 | 73 |
| 76 window.addEventListener("load", go, false); | 74 window.addEventListener("load", go, false); |
| 77 | 75 |
| 78 successfullyParsed = true; | 76 successfullyParsed = true; |
| 79 </script> | 77 </script> |
| 80 </head> | 78 </head> |
| 81 <body> | 79 <body> |
| 82 <div id="description"></div> | 80 <div id="description"></div> |
| 83 <canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas> | 81 <canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas> |
| 84 <div id="console"></div> | 82 <div id="console"></div> |
| 85 </body> | 83 </body> |
| 86 </html> | 84 </html> |
| OLD | NEW |