tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

state-uneffected-after-compositing.html (2356B)


      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 -->
      6 
      7 <!DOCTYPE html>
      8 <html>
      9 <head>
     10 <meta charset="utf-8">
     11 <title>WebGL: Check that state is not lost by compositing</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 <canvas id="testbed" width="16" height="16" style="width:50px; height:50px"></canvas>
     18 <div id="description"></div>
     19 <div id="console"></div>
     20 <script>
     21 "use strict";
     22 description();
     23 var wtu = WebGLTestUtils;
     24 
     25 function runTest()
     26 {
     27  var gl = wtu.create3DContext('testbed', { antialias: false });
     28  if (!gl) {
     29    testFailed('could not create context');
     30    return;
     31  }
     32 
     33  var program = wtu.setupTexturedQuad(gl);
     34  var tex = gl.createTexture();
     35  var fb = gl.createFramebuffer();
     36 
     37  var step1 = function() {
     38    wtu.fillTexture(gl, tex, 1, 1, [0, 255, 0, 255]);
     39    wtu.clearAndDrawUnitQuad(gl);
     40    wtu.checkCanvas(gl, [0, 255, 0, 255], "drawing with texture should be green");
     41  };
     42 
     43  var step2 = function() {
     44    wtu.clearAndDrawUnitQuad(gl);
     45    wtu.checkCanvas(gl, [0, 255, 0, 255], "drawing with texture after composite without rebinding should be green");
     46 
     47    // Clear background to red
     48    gl.clearColor(1, 0, 0, 1);
     49    gl.clear(gl.COLOR_BUFFER_BIT);
     50 
     51    // Bind framebuffer with green texture.
     52    gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
     53    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
     54    wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 255, 0, 255], "reading from fbo with attached texture should be green");
     55  };
     56 
     57  var step3 = function() {
     58    // Should still have fb bound and reading should be green
     59    wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 255, 0, 255], "reading from fbo after composite without rebinding should be green");
     60  };
     61 
     62  var steps = [
     63    step1,
     64    step2,
     65    step3,
     66  ];
     67 
     68  var stepIndex = 0;
     69  var runNextStep = function() {
     70    steps[stepIndex++]();
     71    if (stepIndex == steps.length) {
     72      wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
     73      finishTest();
     74      return;
     75    }
     76    wtu.waitForComposite(runNextStep);
     77  };
     78  runNextStep();
     79 }
     80 
     81 runTest();
     82 var successfullyParsed = true;
     83 </script>
     84 </body>
     85 </html>