mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add more raw context handler for glutin port
This commit is contained in:
parent
6e2ee394c9
commit
eb3857237c
2 changed files with 61 additions and 13 deletions
|
@ -77,30 +77,53 @@ impl GlContext {
|
|||
pub fn raw_context(&self) -> RawContext {
|
||||
match self {
|
||||
GlContext::Current(c) => {
|
||||
let raw_handle = unsafe { c.raw_handle() };
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
target_os = "openbsd",
|
||||
))]
|
||||
{
|
||||
use glutin::os::unix::RawHandle;
|
||||
|
||||
let raw_handle = unsafe { c.raw_handle() };
|
||||
return match raw_handle {
|
||||
RawHandle::Egl(handle) => RawContext::Egl(handle as usize),
|
||||
RawHandle::Glx(handle) => RawContext::Glx(handle as usize),
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use glutin::os::windows::RawHandle;
|
||||
|
||||
let raw_handle = unsafe { c.raw_handle() };
|
||||
return match raw_handle {
|
||||
RawHandle::Egl(handle) => RawContext::Egl(handle as usize),
|
||||
// @TODO(victor): RawContext::Wgl in servo-media
|
||||
RawHandle::Wgl(_) => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let raw_handle = unsafe { c.raw_handle() };
|
||||
return RawContext::Egl(raw_handle as usize);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
return unimplemeneted!(); // @TODO(victor): RawContext::Cocoa in servo-media
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
target_os = "openbsd",
|
||||
target_os = "windows",
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
)))]
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -111,6 +134,7 @@ impl GlContext {
|
|||
GlContext::None => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn egl_display(&self) -> Option<*const raw::c_void> {
|
||||
match self {
|
||||
GlContext::Current(c) => unsafe { c.get_egl_display() },
|
||||
|
|
|
@ -544,21 +544,43 @@ impl WindowMethods for Window {
|
|||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
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 {
|
||||
use glutin::os::unix::WindowExt;
|
||||
#[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
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -567,7 +589,9 @@ impl WindowMethods for Window {
|
|||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
target_os = "openbsd",
|
||||
target_os = "windows",
|
||||
target_os = "android",
|
||||
)))]
|
||||
let native_display = NativeDisplay::Unknown;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue