mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
libservo: Handle GL video decoding setup internally (#31209)
Instead of making the client set up GL video decoding, have this done inside libservo. The details necessary for decoding are fetched via Surfman now. This also removes the setup for the context on Android -- which has no GStreamer support now anyway. In the future, this could be enabled, but should likely be done using Surfman, instead of passing on all these details manually.
This commit is contained in:
parent
b2fe66f7e4
commit
d7d0451424
7 changed files with 125 additions and 156 deletions
|
@ -14,7 +14,7 @@ use gleam::gl;
|
|||
use log::{info, trace, warn};
|
||||
use servo::compositing::windowing::EmbedderEvent;
|
||||
use servo::compositing::CompositeTarget;
|
||||
use servo::config::opts;
|
||||
use servo::config::{opts, set_pref};
|
||||
use servo::servo_config::pref;
|
||||
use servo::Servo;
|
||||
use surfman::GLApi;
|
||||
|
@ -67,6 +67,8 @@ impl App {
|
|||
|
||||
// Implements window methods, used by compositor.
|
||||
let window = if opts::get().headless {
|
||||
// GL video rendering is not supported on headless windows.
|
||||
set_pref!(media.glvideo.enabled, false);
|
||||
headless_window::Window::new(
|
||||
opts::get().initial_window_size,
|
||||
device_pixel_ratio_override,
|
||||
|
|
|
@ -24,12 +24,7 @@ use servo::servo_geometry::DeviceIndependentPixel;
|
|||
use servo::style_traits::DevicePixel;
|
||||
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use servo::webrender_api::ScrollLocation;
|
||||
use servo_media::player::context::{GlApi, GlContext as PlayerGLContext, NativeDisplay};
|
||||
#[cfg(target_os = "linux")]
|
||||
use surfman::platform::generic::multi::connection::NativeConnection;
|
||||
#[cfg(target_os = "linux")]
|
||||
use surfman::platform::generic::multi::context::NativeContext;
|
||||
use surfman::{Connection, Context, Device, GLApi, GLVersion, SurfaceType};
|
||||
use surfman::{Connection, Context, Device, SurfaceType};
|
||||
#[cfg(target_os = "windows")]
|
||||
use winapi;
|
||||
use winit::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||
|
@ -553,82 +548,6 @@ impl WindowMethods for Window {
|
|||
fn rendering_context(&self) -> RenderingContext {
|
||||
self.rendering_context.clone()
|
||||
}
|
||||
|
||||
fn get_gl_context(&self) -> PlayerGLContext {
|
||||
if !pref!(media.glvideo.enabled) {
|
||||
return PlayerGLContext::Unknown;
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
let native_context = self.rendering_context.native_context();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
return PlayerGLContext::Egl(native_context.egl_context as usize);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
return match native_context {
|
||||
NativeContext::Default(NativeContext::Default(native_context)) => {
|
||||
PlayerGLContext::Egl(native_context.egl_context as usize)
|
||||
},
|
||||
NativeContext::Default(NativeContext::Alternate(native_context)) => {
|
||||
PlayerGLContext::Egl(native_context.egl_context as usize)
|
||||
},
|
||||
NativeContext::Alternate(_) => unimplemented!(),
|
||||
};
|
||||
|
||||
// @TODO(victor): https://github.com/servo/media/pull/315
|
||||
#[cfg(target_os = "macos")]
|
||||
#[allow(unreachable_code)]
|
||||
return unimplemented!();
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
|
||||
return unimplemented!();
|
||||
}
|
||||
|
||||
fn get_native_display(&self) -> NativeDisplay {
|
||||
if !pref!(media.glvideo.enabled) {
|
||||
return NativeDisplay::Unknown;
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
let native_connection = self.rendering_context.connection().native_connection();
|
||||
#[allow(unused_variables)]
|
||||
let native_device = self.rendering_context.native_device();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
return NativeDisplay::Egl(native_device.egl_display as usize);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
return match native_connection {
|
||||
NativeConnection::Default(NativeConnection::Default(conn)) => {
|
||||
NativeDisplay::Egl(conn.0 as usize)
|
||||
},
|
||||
NativeConnection::Default(NativeConnection::Alternate(conn)) => {
|
||||
NativeDisplay::X11(conn.x11_display as usize)
|
||||
},
|
||||
NativeConnection::Alternate(_) => unimplemented!(),
|
||||
};
|
||||
|
||||
// @TODO(victor): https://github.com/servo/media/pull/315
|
||||
#[cfg(target_os = "macos")]
|
||||
#[allow(unreachable_code)]
|
||||
return unimplemented!();
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
|
||||
return unimplemented!();
|
||||
}
|
||||
|
||||
fn get_gl_api(&self) -> GlApi {
|
||||
let api = self.rendering_context.connection().gl_api();
|
||||
let attributes = self.rendering_context.context_attributes();
|
||||
let GLVersion { major, minor } = attributes.version;
|
||||
match api {
|
||||
GLApi::GL if major >= 3 && minor >= 2 => GlApi::OpenGL3,
|
||||
GLApi::GL => GlApi::OpenGL,
|
||||
GLApi::GLES if major > 1 => GlApi::Gles2,
|
||||
GLApi::GLES => GlApi::Gles1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn winit_phase_to_touch_event_type(phase: TouchPhase) -> TouchEventType {
|
||||
|
|
|
@ -15,7 +15,6 @@ use servo::rendering_context::RenderingContext;
|
|||
use servo::servo_geometry::DeviceIndependentPixel;
|
||||
use servo::style_traits::DevicePixel;
|
||||
use servo::webrender_api::units::DeviceIntRect;
|
||||
use servo_media::player::context as MediaPlayerCtxt;
|
||||
use surfman::{Connection, Context, Device, SurfaceType};
|
||||
|
||||
use crate::events_loop::WakerEvent;
|
||||
|
@ -144,18 +143,6 @@ impl WindowMethods for Window {
|
|||
self.animation_state.set(state);
|
||||
}
|
||||
|
||||
fn get_gl_context(&self) -> MediaPlayerCtxt::GlContext {
|
||||
MediaPlayerCtxt::GlContext::Unknown
|
||||
}
|
||||
|
||||
fn get_native_display(&self) -> MediaPlayerCtxt::NativeDisplay {
|
||||
MediaPlayerCtxt::NativeDisplay::Unknown
|
||||
}
|
||||
|
||||
fn get_gl_api(&self) -> MediaPlayerCtxt::GlApi {
|
||||
MediaPlayerCtxt::GlApi::None
|
||||
}
|
||||
|
||||
fn rendering_context(&self) -> RenderingContext {
|
||||
self.rendering_context.clone()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue