tor-browser

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

matchDepthViewValues.js (1608B)


      1 'use strict';
      2 
      3 // import * as XrConstants from 'resources/webxr_test_constants.js'
      4 // import * as XrAsserts from 'resources/webxr_test_asserts.js'
      5 
      6 // TODO: Expand the WebXrTestApi to specify a viewGeometry that this can validate
      7 // as well.
      8 const depthViewGeometryTestGenerator = (matchDepthView) => {
      9  return (session, controller, t, sessionObjects) => {
     10 
     11    return session.requestReferenceSpace('viewer').then((viewerSpace) => new Promise((resolve) => {
     12 
     13      const isCpuOptimized = session.depthUsage === 'cpu-optimized';
     14      const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
     15 
     16      const rafCb = function(time, frame) {
     17        const pose = frame.getViewerPose(viewerSpace);
     18        for(const view of pose.views) {
     19          const depthInformation = isCpuOptimized ? frame.getDepthInformation(view)
     20                                                  : glBinding.getDepthInformation(view);
     21          if (matchDepthView) {
     22            t.step(()=> {
     23              assert_matrix_approx_equals(view.projectionMatrix, depthInformation.projectionMatrix);
     24              assert_transform_approx_equals(view.transform, depthInformation.transform);
     25            });
     26          } else {
     27            t.step(() => {
     28              assert_matrix_significantly_not_equals(view.projectionMatrix, depthInformation.projectionMatrix);
     29              assert_transform_significantly_not_equals(view.transform, depthInformation.transform);
     30            });
     31          }
     32        }
     33        resolve();
     34      }
     35 
     36      session.requestAnimationFrame(rafCb);
     37    })); // Promise
     38  }; // Test Func
     39 };  // Generator Func