diff --git a/components/canvas_traits/media.rs b/components/canvas_traits/media.rs index 4b5576dce91..82f2e8e6248 100644 --- a/components/canvas_traits/media.rs +++ b/components/canvas_traits/media.rs @@ -66,6 +66,8 @@ pub struct WindowGLContext { pub gl_api: GlApi, /// Application's native display pub native_display: NativeDisplay, + /// A channel to the GLPlayer thread. + pub glplayer_chan: Option, } impl PlayerGLContext for WindowGLContext { diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index dbdd54ba5ce..b2a6729e681 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -104,6 +104,7 @@ use background_hang_monitor::HangMonitorRegister; use backtrace::Backtrace; use bluetooth_traits::BluetoothRequest; use canvas::canvas_paint_thread::CanvasPaintThread; +use canvas::media_thread::GLPlayerThreads; use canvas::webgl_thread::WebGLThreads; use canvas_traits::canvas::CanvasId; use canvas_traits::canvas::CanvasMsg; @@ -411,6 +412,9 @@ pub struct Constellation { /// results are required. enable_canvas_antialiasing: bool, + /// Entry point to create and get channels to a GLPlayerThread. + glplayer_threads: Option, + /// Application window's GL Context for Media player player_context: WindowGLContext, } @@ -461,6 +465,8 @@ pub struct InitialConstellationState { /// The XR device registry pub webxr_registry: webxr_api::Registry, + + pub glplayer_threads: Option, /// Application window's GL Context for Media player pub player_context: WindowGLContext, @@ -760,6 +766,7 @@ where is_running_problem_test, hard_fail, enable_canvas_antialiasing, + glplayer_threads: state.glplayer_threads, player_context: state.player_context, }; @@ -1804,6 +1811,13 @@ where } } + debug!("Exiting GLPlayer thread."); + if let Some(glplayer_threads) = self.glplayer_threads.as_ref() { + if let Err(e) = glplayer_threads.exit() { + warn!("Exit GLPlayer Thread failed ({})", e); + } + } + debug!("Exiting timer scheduler."); if let Err(e) = self.scheduler_chan.send(TimerSchedulerMsg::Exit) { warn!("Exit timer scheduler failed ({})", e); diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 1e01b2fd39e..f95a2f804de 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -63,6 +63,7 @@ fn webdriver(_port: u16, _constellation: Sender) {} use bluetooth::BluetoothThreadFactory; use bluetooth_traits::BluetoothRequest; use canvas::gl_context::GLContextFactory; +use canvas::media_thread::GLPlayerThreads; use canvas::webgl_thread::WebGLThreads; use canvas_traits::media::WindowGLContext; use compositing::compositor_thread::{ @@ -104,6 +105,7 @@ use profile_traits::time; use script_traits::{ConstellationMsg, SWManagerSenders, ScriptToConstellationChan}; use servo_config::opts; use servo_config::{pref, prefs}; +use servo_media::player::context::GlContext; use servo_media::ServoMedia; use std::borrow::Cow; use std::cmp::max; @@ -304,10 +306,16 @@ where None }; + let gl_context = window.get_gl_context(); + let glplayer_threads = match gl_context { + GlContext::Unknown => None, + _ => Some(GLPlayerThreads::new()), + }; let player_context = WindowGLContext { - gl_context: window.get_gl_context(), + gl_context, native_display: window.get_native_display(), gl_api: window.get_gl_api(), + glplayer_chan: glplayer_threads.as_ref().map(|threads| threads.pipeline()), }; // Create the constellation, which maintains the engine @@ -328,6 +336,7 @@ where window.gl(), webvr_services, webxr_registry, + glplayer_threads, player_context, ); @@ -639,6 +648,7 @@ fn create_constellation( window_gl: Rc, webvr_services: Option, webxr_registry: webxr_api::Registry, + glplayer_threads: Option, player_context: WindowGLContext, ) -> (Sender, SWManagerSenders) { // Global configuration options, parsed from the command line. @@ -721,6 +731,7 @@ fn create_constellation( webgl_threads, webvr_chan, webxr_registry, + glplayer_threads, player_context, }; let (constellation_chan, from_swmanager_sender) = Constellation::<