mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update rust-webvr
This commit is contained in:
parent
bb310efbb9
commit
5ac106cbbe
7 changed files with 58 additions and 13 deletions
|
@ -152,6 +152,13 @@ impl VR {
|
|||
WebVRDisplayEvent::Change(ref display) => {
|
||||
let display = self.sync_display(&display);
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -66,7 +66,12 @@ impl VRDisplayEvent {
|
|||
WebVRDisplayEvent::Blur(_) => ("blur", None),
|
||||
WebVRDisplayEvent::Focus(_) => ("focus", 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue