From eb3857237c2760ed17a2888f01c069566def509f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 17 Jun 2019 11:46:24 +0200 Subject: Add more raw context handler for glutin port --- ports/glutin/context.rs | 32 +++++++++++++++++++++++++++---- ports/glutin/headed_window.rs | 44 +++++++++++++++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 14 deletions(-) (limited to 'ports/glutin') diff --git a/ports/glutin/context.rs b/ports/glutin/context.rs index 4328f9e47ea..ed56a7afc76 100644 --- a/ports/glutin/context.rs +++ b/ports/glutin/context.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() }, diff --git a/ports/glutin/headed_window.rs b/ports/glutin/headed_window.rs index 9f934029aa6..c19d2bdb63b 100644 --- a/ports/glutin/headed_window.rs +++ b/ports/glutin/headed_window.rs @@ -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; -- cgit v1.2.3