mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Use task! for raf events from VR
This commit is contained in:
parent
76745699d2
commit
c051fc1995
1 changed files with 6 additions and 19 deletions
|
@ -41,7 +41,6 @@ use std::mem;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use task::Task;
|
|
||||||
use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRLayer, WebVRMsg};
|
use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRLayer, WebVRMsg};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -511,11 +510,12 @@ impl VRDisplay {
|
||||||
api_sender.send_vr(WebVRCommand::Create(display_id)).unwrap();
|
api_sender.send_vr(WebVRCommand::Create(display_id)).unwrap();
|
||||||
loop {
|
loop {
|
||||||
// Run RAF callbacks on JavaScript thread
|
// Run RAF callbacks on JavaScript thread
|
||||||
let msg = box NotifyDisplayRAF {
|
let this = address.clone();
|
||||||
address: address.clone(),
|
let sender = raf_sender.clone();
|
||||||
sender: raf_sender.clone()
|
let task = box task!(handle_vrdisplay_raf: move || {
|
||||||
};
|
this.root().handle_raf(&sender);
|
||||||
js_sender.send(CommonScriptMsg::Task(WebVREvent, msg)).unwrap();
|
});
|
||||||
|
js_sender.send(CommonScriptMsg::Task(WebVREvent, task)).unwrap();
|
||||||
|
|
||||||
// Run Sync Poses in parallell on Render thread
|
// Run Sync Poses in parallell on Render thread
|
||||||
let msg = WebVRCommand::SyncPoses(display_id, near, far, sync_sender.clone());
|
let msg = WebVRCommand::SyncPoses(display_id, near, far, sync_sender.clone());
|
||||||
|
@ -608,19 +608,6 @@ impl VRDisplay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NotifyDisplayRAF {
|
|
||||||
address: Trusted<VRDisplay>,
|
|
||||||
sender: mpsc::Sender<Result<(f64, f64), ()>>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Task for NotifyDisplayRAF {
|
|
||||||
fn run(self: Box<Self>) {
|
|
||||||
let display = self.address.root();
|
|
||||||
display.handle_raf(&self.sender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// WebVR Spec: If the number of values in the leftBounds/rightBounds arrays
|
// WebVR Spec: If the number of values in the leftBounds/rightBounds arrays
|
||||||
// is not 0 or 4 for any of the passed layers the promise is rejected
|
// is not 0 or 4 for any of the passed layers the promise is rejected
|
||||||
fn parse_bounds(src: &Option<Vec<Finite<f32>>>, dst: &mut [f32; 4]) -> Result<(), &'static str> {
|
fn parse_bounds(src: &Option<Vec<Finite<f32>>>, dst: &mut [f32; 4]) -> Result<(), &'static str> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue