tor-browser

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

tex-image-and-sub-image-2d-with-image-bitmap-from-blob.js (1951B)


      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 function generateTest(internalFormat, pixelFormat, pixelType, prologue, resourcePath, defaultContextVersion) {
      8    var wtu = WebGLTestUtils;
      9    var tiu = TexImageUtils;
     10    var gl = null;
     11    var successfullyParsed = false;
     12 
     13    async function init()
     14    {
     15        description('Verify texImage2D and texSubImage2D code paths taking ImageBitmap created from a Blob (' + internalFormat + '/' + pixelFormat + '/' + pixelType + ')');
     16 
     17        if(!window.createImageBitmap || !window.ImageBitmap) {
     18            finishTest();
     19            return;
     20        }
     21 
     22        // Set the default context version while still allowing the webglVersion URL query string to override it.
     23        wtu.setDefault3DContextVersion(defaultContextVersion);
     24        gl = wtu.create3DContext("example");
     25 
     26        if (!prologue(gl)) {
     27            finishTest();
     28            return;
     29        }
     30 
     31        gl.clearColor(0,0,0,1);
     32        gl.clearDepth(1);
     33 
     34        debug('*** Running tests against red-green-semi-transparent.png ***');
     35        let response = await fetch(resourcePath + "red-green-semi-transparent.png");
     36        let blob = await response.blob();
     37        await runImageBitmapTest(blob, 0.5, internalFormat, pixelFormat, pixelType, gl, tiu, wtu, false);
     38        debug('*** Running tests against red-green-128x128-linear-profile.jpg ***');
     39        response = await fetch(resourcePath + "red-green-128x128-linear-profile.jpg");
     40        blob = await response.blob();
     41        // This test requires a huge tolerance because browsers - at least currently - vary
     42        // widely in the colorspace conversion results for this image.
     43        let tolerance = 120;
     44        await runImageBitmapTest(blob, 1.0, internalFormat, pixelFormat, pixelType, gl, tiu, wtu, false, tolerance);
     45        finishTest();
     46    }
     47 
     48    return init;
     49 }