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
  • Loading branch information
Alex Cooper authored and chromium-wpt-export-bot committed Sep 11, 2019
1 parent dcae3ce commit 11e295519e2b4542128c1125e24c6264e560c1d0
Showing with 43 additions and 19 deletions.
  1. +25 −15 resources/chromium/webxr-test.js
  2. +8 −0 webxr/resources/webxr_test_constants.js
  3. +10 −4 webxr/xrView_oneframeupdate.https.html
@@ -403,28 +403,38 @@ 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;

function toDegrees(tan) {
return Math.atan(tan) * 180 / Math.PI;
}
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;

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];
function toDegrees(tan) {
return Math.atan(tan) * 180 / Math.PI;
}

return {
fieldOfView: {
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];

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 11e2955

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