mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +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::sync::mpsc;
|
||||
use std::thread;
|
||||
use task::Task;
|
||||
use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRLayer, WebVRMsg};
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -511,11 +510,12 @@ impl VRDisplay {
|
|||
api_sender.send_vr(WebVRCommand::Create(display_id)).unwrap();
|
||||
loop {
|
||||
// Run RAF callbacks on JavaScript thread
|
||||
let msg = box NotifyDisplayRAF {
|
||||
address: address.clone(),
|
||||
sender: raf_sender.clone()
|
||||
};
|
||||
js_sender.send(CommonScriptMsg::Task(WebVREvent, msg)).unwrap();
|
||||
let this = address.clone();
|
||||
let sender = raf_sender.clone();
|
||||
let task = box task!(handle_vrdisplay_raf: move || {
|
||||
this.root().handle_raf(&sender);
|
||||
});
|
||||
js_sender.send(CommonScriptMsg::Task(WebVREvent, task)).unwrap();
|
||||
|
||||
// Run Sync Poses in parallell on Render thread
|
||||
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
|
||||
// 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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue