Skip to content
Permalink
Browse files

Add more raw context handler for glutin port

  • Loading branch information...
ceyusa authored and ferjm committed Jun 17, 2019
1 parent 6e2ee39 commit eb3857237c2760ed17a2888f01c069566def509f
Showing with 62 additions and 14 deletions.
  1. +28 −4 ports/glutin/context.rs
  2. +34 −10 ports/glutin/headed_window.rs
@@ -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;

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(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
}
};

@@ -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;

0 comments on commit eb38572

Please sign in to comment.
You can’t perform that action at this time.