From aa2a4a5572972450947efd1c9e34b30b80a8f876 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 3 Oct 2024 15:03:05 +0300 Subject: [PATCH] egl: remove cfg from code not needing them --- glutin/src/api/egl/config.rs | 12 +++------- glutin/src/api/egl/surface.rs | 44 +++++------------------------------ 2 files changed, 9 insertions(+), 47 deletions(-) diff --git a/glutin/src/api/egl/config.rs b/glutin/src/api/egl/config.rs index ecbdea9d4e..75576c50d9 100644 --- a/glutin/src/api/egl/config.rs +++ b/glutin/src/api/egl/config.rs @@ -327,21 +327,15 @@ impl GlConfig for Config { unsafe { self.raw_attribute(egl::CONFIG_CAVEAT as EGLint) != egl::SLOW_CONFIG as EGLint } } - #[cfg(not(any(wayland_platform, x11_platform)))] fn supports_transparency(&self) -> Option { - None - } - - #[cfg(any(wayland_platform, x11_platform))] - fn supports_transparency(&self) -> Option { - use raw_window_handle::RawDisplayHandle; match *self.inner.display.inner._native_display? { #[cfg(x11_platform)] - RawDisplayHandle::Xlib(_) | RawDisplayHandle::Xcb(_) => { + raw_window_handle::RawDisplayHandle::Xlib(_) + | raw_window_handle::RawDisplayHandle::Xcb(_) => { self.x11_visual().map(|visual| visual.supports_transparency()) }, #[cfg(wayland_platform)] - RawDisplayHandle::Wayland(_) => Some(self.alpha_size() != 0), + raw_window_handle::RawDisplayHandle::Wayland(_) => Some(self.alpha_size() != 0), _ => None, } } diff --git a/glutin/src/api/egl/surface.rs b/glutin/src/api/egl/surface.rs index 222e033b74..c13716f304 100644 --- a/glutin/src/api/egl/surface.rs +++ b/glutin/src/api/egl/surface.rs @@ -444,25 +444,13 @@ impl Sealed for Surface {} #[derive(Debug)] enum NativeWindow { - #[cfg(wayland_platform)] + #[allow(dead_code)] Wayland(*mut ffi::c_void), - - #[cfg(x11_platform)] Xlib(std::os::raw::c_ulong), - - #[cfg(x11_platform)] Xcb(u32), - - #[cfg(android_platform)] Android(*mut ffi::c_void), - - #[cfg(ohos_platform)] Ohos(*mut ffi::c_void), - - #[cfg(windows)] Win32(isize), - - #[cfg(free_unix)] Gbm(*mut ffi::c_void), } @@ -487,7 +475,6 @@ impl NativeWindow { } Self::Wayland(ptr.cast()) }, - #[cfg(x11_platform)] RawWindowHandle::Xlib(window_handle) => { if window_handle.window == 0 { return Err(ErrorKind::BadNativeWindow.into()); @@ -495,19 +482,14 @@ impl NativeWindow { Self::Xlib(window_handle.window as _) }, - #[cfg(x11_platform)] RawWindowHandle::Xcb(window_handle) => Self::Xcb(window_handle.window.get() as _), - #[cfg(android_platform)] RawWindowHandle::AndroidNdk(window_handle) => { Self::Android(window_handle.a_native_window.as_ptr()) }, - #[cfg(ohos_platform)] RawWindowHandle::OhosNdk(window_handle) => { Self::Ohos(window_handle.native_window.as_ptr()) }, - #[cfg(windows)] RawWindowHandle::Win32(window_handle) => Self::Win32(window_handle.hwnd.get() as _), - #[cfg(free_unix)] RawWindowHandle::Gbm(window_handle) => Self::Gbm(window_handle.gbm_surface.as_ptr()), _ => { return Err( @@ -539,20 +521,13 @@ impl NativeWindow { /// Returns the underlying handle value. fn as_native_window(&self) -> egl::NativeWindowType { match *self { - #[cfg(wayland_platform)] - Self::Wayland(wl_egl_surface) => wl_egl_surface, - #[cfg(x11_platform)] + Self::Wayland(wl_egl_surface) => wl_egl_surface as egl::NativeWindowType, Self::Xlib(window_id) => window_id as egl::NativeWindowType, - #[cfg(x11_platform)] Self::Xcb(window_id) => window_id as egl::NativeWindowType, - #[cfg(windows)] - Self::Win32(hwnd) => hwnd, - #[cfg(android_platform)] - Self::Android(a_native_window) => a_native_window, - #[cfg(ohos_platform)] - Self::Ohos(native_window) => native_window, - #[cfg(free_unix)] - Self::Gbm(gbm_surface) => gbm_surface, + Self::Win32(hwnd) => hwnd as egl::NativeWindowType, + Self::Android(a_native_window) => a_native_window as egl::NativeWindowType, + Self::Ohos(native_window) => native_window as egl::NativeWindowType, + Self::Gbm(gbm_surface) => gbm_surface as egl::NativeWindowType, } } @@ -572,19 +547,12 @@ impl NativeWindow { /// On X11 the returned pointer is a cast of the `&self` borrow. fn as_platform_window(&self) -> *mut ffi::c_void { match self { - #[cfg(wayland_platform)] Self::Wayland(wl_egl_surface) => *wl_egl_surface, - #[cfg(x11_platform)] Self::Xlib(window_id) => window_id as *const _ as *mut ffi::c_void, - #[cfg(x11_platform)] Self::Xcb(window_id) => window_id as *const _ as *mut ffi::c_void, - #[cfg(windows)] Self::Win32(hwnd) => *hwnd as *const ffi::c_void as *mut _, - #[cfg(android_platform)] Self::Android(a_native_window) => *a_native_window, - #[cfg(ohos_platform)] Self::Ohos(native_window) => *native_window, - #[cfg(free_unix)] Self::Gbm(gbm_surface) => *gbm_surface, } }