mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Clean up gating and order of getting display/glcontext from glutin
This patch simply simplify the OS gating for getting display and gl context from glutin since it is only used for a linux, mac and not UWP-based windows. Also, in linux tries to fetch the wayland display and don't rely on EGLDisplay because it might bring problems in servo/media. Nonetheless it is required to compile render-unix in servo-media with feature 'gl-wayland'
This commit is contained in:
parent
45b68ecbfc
commit
115d72771e
2 changed files with 25 additions and 76 deletions
|
@ -85,13 +85,7 @@ impl GlContext {
|
|||
pub fn raw_context(&self) -> RawContext {
|
||||
match self {
|
||||
GlContext::Current(c) => {
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
))]
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
use glutin::os::unix::RawHandle;
|
||||
|
||||
|
@ -114,23 +108,14 @@ impl GlContext {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let raw_handle = unsafe { c.raw_handle() };
|
||||
return RawContext::Egl(raw_handle as usize);
|
||||
}
|
||||
|
||||
// @TODO(victor): https://github.com/rust-windowing/glutin/pull/1221
|
||||
// https://github.com/servo/media/pull/315
|
||||
#[cfg(target_os = "macos")]
|
||||
return unimplemented!(); // @TODO(victor): RawContext::Cocoa in servo-media
|
||||
return unimplemented!();
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "windows",
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
)))]
|
||||
unimplemented!()
|
||||
|
|
|
@ -14,6 +14,8 @@ use gleam::gl;
|
|||
use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||
#[cfg(target_os = "macos")]
|
||||
use glutin::os::macos::{ActivationPolicy, WindowBuilderExt};
|
||||
#[cfg(target_os = "linux")]
|
||||
use glutin::os::unix::WindowExt;
|
||||
use glutin::Api;
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
use glutin::Icon;
|
||||
|
@ -577,10 +579,10 @@ impl WindowMethods for Window {
|
|||
|
||||
fn get_gl_context(&self) -> PlayerGLContext {
|
||||
if pref!(media.glvideo.enabled) {
|
||||
self.gl_context.borrow().raw_context()
|
||||
} else {
|
||||
PlayerGLContext::Unknown
|
||||
return self.gl_context.borrow().raw_context();
|
||||
}
|
||||
|
||||
return PlayerGLContext::Unknown;
|
||||
}
|
||||
|
||||
fn get_native_display(&self) -> NativeDisplay {
|
||||
|
@ -588,63 +590,25 @@ impl WindowMethods for Window {
|
|||
return NativeDisplay::Unknown;
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "windows",
|
||||
target_os = "android",
|
||||
))]
|
||||
let native_display = {
|
||||
if let Some(display) = self.gl_context.borrow().egl_display() {
|
||||
NativeDisplay::Egl(display as usize)
|
||||
} else {
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
))]
|
||||
{
|
||||
use glutin::os::unix::WindowExt;
|
||||
|
||||
if let Some(display) = self.gl_context.borrow().window().get_wayland_display() {
|
||||
NativeDisplay::Wayland(display as usize)
|
||||
} else if let Some(display) =
|
||||
self.gl_context.borrow().window().get_xlib_display()
|
||||
{
|
||||
NativeDisplay::X11(display as usize)
|
||||
} else {
|
||||
NativeDisplay::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
)))]
|
||||
NativeDisplay::Unknown
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
if let Some(display) = self.gl_context.borrow().window().get_wayland_display() {
|
||||
return NativeDisplay::Wayland(display as usize);
|
||||
} else if let Some(display) =
|
||||
self.gl_context.borrow().window().get_xlib_display()
|
||||
{
|
||||
return NativeDisplay::X11(display as usize);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "windows",
|
||||
target_os = "android",
|
||||
)))]
|
||||
let native_display = NativeDisplay::Unknown;
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
{
|
||||
if let Some(display) = self.gl_context.borrow().egl_display() {
|
||||
return NativeDisplay::Egl(display as usize);
|
||||
}
|
||||
}
|
||||
|
||||
native_display
|
||||
NativeDisplay::Unknown
|
||||
}
|
||||
|
||||
fn get_gl_api(&self) -> GlApi {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue