Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various webxr WPT fixes #25259

Merged
merged 11 commits into from Dec 13, 2019

Handle FOV values in mock API

  • Loading branch information
Manishearth committed Dec 12, 2019
commit c2d3c646efa19d04ef2d30c785ea995a9619166f
@@ -20,7 +20,7 @@ use ipc_channel::ipc::IpcSender;
use ipc_channel::router::ROUTER;
use profile_traits::ipc;
use std::rc::Rc;
use webxr_api::{MockDeviceMsg, View, Views};
use webxr_api::{MockDeviceMsg, MockViewInit, MockViewsInit};

#[dom_struct]
pub struct FakeXRDevice {
@@ -50,7 +50,7 @@ impl FakeXRDevice {
}
}

pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<Views> {
pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<MockViewsInit> {
if views.len() != 2 {
return Err(Error::NotSupported);
}
@@ -91,17 +91,41 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<Views> {
let viewport_l = Rect::new(origin_l, size_l);
let viewport_r = Rect::new(origin_r, size_r);

let left = View {
let fov_l = if let Some(ref fov) = left.fieldOfView {
Some((
fov.leftDegrees.to_radians(),
fov.rightDegrees.to_radians(),
fov.upDegrees.to_radians(),
fov.downDegrees.to_radians(),
))
} else {
None
};

let fov_r = if let Some(ref fov) = right.fieldOfView {
Some((
fov.leftDegrees.to_radians(),
fov.rightDegrees.to_radians(),
fov.upDegrees.to_radians(),
fov.downDegrees.to_radians(),
))
} else {
None
};

let left = MockViewInit {
projection: proj_l,
transform: offset_l,
viewport: viewport_l,
fov: fov_l,
};
let right = View {
let right = MockViewInit {
projection: proj_r,
transform: offset_r,
viewport: viewport_r,
fov: fov_r,
};
Ok(Views::Stereo(left, right))
Ok(MockViewsInit::Stereo(left, right))
}

pub fn get_origin<T, U>(
@@ -43,6 +43,8 @@ dictionary FakeXRViewInit {
required FakeXRRigidTransformInit viewOffset;
// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-getviewport
required FakeXRDeviceResolution resolution;

FakeXRFieldOfViewInit fieldOfView;
};

// https://immersive-web.github.io/webxr/#xrviewport
@@ -59,3 +61,10 @@ dictionary FakeXRRigidTransformInit {
required sequence<float> position;
required sequence<float> orientation;
};

dictionary FakeXRFieldOfViewInit {
required float upDegrees;
required float downDegrees;
required float leftDegrees;
required float rightDegrees;
};
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.