tor-browser

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

depth_sensing_cpu_matchDepthViewDepthData.https.html (3785B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>WebXR Depth Sensing Test: XRDepthInformation.data buffer with matchDepthView and offset depth data (CPU)</title>
      4 <link rel="help" href="https://immersive-web.github.io/depth-sensing/">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/webxr/resources/webxr_util.js"></script>
      8 <script src="/webxr/resources/webxr_test_constants.js"></script>
      9 <script src="/webxr/resources/webxr_test_constants_fake_depth.js"></script>
     10 <script src="/webxr/resources/webxr_test_asserts.js"></script>
     11 
     12 <canvas id="webgl-canvas"></canvas>
     13 <script>
     14 
     15 const offsetMatchDepthViewDataTestGenerator = function(matchDepthView) {
     16  return function(session, controller, t, sessionObjects) {
     17    return session.requestReferenceSpace('viewer').then((viewerSpace) => new Promise((resolve, reject) => {
     18      const rafCb = function(time, frame) {
     19        const pose = frame.getViewerPose(viewerSpace);
     20 
     21        for (const view of pose.views) {
     22          const depthInformation = frame.getDepthInformation(view);
     23          t.step(() => {
     24            assert_not_equals(depthInformation, null, "Depth information should not be null.");
     25            assert_not_equals(depthInformation.data, null, "Depth information data ArrayBuffer should not be null.");
     26 
     27            // OFFSET_DEPTH_SENSING_DATA.depthData is a Uint8Array.
     28            // We need its underlying ArrayBuffer for comparison with depthInformation.data.
     29            const rawDeviceDepthArrayBuffer = OFFSET_DEPTH_SENSING_DATA.depthData.buffer;
     30            const pageVisibleDepthArrayBuffer = depthInformation.data;
     31 
     32            if (matchDepthView) {
     33              // When matchDepthView is true, depth data should be reprojected to the XRView.
     34              // This reprojected data must be different from the raw device data.
     35              assert_array_buffer_not_equals(
     36                  pageVisibleDepthArrayBuffer,
     37                  rawDeviceDepthArrayBuffer,
     38                  "Page depth data ArrayBuffer SHOULD NOT match raw device depth data ArrayBuffer when matchDepthView is true.");
     39            } else {
     40              // When matchDepthView is false, depth data should be the raw device data,
     41              // without reprojection to the XRView.
     42              assert_array_buffer_equals(
     43                  pageVisibleDepthArrayBuffer,
     44                  rawDeviceDepthArrayBuffer,
     45                  "Page depth data ArrayBuffer SHOULD match raw device depth data ArrayBuffer when matchDepthView is false.");
     46            }
     47          });
     48        }
     49        resolve();
     50      };
     51 
     52      session.requestAnimationFrame(rafCb);
     53    }));
     54  };
     55 };
     56 
     57 const fakeDeviceInitParams = {
     58  supportedModes: ["immersive-ar"],
     59  views: VALID_VIEWS,
     60  supportedFeatures: ALL_FEATURES,
     61  depthSensingData: OFFSET_DEPTH_SENSING_DATA,
     62 };
     63 
     64 xr_session_promise_test(
     65  `XRDepthInformation.data matches raw device data when matchDepthView is false with offset depth (CPU)`,
     66  offsetMatchDepthViewDataTestGenerator(/*matchDepthView=*/false),
     67  fakeDeviceInitParams,
     68  'immersive-ar',
     69  {
     70    requiredFeatures: ['depth-sensing'],
     71    depthSensing: {
     72      usagePreference: ['cpu-optimized'],
     73      dataFormatPreference: [OFFSET_DEPTH_SENSING_DATA.depthFormat],
     74      matchDepthView: false
     75  }
     76 });
     77 
     78 xr_session_promise_test(
     79  `XRDepthInformation.data does NOT match raw device data when matchDepthView is true with offset depth (CPU)`,
     80  offsetMatchDepthViewDataTestGenerator(/*matchDepthView=*/true),
     81  fakeDeviceInitParams,
     82  'immersive-ar',
     83  {
     84    requiredFeatures: ['depth-sensing'],
     85    depthSensing: {
     86      usagePreference: ['cpu-optimized'],
     87      dataFormatPreference: [OFFSET_DEPTH_SENSING_DATA.depthFormat],
     88      matchDepthView: true
     89    }
     90  }
     91 );
     92 </script>