Auto merge of #17031 - MortimerGoro:update_webvr, r=emilio

Update rust-webvr

<!-- Please describe your changes on the following line: -->

Required for https://github.com/servo/servo/issues/16556

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/17031)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-25 07:12:11 -05:00 committed by GitHub
commit 3c267d7fdd
7 changed files with 58 additions and 13 deletions

17
Cargo.lock generated
View file

@ -4,7 +4,7 @@ version = "0.0.1"
dependencies = [ dependencies = [
"ipc-channel 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1", "msg 0.0.1",
"rust-webvr 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rust-webvr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -35,7 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "android_injected_glue" name = "android_injected_glue"
version = "0.2.2" version = "0.2.2"
source = "git+https://github.com/mmatyas/android-rs-injected-glue#1995be2c692d8d1f4c82d387c06c56451721cc38" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "angle" name = "angle"
@ -2268,11 +2268,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "rust-webvr" name = "rust-webvr"
version = "0.3.1" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2530,7 +2531,7 @@ dependencies = [
name = "servo" name = "servo"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"android_injected_glue 0.2.2 (git+https://github.com/mmatyas/android-rs-injected-glue)", "android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"browserhtml 0.1.17 (git+https://github.com/browserhtml/browserhtml?branch=crate)", "browserhtml 0.1.17 (git+https://github.com/browserhtml/browserhtml?branch=crate)",
"compiletest_helper 0.0.1", "compiletest_helper 0.0.1",
@ -2660,7 +2661,7 @@ dependencies = [
name = "servo_config" name = "servo_config"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"android_injected_glue 0.2.2 (git+https://github.com/mmatyas/android-rs-injected-glue)", "android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3459,7 +3460,7 @@ dependencies = [
"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
"checksum alloc-no-stdlib 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b21f6ad9c9957eb5d70c3dee16d31c092b3cab339628f821766b05e6833d72b8" "checksum alloc-no-stdlib 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b21f6ad9c9957eb5d70c3dee16d31c092b3cab339628f821766b05e6833d72b8"
"checksum android_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d8289e9637439939cc92b1995b0972117905be88bc28116c86b64d6e589bcd38" "checksum android_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d8289e9637439939cc92b1995b0972117905be88bc28116c86b64d6e589bcd38"
"checksum android_injected_glue 0.2.2 (git+https://github.com/mmatyas/android-rs-injected-glue)" = "<none>" "checksum android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec08bc5e100186b5223a24dcfe5655d1488aed9eafeb44fb9a0f67a4f53d0fc"
"checksum angle 0.2.0 (git+https://github.com/servo/angle?branch=servo)" = "<none>" "checksum angle 0.2.0 (git+https://github.com/servo/angle?branch=servo)" = "<none>"
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" "checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
@ -3647,7 +3648,7 @@ dependencies = [
"checksum ref_slice 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "825740057197b7d43025e7faf6477eaabc03434e153233da02d1f44602f71527" "checksum ref_slice 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "825740057197b7d43025e7faf6477eaabc03434e153233da02d1f44602f71527"
"checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01" "checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01"
"checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457" "checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457"
"checksum rust-webvr 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "454fc4c3a786029ab82c5528c14f01bf965f60f61b3f9b1ed51b4646223eab59" "checksum rust-webvr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "263be07c1d462798df737e4dcc6920ac92727340b05985a0328e3a86c9592b19"
"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95" "checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"

View file

@ -29,4 +29,4 @@ env_logger = "0.4"
xdg = "2.0" xdg = "2.0"
[target.'cfg(target_os = "android")'.dependencies] [target.'cfg(target_os = "android")'.dependencies]
android_injected_glue = {git = "https://github.com/mmatyas/android-rs-injected-glue"} android_injected_glue = "0.2"

View file

@ -152,6 +152,13 @@ impl VR {
WebVRDisplayEvent::Change(ref display) => { WebVRDisplayEvent::Change(ref display) => {
let display = self.sync_display(&display); let display = self.sync_display(&display);
display.handle_webvr_event(&event); display.handle_webvr_event(&event);
},
WebVRDisplayEvent::Pause(id) |
WebVRDisplayEvent::Resume(id) |
WebVRDisplayEvent::Exit(id) => {
if let Some(display) = self.find_display(id) {
display.handle_webvr_event(&event);
}
} }
}; };
} }

View file

@ -71,7 +71,9 @@ pub struct VRDisplay {
frame_data_status: Cell<VRFrameDataStatus>, frame_data_status: Cell<VRFrameDataStatus>,
#[ignore_heap_size_of = "channels are hard"] #[ignore_heap_size_of = "channels are hard"]
frame_data_receiver: DOMRefCell<Option<IpcReceiver<Result<Vec<u8>, ()>>>>, frame_data_receiver: DOMRefCell<Option<IpcReceiver<Result<Vec<u8>, ()>>>>,
running_display_raf: Cell<bool> running_display_raf: Cell<bool>,
paused: Cell<bool>,
stopped_on_pause: Cell<bool>,
} }
unsafe_no_jsmanaged_fields!(WebVRDisplayData); unsafe_no_jsmanaged_fields!(WebVRDisplayData);
@ -112,6 +114,12 @@ impl VRDisplay {
frame_data_status: Cell::new(VRFrameDataStatus::Waiting), frame_data_status: Cell::new(VRFrameDataStatus::Waiting),
frame_data_receiver: DOMRefCell::new(None), frame_data_receiver: DOMRefCell::new(None),
running_display_raf: Cell::new(false), running_display_raf: Cell::new(false),
// Some VR implementations (e.g. Daydream) can be paused in some life cycle situations
// such as showing and hiding the controller pairing screen.
paused: Cell::new(false),
// This flag is set when the Display was presenting when it received a VR Pause event.
// When the VR Resume event is received and the flag is set, VR presentation automatically restarts.
stopped_on_pause: Cell::new(false)
} }
} }
@ -428,6 +436,30 @@ impl VRDisplay {
// Change event doesn't exist in WebVR spec. // Change event doesn't exist in WebVR spec.
// So we update display data but don't notify JS. // So we update display data but don't notify JS.
self.update_display(&display); self.update_display(&display);
},
WebVRDisplayEvent::Pause(_) => {
if self.paused.get() {
return;
}
self.paused.set(true);
if self.presenting.get() {
self.stop_present();
self.stopped_on_pause.set(true);
}
},
WebVRDisplayEvent::Resume(_) => {
self.paused.set(false);
if self.stopped_on_pause.get() {
self.stopped_on_pause.set(false);
self.init_present();
}
},
WebVRDisplayEvent::Exit(_) => {
self.stopped_on_pause.set(false);
if self.presenting.get() {
self.stop_present();
}
} }
}; };
} }

View file

@ -66,7 +66,12 @@ impl VRDisplayEvent {
WebVRDisplayEvent::Blur(_) => ("blur", None), WebVRDisplayEvent::Blur(_) => ("blur", None),
WebVRDisplayEvent::Focus(_) => ("focus", None), WebVRDisplayEvent::Focus(_) => ("focus", None),
WebVRDisplayEvent::PresentChange(_, _) => ("presentchange", None), WebVRDisplayEvent::PresentChange(_, _) => ("presentchange", None),
WebVRDisplayEvent::Change(_) => panic!("VRDisplayEvent:Change event not available in WebVR") WebVRDisplayEvent::Change(_) |
WebVRDisplayEvent::Pause(_) |
WebVRDisplayEvent::Resume(_) |
WebVRDisplayEvent::Exit(_) => {
panic!("{:?} event not available in WebVR", event)
}
}; };
// map to JS enum values // map to JS enum values

View file

@ -12,6 +12,6 @@ path = "lib.rs"
[dependencies] [dependencies]
ipc-channel = "0.7" ipc-channel = "0.7"
msg = {path = "../msg"} msg = {path = "../msg"}
rust-webvr = {version = "0.3", features = ["serde-serialization"]} rust-webvr = {version = "0.4", features = ["serde-serialization"]}
serde = "0.9" serde = "0.9"
serde_derive = "0.9" serde_derive = "0.9"

View file

@ -45,4 +45,4 @@ libservo = {path = "../../components/servo"}
sig = "0.1" sig = "0.1"
[target.'cfg(target_os = "android")'.dependencies] [target.'cfg(target_os = "android")'.dependencies]
android_injected_glue = {git = "https://github.com/mmatyas/android-rs-injected-glue"} android_injected_glue = "0.2"