Skip to content
Permalink
Browse files

Update webxr-test to support FakeXRFieldOfViewInit

In order to enable tests of the render depth, without requiring the test
implementations to perform this decomposition, the webxr-test-api was
updated to allow a fieldOfView parameter to be provided, which would
override any passed in projectionMatrix

Bug: 1003135
Change-Id: I54fce9832b72a36cf99130f626afc0c1c227e943
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1799318
Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696210}
  • Loading branch information
Alex Cooper authored and chromium-wpt-export-bot committed Sep 12, 2019
1 parent b1cd3ae commit 057b7c02e9fe802487a20cd091255058a456cc04
Showing with 42 additions and 19 deletions.
  1. +24 −15 resources/chromium/webxr-test.js
  2. +8 −0 webxr/resources/webxr_test_constants.js
  3. +10 −4 webxr/xrView_oneframeupdate.https.html
@@ -416,28 +416,37 @@ class MockRuntime {
// This function converts between the matrix provided by the WebXR test API
// and the internal data representation.
getEye(fakeXRViewInit) {
let m = fakeXRViewInit.projectionMatrix;
let fov = null;

if (fakeXRViewInit.fieldOfView) {
fov = {
upDegrees: fakeXRViewInit.fieldOfView.upDegrees,
downDegrees: fakeXRViewInit.fieldOfView.downDegrees,
leftDegrees: fakeXRViewInit.fieldOfView.leftDegrees,
rightDegrees: fakeXRViewInit.fieldOfView.rightDegrees
};
} else {
let m = fakeXRViewInit.projectionMatrix;

function toDegrees(tan) {
return Math.atan(tan) * 180 / Math.PI;
}
function toDegrees(tan) {
return Math.atan(tan) * 180 / Math.PI;
}

let xScale = m[0];
let yScale = m[5];
let near = m[14] / (m[10] - 1);
let far = m[14] / (m[10] - 1);
let leftTan = (1 - m[8]) / m[0];
let rightTan = (1 + m[8]) / m[0];
let upTan = (1 + m[9]) / m[5];
let downTan = (1 - m[9]) / m[5];
let leftTan = (1 - m[8]) / m[0];
let rightTan = (1 + m[8]) / m[0];
let upTan = (1 + m[9]) / m[5];
let downTan = (1 - m[9]) / m[5];

return {
fieldOfView: {
fov = {
upDegrees: toDegrees(upTan),
downDegrees: toDegrees(downTan),
leftDegrees: toDegrees(leftTan),
rightDegrees: toDegrees(rightTan)
},
};
}

return {
fieldOfView: fov,
headFromEye: composeGFXTransform(fakeXRViewInit.viewOffset),
renderWidth: fakeXRViewInit.resolution.width,
renderHeight: fakeXRViewInit.resolution.height
@@ -28,6 +28,14 @@ const VALID_POSE_TRANSFORM = {
const VALID_PROJECTION_MATRIX =
[1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];

// This is a decomposed version of the above.
const VALID_FIELD_OF_VIEW = {
upDegrees: 71.565,
downDegrees: -45,
leftDegrees:-63.4349,
rightDegrees: 75.9637
};

// A valid input grip matrix for when we don't care about specific values
const VALID_GRIP = [1, 0, 0, 0,
0, 1, 0, 0,
@@ -13,14 +13,20 @@

const fakeViews = [{
eye:"left",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewOffset: LEFT_OFFSET,
resolution: VALID_RESOLUTION
resolution: VALID_RESOLUTION,
fieldOfView: VALID_FIELD_OF_VIEW,
// The webxr-test-api requires that we still set this for now, but it is
// supposed to be ignored.
projectionMatrix: IDENTITY_MATRIX
}, {
eye:"right",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewOffset: RIGHT_OFFSET,
resolution: VALID_RESOLUTION
resolution: VALID_RESOLUTION,
fieldOfView: VALID_FIELD_OF_VIEW,
// The webxr-test-api requires that we still set this for now, but it is
// supposed to be ignored.
projectionMatrix: IDENTITY_MATRIX
},
];

0 comments on commit 057b7c0

Please sign in to comment.
You can’t perform that action at this time.