diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-25 07:12:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 07:12:11 -0500 |
commit | 3c267d7fddd036f6bcc9ebf000ed37665cf7496d (patch) | |
tree | 1b643c9429d03dc56196a3771b9a8f1b22ab9a4f /components/script/dom/vrdisplay.rs | |
parent | 7780ef5e431b7c346c0f50ff914fbda9b5017900 (diff) | |
parent | 5ac106cbbe30054ee9440082049ccad0595937d5 (diff) | |
download | servo-3c267d7fddd036f6bcc9ebf000ed37665cf7496d.tar.gz servo-3c267d7fddd036f6bcc9ebf000ed37665cf7496d.zip |
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 -->
Diffstat (limited to 'components/script/dom/vrdisplay.rs')
-rw-r--r-- | components/script/dom/vrdisplay.rs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index b9b65264c44..da5c12e8c54 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -71,7 +71,9 @@ pub struct VRDisplay { frame_data_status: Cell<VRFrameDataStatus>, #[ignore_heap_size_of = "channels are hard"] 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); @@ -112,6 +114,12 @@ impl VRDisplay { frame_data_status: Cell::new(VRFrameDataStatus::Waiting), frame_data_receiver: DOMRefCell::new(None), 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. // So we update display data but don't notify JS. 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(); + } } }; } |