Skip to content

Commit

Permalink
Update test processing of StageParameters changes
Browse files Browse the repository at this point in the history
Currently the test code only sends the stage parameters as Display Info
updates. Now that WebVr has been removed, this code path is one that is
being considered for removal.

The real runtimes utilize both this VRDisplayInfo update path as well as
updating the stage parameters with frame data.

This changes the test runtime to do the same (i.e. send up stage
parameters via both DisplayInfo and FrameData).

Fixed:983363
Change-Id: I3c0a3f59b97163c3ac3b8f4b6529183142688d0d
  • Loading branch information
alcooper91 authored and chromium-wpt-export-bot committed Feb 15, 2020
1 parent 8636d91 commit d67a410
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions resources/chromium/webxr-test.js
Expand Up @@ -226,6 +226,8 @@ class MockRuntime {
this.next_frame_id_ = 0;
this.bounds_ = null;
this.send_mojo_space_reset_ = false;
this.stageParameters_ = null;
this.stageParametersUpdated_ = false;

this.service_ = service;

Expand Down Expand Up @@ -387,37 +389,38 @@ class MockRuntime {
// don't know the transform from local space to bounds space.
// We'll cache the bounds so that they can be set in the future if the
// floorLevel transform is set, but we won't update them just yet.
if (this.displayInfo_.stageParameters) {
this.displayInfo_.stageParameters.bounds = this.bounds_;

if (this.sessionClient_.ptr.isBound()) {
this.sessionClient_.onChanged(this.displayInfo_);
}
if (this.stageParameters_) {
this.stageParameters_.bounds = this.bounds_;
this.onStageParametersUpdated();
}
}

setFloorOrigin(floorOrigin) {
if (!this.displayInfo_.stageParameters) {
this.displayInfo_.stageParameters = default_stage_parameters;
this.displayInfo_.stageParameters.bounds = this.bounds_;
if (!this.stageParameters_) {
this.stageParameters_ = default_stage_parameters;
this.stageParameters_.bounds = this.bounds_;
}

this.displayInfo_.stageParameters.standingTransform = new gfx.mojom.Transform();
this.displayInfo_.stageParameters.standingTransform.matrix =
this.stageParameters_.standingTransform = new gfx.mojom.Transform();
this.stageParameters_.standingTransform.matrix =
getMatrixFromTransform(floorOrigin);

if (this.sessionClient_.ptr.isBound()) {
this.sessionClient_.onChanged(this.displayInfo_);
}
this.onStageParametersUpdated();
}

clearFloorOrigin() {
if (this.displayInfo_.stageParameters) {
this.displayInfo_.stageParameters = null;
if (this.stageParameters_) {
this.stageParameters_ = null;
this.onStageParametersUpdated();
}
}

if (this.sessionClient_.ptr.isBound()) {
this.sessionClient_.onChanged(this.displayInfo_);
}
onStageParametersUpdated() {
// Indicate for the frame loop that the stage parameters have been updated.
this.stageParametersUpdated_ = true;
this.displayInfo_.stageParameters = this.stageParameters_;
if (this.sessionClient_.ptr.isBound()) {
this.sessionClient_.onChanged(this.displayInfo_);
}
}

Expand Down Expand Up @@ -569,6 +572,9 @@ class MockRuntime {
getFrameData(options) {
const mojo_space_reset = this.send_mojo_space_reset_;
this.send_mojo_space_reset_ = false;

const stage_parameters_updated = this.stageParametersUpdated_;
this.stageParametersUpdated_ = false;
if (this.pose_) {
this.pose_.poseIndex++;
}
Expand Down Expand Up @@ -601,6 +607,8 @@ class MockRuntime {
frameId: this.next_frame_id_++,
bufferHolder: null,
bufferSize: {},
stageParameters: this.stageParameters_,
stageParametersUpdated: stage_parameters_updated,
};

this._calculateHitTestResults(frameData);
Expand Down Expand Up @@ -946,13 +954,12 @@ class MockRuntime {
case device.mojom.XRReferenceSpaceCategory.LOCAL:
return identity();
case device.mojom.XRReferenceSpaceCategory.LOCAL_FLOOR:
if (this.displayInfo_ == null || this.displayInfo_.stageParameters == null
|| this.displayInfo_.stageParameters.standingTransform == null) {
if (this.stageParameters_ == null || this.stageParameters_.standingTransform == null) {
console.warn("Standing transform not available.");
return null;
}
// this.displayInfo_.stageParameters.standingTransform = floor_from_mojo aka native_origin_from_mojo
return XRMathHelper.inverse(this.displayInfo_.stageParameters.standingTransform.matrix);
// this.stageParameters_.standingTransform = floor_from_mojo aka native_origin_from_mojo
return XRMathHelper.inverse(this.stageParameters_.standingTransform.matrix);
case device.mojom.XRReferenceSpaceCategory.VIEWER:
const transform = {
position: [
Expand Down

0 comments on commit d67a410

Please sign in to comment.