New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebVR API Implementation #14618
Merged
+13,044
−20
Merged
WebVR API Implementation #14618
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
WebVR API Implementation, r=larsbergstrom
- Loading branch information
commit c5705bff5003675d6d266c698653834027a78227
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
| @@ -101,6 +101,7 @@ use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, Scri | ||
| use script_traits::{LogEntry, ServiceWorkerMsg, webdriver_msg}; | ||
| use script_traits::{MozBrowserErrorType, MozBrowserEvent, WebDriverCommandMsg, WindowSizeData}; | ||
| use script_traits::{SWManagerMsg, ScopeThings, WindowSizeType}; | ||
| use script_traits::WebVREventMsg; | ||
| use servo_config::opts; | ||
| use servo_config::prefs::PREFS; | ||
| use servo_rand::{Rng, SeedableRng, ServoRng, random}; | ||
| @@ -122,6 +123,7 @@ use style_traits::cursor::Cursor; | ||
| use style_traits::viewport::ViewportConstraints; | ||
| use timer_scheduler::TimerScheduler; | ||
| use webrender_traits; | ||
| use webvr_traits::WebVRMsg; | ||
|
|
||
| /// The `Constellation` itself. In the servo browser, there is one | ||
| /// constellation, which maintains all of the browser global data. | ||
| @@ -280,6 +282,9 @@ pub struct Constellation<Message, LTF, STF> { | ||
|
|
||
| /// Phantom data that keeps the Rust type system happy. | ||
| phantom: PhantomData<(Message, LTF, STF)>, | ||
|
|
||
| /// A channel through which messages can be sent to the webvr thread. | ||
| webvr_thread: Option<IpcSender<WebVRMsg>>, | ||
| } | ||
|
|
||
| /// State needed to construct a constellation. | ||
| @@ -535,6 +540,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | ||
| info!("Using seed {} for random pipeline closure.", seed); | ||
| (rng, prob) | ||
| }), | ||
| webvr_thread: None | ||
| }; | ||
|
|
||
| constellation.run(); | ||
| @@ -645,6 +651,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | ||
| prev_visibility: prev_visibility, | ||
| webrender_api_sender: self.webrender_api_sender.clone(), | ||
| is_private: is_private, | ||
| webvr_thread: self.webvr_thread.clone() | ||
| }); | ||
|
|
||
| let pipeline = match result { | ||
| @@ -879,6 +886,14 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | ||
| FromCompositorMsg::LogEntry(top_level_frame_id, thread_name, entry) => { | ||
| self.handle_log_entry(top_level_frame_id, thread_name, entry); | ||
| } | ||
| FromCompositorMsg::SetWebVRThread(webvr_thread) => { | ||
| assert!(self.webvr_thread.is_none()); | ||
| self.webvr_thread = Some(webvr_thread) | ||
| } | ||
| FromCompositorMsg::WebVREvent(pipeline_ids, event) => { | ||
| debug!("constellation got WebVR event"); | ||
| self.handle_webvr_event(pipeline_ids, event); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @@ -1186,6 +1201,13 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | ||
| } | ||
| } | ||
|
|
||
| if let Some(chan) = self.webvr_thread.as_ref() { | ||
| debug!("Exiting WebVR thread."); | ||
MortimerGoro
Author
Contributor
|
||
| if let Err(e) = chan.send(WebVRMsg::Exit) { | ||
| warn!("Exit WebVR thread failed ({})", e); | ||
| } | ||
| } | ||
|
|
||
| debug!("Exiting font cache thread."); | ||
| self.font_cache_thread.exit(); | ||
|
|
||
| @@ -1274,6 +1296,18 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | ||
| } | ||
| } | ||
|
|
||
| fn handle_webvr_event(&mut self, ids: Vec<PipelineId>, event: WebVREventMsg) { | ||
| for id in ids { | ||
| match self.pipelines.get_mut(&id) { | ||
| Some(ref pipeline) => { | ||
| // Notify script thread | ||
| let _ = pipeline.event_loop.send(ConstellationControlMsg::WebVREvent(id, event.clone())); | ||
| }, | ||
| None => warn!("constellation got webvr event for dead pipeline") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn handle_init_load(&mut self, url: ServoUrl) { | ||
| let window_size = self.window_size.visible_viewport; | ||
| let root_pipeline_id = PipelineId::new(); | ||
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
should this be logged outside the
ifcheck (à la above)?