mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #23641 - Manishearth:newtest, r=asajeffrey
Update to newest XRTest API requires https://github.com/servo/rust-webvr/pull/88 and https://github.com/servo/servo/pull/23575 Incorporates changes from https://github.com/immersive-web/webxr-test-api/pull/10 (and various minor improvements on that, like https://github.com/immersive-web/webxr-test-api/pull/20). Test no longer relies on racy state setting functions. We're nearing consensus on what the test API should look like, thought I'd implement the updated model so I can start poking at the tests. Fixes https://github.com/servo/servo/issues/23634 by setting everything at initialization. This is based on https://github.com/servo/servo/pull/23575, so we can't merge it yet. r? @asajeffrey (only the last commit) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23641) <!-- Reviewable:end -->
This commit is contained in:
commit
b4ed3b6f3c
19 changed files with 263 additions and 194 deletions
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -2434,7 +2434,7 @@ dependencies = [
|
|||
"libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libservo 0.0.1",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"simpleservo 0.0.1",
|
||||
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3626,7 +3626,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rust-webvr"
|
||||
version = "0.12.2"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bindgen 0.49.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3639,12 +3639,12 @@ dependencies = [
|
|||
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ovr-mobile-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-webvr-api"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3977,7 +3977,7 @@ dependencies = [
|
|||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"osmesa-src 0.1.0 (git+https://github.com/servo/osmesa-src)",
|
||||
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sig 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tinyfiledialogs 3.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -5309,8 +5309,8 @@ dependencies = [
|
|||
"ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"servo_config 0.0.1",
|
||||
"webvr_traits 0.0.1",
|
||||
|
@ -5322,7 +5322,7 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -5843,8 +5843,8 @@ dependencies = [
|
|||
"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
|
||||
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
|
||||
"checksum ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "da06feaa07f69125ab9ddc769b11de29090122170b402547f64b86fe16ebc399"
|
||||
"checksum rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db3a145f737e4bf51cd4f7d29262f2b2e46e76b116070cbbfc0959553b2e8006"
|
||||
"checksum rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4f3a81b1acf3c6295f9c180e8ade671858865ee4e11d114ecf60974e86b2e0"
|
||||
"checksum rust-webvr 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab628b77aaacca496483788a5e0184d42af6dc0e938551aa5be20676c84dd196"
|
||||
"checksum rust-webvr-api 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d01034b181187e7d048ef4c5caaf95d28d0f7973834907fe7dd74b2bfb66e8"
|
||||
"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95"
|
||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
"checksum rusttype 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8eb11f5b0a98c8eca2fb1483f42646d8c340e83e46ab416f8a063a0fd0eeb20"
|
||||
|
|
121
components/script/dom/fakexrdevice.rs
Normal file
121
components/script/dom/fakexrdevice.rs
Normal file
|
@ -0,0 +1,121 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::{
|
||||
self, FakeXRDeviceMethods, FakeXRRigidTransformInit, FakeXRViewInit,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use webvr_traits::{MockVRControlMsg, MockVRView, WebVRMsg};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct FakeXRDevice {
|
||||
reflector: Reflector,
|
||||
}
|
||||
|
||||
impl FakeXRDevice {
|
||||
pub fn new_inherited() -> FakeXRDevice {
|
||||
FakeXRDevice {
|
||||
reflector: Reflector::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &GlobalScope) -> DomRoot<FakeXRDevice> {
|
||||
reflect_dom_object(
|
||||
Box::new(FakeXRDevice::new_inherited()),
|
||||
global,
|
||||
FakeXRDeviceBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
fn send_msg(&self, msg: MockVRControlMsg) {
|
||||
self.global()
|
||||
.as_window()
|
||||
.webvr_thread()
|
||||
.unwrap()
|
||||
.send(WebVRMsg::MessageMockDisplay(msg))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<(MockVRView, MockVRView)> {
|
||||
if views.len() != 2 {
|
||||
return Err(Error::NotSupported);
|
||||
}
|
||||
|
||||
let (left, right) = match (views[0].eye, views[1].eye) {
|
||||
(XREye::Left, XREye::Right) => (&views[0], &views[1]),
|
||||
(XREye::Right, XREye::Left) => (&views[1], &views[0]),
|
||||
_ => return Err(Error::NotSupported),
|
||||
};
|
||||
|
||||
if left.projectionMatrix.len() != 16 ||
|
||||
right.projectionMatrix.len() != 16 ||
|
||||
left.viewOffset.position.len() != 3 ||
|
||||
right.viewOffset.position.len() != 3
|
||||
{
|
||||
return Err(Error::Type("Incorrectly sized array".into()));
|
||||
}
|
||||
|
||||
let mut proj_l = [0.; 16];
|
||||
let mut proj_r = [0.; 16];
|
||||
let v: Vec<_> = left.projectionMatrix.iter().map(|x| **x).collect();
|
||||
proj_l.copy_from_slice(&v);
|
||||
let v: Vec<_> = right.projectionMatrix.iter().map(|x| **x).collect();
|
||||
proj_r.copy_from_slice(&v);
|
||||
|
||||
let mut offset_l = [0.; 3];
|
||||
let mut offset_r = [0.; 3];
|
||||
let v: Vec<_> = left.viewOffset.position.iter().map(|x| **x).collect();
|
||||
offset_l.copy_from_slice(&v);
|
||||
let v: Vec<_> = right.viewOffset.position.iter().map(|x| **x).collect();
|
||||
offset_r.copy_from_slice(&v);
|
||||
let left = MockVRView {
|
||||
projection: proj_l,
|
||||
offset: offset_l,
|
||||
};
|
||||
let right = MockVRView {
|
||||
projection: proj_r,
|
||||
offset: offset_r,
|
||||
};
|
||||
Ok((left, right))
|
||||
}
|
||||
|
||||
pub fn get_origin(origin: &FakeXRRigidTransformInit) -> Fallible<([f32; 3], [f32; 4])> {
|
||||
if origin.position.len() != 3 || origin.orientation.len() != 4 {
|
||||
return Err(Error::Type("Incorrectly sized array".into()));
|
||||
}
|
||||
let mut p = [0.; 3];
|
||||
let mut o = [0.; 4];
|
||||
let v: Vec<_> = origin.position.iter().map(|x| **x).collect();
|
||||
p.copy_from_slice(&v[0..3]);
|
||||
let v: Vec<_> = origin.orientation.iter().map(|x| **x).collect();
|
||||
o.copy_from_slice(&v);
|
||||
|
||||
Ok((p, o))
|
||||
}
|
||||
|
||||
impl FakeXRDeviceMethods for FakeXRDevice {
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn SetViews(&self, views: Vec<FakeXRViewInit>) -> Fallible<()> {
|
||||
let (left, right) = get_views(&views)?;
|
||||
self.send_msg(MockVRControlMsg::SetViews(left, right));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn SetViewerOrigin(
|
||||
&self,
|
||||
origin: &FakeXRRigidTransformInit,
|
||||
_emulated_position: bool,
|
||||
) -> Fallible<()> {
|
||||
let (position, orientation) = get_origin(origin)?;
|
||||
self.send_msg(MockVRControlMsg::SetViewerPose(position, orientation));
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceControllerBinding::{
|
||||
self, FakeXRDeviceControllerMethods, FakeXRRigidTransform, FakeXRViewInit,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use webvr_traits::{MockVRControlMsg, WebVREyeParameters, WebVRMsg};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct FakeXRDeviceController {
|
||||
reflector: Reflector,
|
||||
}
|
||||
|
||||
impl FakeXRDeviceController {
|
||||
pub fn new_inherited() -> FakeXRDeviceController {
|
||||
FakeXRDeviceController {
|
||||
reflector: Reflector::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &GlobalScope) -> DomRoot<FakeXRDeviceController> {
|
||||
reflect_dom_object(
|
||||
Box::new(FakeXRDeviceController::new_inherited()),
|
||||
global,
|
||||
FakeXRDeviceControllerBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn send_msg(&self, msg: MockVRControlMsg) {
|
||||
self.global()
|
||||
.as_window()
|
||||
.webvr_thread()
|
||||
.unwrap()
|
||||
.send(WebVRMsg::MessageMockDisplay(msg))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl FakeXRDeviceControllerMethods for FakeXRDeviceController {
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn SetViews(&self, views: Vec<FakeXRViewInit>) -> Fallible<()> {
|
||||
if views.len() != 2 {
|
||||
return Err(Error::NotSupported);
|
||||
}
|
||||
|
||||
let (left, right) = match (views[0].eye, views[1].eye) {
|
||||
(XREye::Left, XREye::Right) => (&views[0], &views[1]),
|
||||
(XREye::Right, XREye::Left) => (&views[1], &views[0]),
|
||||
_ => return Err(Error::NotSupported),
|
||||
};
|
||||
|
||||
if left.projectionMatrix.len() != 16 ||
|
||||
right.projectionMatrix.len() != 16 ||
|
||||
left.viewOffset.position.len() != 3 ||
|
||||
right.viewOffset.position.len() != 3
|
||||
{
|
||||
return Err(Error::Type("Incorrectly sized array".into()));
|
||||
}
|
||||
|
||||
let mut proj_l = [0.; 16];
|
||||
let mut proj_r = [0.; 16];
|
||||
let v: Vec<_> = left.projectionMatrix.iter().map(|x| **x).collect();
|
||||
proj_l.copy_from_slice(&v);
|
||||
let v: Vec<_> = right.projectionMatrix.iter().map(|x| **x).collect();
|
||||
proj_r.copy_from_slice(&v);
|
||||
|
||||
let mut params_l = WebVREyeParameters::default();
|
||||
let mut params_r = WebVREyeParameters::default();
|
||||
let v: Vec<_> = left.viewOffset.position.iter().map(|x| **x).collect();
|
||||
params_l.offset.copy_from_slice(&v);
|
||||
let v: Vec<_> = right.viewOffset.position.iter().map(|x| **x).collect();
|
||||
params_r.offset.copy_from_slice(&v);
|
||||
|
||||
self.send_msg(MockVRControlMsg::SetProjectionMatrices(proj_l, proj_r));
|
||||
self.send_msg(MockVRControlMsg::SetEyeParameters(params_l, params_r));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn SetViewerOrigin(&self, origin: &FakeXRRigidTransform) -> Fallible<()> {
|
||||
if origin.position.len() != 4 || origin.orientation.len() != 4 {
|
||||
return Err(Error::Type("Incorrectly sized array".into()));
|
||||
}
|
||||
let mut position = [0.; 3];
|
||||
let mut orientation = [0.; 4];
|
||||
let v: Vec<_> = origin.position.iter().map(|x| **x).collect();
|
||||
position.copy_from_slice(&v[0..3]);
|
||||
let v: Vec<_> = origin.orientation.iter().map(|x| **x).collect();
|
||||
orientation.copy_from_slice(&v);
|
||||
self.send_msg(MockVRControlMsg::SetViewerPose(position, orientation));
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -301,7 +301,7 @@ pub mod eventsource;
|
|||
pub mod eventtarget;
|
||||
pub mod extendableevent;
|
||||
pub mod extendablemessageevent;
|
||||
pub mod fakexrdevicecontroller;
|
||||
pub mod fakexrdevice;
|
||||
pub mod file;
|
||||
pub mod filelist;
|
||||
pub mod filereader;
|
||||
|
|
57
components/script/dom/webidls/FakeXRDevice.webidl
Normal file
57
components/script/dom/webidls/FakeXRDevice.webidl
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://github.com/immersive-web/webxr-test-api/
|
||||
|
||||
[Exposed=Window, Pref="dom.webxr.test"]
|
||||
interface FakeXRDevice {
|
||||
// Sets the values to be used for subsequent
|
||||
// requestAnimationFrame() callbacks.
|
||||
[Throws] void setViews(sequence<FakeXRViewInit> views);
|
||||
|
||||
// // behaves as if device was disconnected
|
||||
// Promise<void> disconnect();
|
||||
|
||||
// Sets the origin of the viewer
|
||||
[Throws] void setViewerOrigin(FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false);
|
||||
|
||||
// // Simulates devices focusing and blurring sessions.
|
||||
// void simulateVisibilityChange(XRVisibilityState);
|
||||
|
||||
// void setBoundsGeometry(sequence<FakeXRBoundsPoint> boundsCoodinates);
|
||||
// // Sets eye level used for calculating floor-level spaces
|
||||
// void setEyeLevel(float eyeLevel);
|
||||
|
||||
|
||||
// Promise<FakeXRInputController>
|
||||
// simulateInputSourceConnection(FakeXRInputSourceInit);
|
||||
};
|
||||
|
||||
// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-getviewport
|
||||
dictionary FakeXRViewInit {
|
||||
required XREye eye;
|
||||
// https://immersive-web.github.io/webxr/#view-projection-matrix
|
||||
required sequence<float> projectionMatrix;
|
||||
// https://immersive-web.github.io/webxr/#view-offset
|
||||
required FakeXRRigidTransformInit viewOffset;
|
||||
// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-getviewport
|
||||
required FakeXRViewportInit viewport;
|
||||
};
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrviewport
|
||||
dictionary FakeXRViewportInit {
|
||||
required long x;
|
||||
required long y;
|
||||
required long width;
|
||||
required long height;
|
||||
};
|
||||
|
||||
dictionary FakeXRBoundsPoint {
|
||||
double x; double z;
|
||||
};
|
||||
|
||||
dictionary FakeXRRigidTransformInit {
|
||||
required sequence<float> position;
|
||||
required sequence<float> orientation;
|
||||
};
|
|
@ -1,49 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://github.com/immersive-web/webxr-test-api/
|
||||
|
||||
[Exposed=Window, Pref="dom.webxr.test"]
|
||||
interface FakeXRDeviceController {
|
||||
// Creates and attaches a XRFrameOfReference of the type specified to the device.
|
||||
// void setFrameOfReference(XRFrameOfReferenceType, FakeXRFrameOfReferenceInit);
|
||||
|
||||
// // Sets the values to be used for subsequent
|
||||
// // requestAnimationFrame() callbacks.
|
||||
[Throws] void setViews(sequence<FakeXRViewInit> views);
|
||||
|
||||
[Throws] void setViewerOrigin(FakeXRRigidTransform origin);
|
||||
|
||||
// Simulates the user activating the reset pose on a device.
|
||||
// void simulateResetPose();
|
||||
|
||||
// Simulates the platform ending the sessions.
|
||||
// void simulateForcedEndSessions();
|
||||
|
||||
// Simulates devices focusing and blurring sessions.
|
||||
// void simulateBlurSession(XRSession);
|
||||
// void simulateFocusSession(XRSession);
|
||||
|
||||
// void setBoundsGeometry(Array<FakeXRBoundsPoint> boundsCoodinates)l
|
||||
|
||||
// Promise<FakeXRInputSourceController>
|
||||
// simulateInputSourceConnection(FakeXRInputSourceInit);
|
||||
};
|
||||
|
||||
dictionary FakeXRViewInit {
|
||||
required XREye eye;
|
||||
// https://immersive-web.github.io/webxr/#view-projection-matrix
|
||||
required sequence<float> projectionMatrix;
|
||||
// https://immersive-web.github.io/webxr/#view-offset
|
||||
required FakeXRRigidTransform viewOffset;
|
||||
};
|
||||
|
||||
dictionary FakeXRBoundsPoint {
|
||||
double x; double z;
|
||||
};
|
||||
|
||||
dictionary FakeXRRigidTransform {
|
||||
required sequence<float> position;
|
||||
required sequence<float> orientation;
|
||||
};
|
|
@ -8,18 +8,28 @@
|
|||
interface XRTest {
|
||||
// Simulates connecting a device to the system.
|
||||
// Used to instantiate a fake device for use in tests.
|
||||
Promise<FakeXRDeviceController> simulateDeviceConnection(FakeXRDeviceInit init);
|
||||
|
||||
// // Simulates a device being disconnected from the system.
|
||||
// Promise<void> simulateDeviceDisconnection(XRDevice);
|
||||
Promise<FakeXRDevice> simulateDeviceConnection(FakeXRDeviceInit init);
|
||||
|
||||
// // Simulates a user activation (aka user gesture) for the current scope.
|
||||
// // The activation is only guaranteed to be valid in the provided function and only applies to WebXR
|
||||
// // Device API methods.
|
||||
// void simulateUserActivation(Function);
|
||||
|
||||
// // Disconnect all fake devices
|
||||
// Promise<void> disconnectAllDevices();
|
||||
};
|
||||
|
||||
dictionary FakeXRDeviceInit {
|
||||
// TODO: Subject to change to match spec changes.
|
||||
required boolean supportsImmersive;
|
||||
required sequence<FakeXRViewInit> views;
|
||||
|
||||
boolean supportsUnbounded = false;
|
||||
// Whether the space supports tracking in inline sessions
|
||||
boolean supportsTrackingInInline = true;
|
||||
// The bounds coordinates. If null, bounded reference spaces are not supported.
|
||||
sequence<FakeXRBoundsPoint> boundsCoodinates;
|
||||
// Eye level used for calculating floor-level spaces
|
||||
float eyeLevel = 1.5;
|
||||
FakeXRRigidTransformInit viewerOrigin;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ use crate::dom::bindings::codegen::Bindings::XRTestBinding::{
|
|||
};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::fakexrdevicecontroller::FakeXRDeviceController;
|
||||
use crate::dom::fakexrdevice::{get_origin, get_views, FakeXRDevice};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::promise::Promise;
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use webvr_traits::WebVRMsg;
|
||||
use webvr_traits::{MockVRInit, WebVRMsg};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct XRTest {
|
||||
|
@ -52,14 +52,40 @@ impl XRTestMethods for XRTest {
|
|||
return p;
|
||||
}
|
||||
|
||||
let origin = if let Some(ref o) = init.viewerOrigin {
|
||||
match get_origin(&o) {
|
||||
Ok(origin) => origin,
|
||||
Err(e) => {
|
||||
p.reject_error(e);
|
||||
return p;
|
||||
},
|
||||
}
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
|
||||
let views = match get_views(&init.views) {
|
||||
Ok(views) => views,
|
||||
Err(e) => {
|
||||
p.reject_error(e);
|
||||
return p;
|
||||
},
|
||||
};
|
||||
|
||||
let init = MockVRInit {
|
||||
viewer_origin: Some(origin),
|
||||
views: Some(views),
|
||||
eye_level: None,
|
||||
};
|
||||
|
||||
self.session_started.set(true);
|
||||
self.global()
|
||||
.as_window()
|
||||
.webvr_thread()
|
||||
.unwrap()
|
||||
.send(WebVRMsg::CreateMockDisplay)
|
||||
.send(WebVRMsg::CreateMockDisplay(init))
|
||||
.unwrap();
|
||||
p.resolve_native(&FakeXRDeviceController::new(&self.global()));
|
||||
p.resolve_native(&FakeXRDevice::new(&self.global()));
|
||||
|
||||
p
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ gleam = "0.6"
|
|||
ipc-channel = "0.11.2"
|
||||
log = "0.4"
|
||||
msg = {path = "../msg"}
|
||||
rust-webvr = {version = "0.12", features = ["mock", "openvr", "vrexternal"]}
|
||||
rust-webvr-api = "0.12"
|
||||
rust-webvr = {version = "0.13", features = ["mock", "openvr", "vrexternal"]}
|
||||
rust-webvr-api = "0.13"
|
||||
script_traits = {path = "../script_traits"}
|
||||
servo_config = {path = "../config"}
|
||||
webvr_traits = {path = "../webvr_traits" }
|
||||
|
|
|
@ -135,8 +135,8 @@ impl WebVRThread {
|
|||
self.handle_get_gamepads_for_display(display_id, sender);
|
||||
},
|
||||
|
||||
WebVRMsg::CreateMockDisplay => {
|
||||
self.handle_create_mock();
|
||||
WebVRMsg::CreateMockDisplay(init) => {
|
||||
self.handle_create_mock(init);
|
||||
},
|
||||
WebVRMsg::MessageMockDisplay(msg) => {
|
||||
self.handle_message_mock_display(msg);
|
||||
|
@ -312,12 +312,12 @@ impl WebVRThread {
|
|||
sender.send(Ok(data)).unwrap();
|
||||
}
|
||||
|
||||
fn handle_create_mock(&mut self) {
|
||||
fn handle_create_mock(&mut self, init: MockVRInit) {
|
||||
if self.mock.is_some() {
|
||||
warn!("Mock display already created");
|
||||
return;
|
||||
}
|
||||
self.mock = Some(self.service.register_mock_with_remote());
|
||||
self.mock = Some(self.service.register_mock_with_remote(init));
|
||||
}
|
||||
|
||||
fn handle_message_mock_display(&mut self, msg: MockVRControlMsg) {
|
||||
|
|
|
@ -13,5 +13,5 @@ path = "lib.rs"
|
|||
[dependencies]
|
||||
ipc-channel = "0.11"
|
||||
msg = {path = "../msg"}
|
||||
rust-webvr-api = {version = "0.12", features = ["ipc"]}
|
||||
rust-webvr-api = {version = "0.13", features = ["ipc"]}
|
||||
serde = "1.0"
|
||||
|
|
|
@ -11,7 +11,6 @@ mod webvr_traits;
|
|||
|
||||
pub use crate::webvr_traits::{WebVRMsg, WebVRResult};
|
||||
pub use rust_webvr_api as webvr;
|
||||
pub use rust_webvr_api::MockVRControlMsg;
|
||||
pub use rust_webvr_api::VRDisplayCapabilities as WebVRDisplayCapabilities;
|
||||
pub use rust_webvr_api::VRDisplayData as WebVRDisplayData;
|
||||
pub use rust_webvr_api::VRDisplayEvent as WebVRDisplayEvent;
|
||||
|
@ -31,6 +30,7 @@ pub use rust_webvr_api::VRLayer as WebVRLayer;
|
|||
pub use rust_webvr_api::VRMainThreadHeartbeat as WebVRMainThreadHeartbeat;
|
||||
pub use rust_webvr_api::VRPose as WebVRPose;
|
||||
pub use rust_webvr_api::VRStageParameters as WebVRStageParameters;
|
||||
pub use rust_webvr_api::{MockVRControlMsg, MockVRInit, MockVRView};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct WebVRPoseInformation {
|
||||
|
|
|
@ -26,7 +26,7 @@ pub enum WebVRMsg {
|
|||
RequestPresent(PipelineId, u32, IpcSender<WebVRResult<()>>),
|
||||
ExitPresent(PipelineId, u32, Option<IpcSender<WebVRResult<()>>>),
|
||||
CreateCompositor(u32),
|
||||
CreateMockDisplay,
|
||||
CreateMockDisplay(MockVRInit),
|
||||
MessageMockDisplay(MockVRControlMsg),
|
||||
GetGamepads(
|
||||
Vec<u32>,
|
||||
|
|
|
@ -54,7 +54,7 @@ lazy_static = "1"
|
|||
libservo = {path = "../../components/servo"}
|
||||
libc = "0.2"
|
||||
log = "0.4"
|
||||
rust-webvr = { version = "0.12", features = ["glwindow"] }
|
||||
rust-webvr = { version = "0.13", features = ["glwindow"] }
|
||||
tinyfiledialogs = "3.0"
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
|
||||
|
|
|
@ -19,7 +19,7 @@ raqote_backend = ["simpleservo/raqote_backend"]
|
|||
[dependencies]
|
||||
libservo = { path = "../../components/servo", features = ["no_static_freetype"] }
|
||||
simpleservo = { path = "../libsimpleservo/api", features = ["no_static_freetype"] }
|
||||
rust-webvr = { version = "0.12", features = ["magicleap"] }
|
||||
rust-webvr = { version = "0.13", features = ["magicleap"] }
|
||||
libc = "0.2"
|
||||
log = "0.4"
|
||||
servo-egl = "0.2"
|
||||
|
|
|
@ -19683,15 +19683,15 @@
|
|||
"testharness"
|
||||
],
|
||||
"webxr/create_session.html": [
|
||||
"306ab85d3b1b914d2dd7c11a3b03dccd990148ae",
|
||||
"ddec5add27b84e8e2febe3789d326f1e9fb7f508",
|
||||
"testharness"
|
||||
],
|
||||
"webxr/obtain_frame.html": [
|
||||
"99d8fd1ef152e4030444c3ca42482d28c3e855d3",
|
||||
"e2b4424d5779baedf6bdb50f1b3151336f31a4cb",
|
||||
"testharness"
|
||||
],
|
||||
"webxr/resources/webxr-util.js": [
|
||||
"b644ba72ac801bc8f659e9678d31ab23db0b7281",
|
||||
"554c1c183d3710e54dc60704dad0aac542ffd67c",
|
||||
"support"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -2,11 +2,16 @@
|
|||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/webxr-util.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
navigator.xr.test.simulateDeviceConnection({supportsImmersive: true}).then((m) => {
|
||||
navigator.xr.test.simulateDeviceConnection({
|
||||
supportsImmersive: true,
|
||||
views: TEST_VIEWS,
|
||||
viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] }
|
||||
}).then((m) => {
|
||||
return navigator.xr.requestSession({mode: "immersive-vr"})
|
||||
}).then(() => t.done());
|
||||
});
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
let canvas = document.getElementById("canvas");
|
||||
let gl = canvas.getContext('webgl');
|
||||
promise_test(async function() {
|
||||
let mock = await navigator.xr.test.simulateDeviceConnection({supportsImmersive: true});
|
||||
mock.setViewerOrigin({position: [0.5, 0.1, 0.1, 1], orientation: [1, 0, 0, 1] });
|
||||
mock.setViews(TEST_VIEWS);
|
||||
let mock = await navigator.xr.test.simulateDeviceConnection({
|
||||
supportsImmersive: true,
|
||||
views: TEST_VIEWS,
|
||||
viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] }
|
||||
});
|
||||
let session = await navigator.xr.requestSession({mode: "immersive-vr"});
|
||||
await session.updateRenderState({"baseLayer": new XRWebGLLayer(session, gl, {})});
|
||||
let resolve;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
const VALID_PROJECTION_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
|
||||
const LEFT_OFFSET = {position: [-0.1, 0, 0], orientation: [0,0,0,0]};
|
||||
const RIGHT_OFFSET = {position: [0.1, 0, 0], orientation: [0,0,0,0]};
|
||||
|
||||
const LEFT_VIEWPORT = {x: 0, y: 0, width: 320, height: 480};
|
||||
const RIGHT_VIEWPORT = {x: 320, y: 0, width: 320, height: 480};
|
||||
let assert_matrix_approx_equals = function(m1, m2, epsilon, prefix = "") {
|
||||
assert_equals(m1.length, m2.length, prefix + "Matrix lengths should match");
|
||||
for(var i = 0; i < m1.length; ++i) {
|
||||
|
@ -12,6 +13,6 @@ let assert_matrix_approx_equals = function(m1, m2, epsilon, prefix = "") {
|
|||
}
|
||||
|
||||
const TEST_VIEWS = [
|
||||
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET},
|
||||
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET}
|
||||
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET, viewport: LEFT_VIEWPORT},
|
||||
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET, viewport: RIGHT_VIEWPORT}
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue