From c051fc1995ea290a780c2ad73a19ae9555bc2141 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 17 Sep 2017 23:49:18 +0200 Subject: [PATCH] Use task! for raf events from VR --- components/script/dom/vrdisplay.rs | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index 2b2ab80f2e5..9c86e5a6bf3 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -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, - sender: mpsc::Sender> -} - -impl Task for NotifyDisplayRAF { - fn run(self: Box) { - 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>>, dst: &mut [f32; 4]) -> Result<(), &'static str> {