content/canvas/test/webgl-conformance/conformance/canvas/buffer-preserve-test.html

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

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

mercurial