mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Call start_present and stop_present on VRDisplay
This commit is contained in:
parent
a28e15e4ea
commit
d6c064e9a9
1 changed files with 18 additions and 9 deletions
|
@ -11,6 +11,7 @@ use msg::constellation_msg::PipelineId;
|
||||||
use rust_webvr::VRServiceManager;
|
use rust_webvr::VRServiceManager;
|
||||||
use script_traits::ConstellationMsg;
|
use script_traits::ConstellationMsg;
|
||||||
use servo_config::prefs::PREFS;
|
use servo_config::prefs::PREFS;
|
||||||
|
use std::collections::hash_map::Entry;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::{thread, time};
|
use std::{thread, time};
|
||||||
use webvr_traits::webvr::*;
|
use webvr_traits::webvr::*;
|
||||||
|
@ -378,7 +379,9 @@ impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
|
||||||
fn handle(&mut self, cmd: webgl::WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
|
fn handle(&mut self, cmd: webgl::WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
|
||||||
match cmd {
|
match cmd {
|
||||||
webgl::WebVRCommand::Create(compositor_id) => {
|
webgl::WebVRCommand::Create(compositor_id) => {
|
||||||
self.create_compositor(compositor_id);
|
if let Some(compositor) = self.create_compositor(compositor_id) {
|
||||||
|
unsafe { (*compositor.0).start_present(None) };
|
||||||
|
}
|
||||||
},
|
},
|
||||||
webgl::WebVRCommand::SyncPoses(compositor_id, near, far, sender) => {
|
webgl::WebVRCommand::SyncPoses(compositor_id, near, far, sender) => {
|
||||||
if let Some(compositor) = self.compositors.get(&compositor_id) {
|
if let Some(compositor) = self.compositors.get(&compositor_id) {
|
||||||
|
@ -408,7 +411,9 @@ impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
webgl::WebVRCommand::Release(compositor_id) => {
|
webgl::WebVRCommand::Release(compositor_id) => {
|
||||||
self.compositors.remove(&compositor_id);
|
if let Some(compositor) = self.compositors.remove(&compositor_id) {
|
||||||
|
unsafe { (*compositor.0).stop_present() };
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,10 +421,13 @@ impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
|
||||||
|
|
||||||
impl WebVRCompositorHandler {
|
impl WebVRCompositorHandler {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn create_compositor(&mut self, display_id: webgl::WebVRDeviceId) {
|
fn create_compositor(
|
||||||
|
&mut self,
|
||||||
|
display_id: webgl::WebVRDeviceId,
|
||||||
|
) -> Option<&mut WebVRCompositor> {
|
||||||
let sender = match self.webvr_thread_sender {
|
let sender = match self.webvr_thread_sender {
|
||||||
Some(ref s) => s,
|
Some(ref s) => s,
|
||||||
None => return,
|
None => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
sender
|
sender
|
||||||
|
@ -428,13 +436,14 @@ impl WebVRCompositorHandler {
|
||||||
let display = self.webvr_thread_receiver.recv().unwrap();
|
let display = self.webvr_thread_receiver.recv().unwrap();
|
||||||
|
|
||||||
match display {
|
match display {
|
||||||
Some(display) => {
|
Some(display) => match self.compositors.entry(display_id) {
|
||||||
self.compositors.insert(display_id, display);
|
Entry::Vacant(entry) => return Some(entry.insert(display)),
|
||||||
},
|
Entry::Occupied(_) => error!("VRDisplay already presenting"),
|
||||||
None => {
|
|
||||||
error!("VRDisplay not found when creating a new VRCompositor");
|
|
||||||
},
|
},
|
||||||
|
None => error!("VRDisplay not found when creating a new VRCompositor"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is done on only a per-platform basis on initialization.
|
// This is done on only a per-platform basis on initialization.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue