From 21d017292e6e6a6df8fff13f5bf96393c3816da7 Mon Sep 17 00:00:00 2001 From: Kilika Date: Thu, 5 Sep 2024 15:40:58 +0300 Subject: [PATCH] Inlined the sanitization in the `initialize_display` function --- glutin/src/api/egl/display.rs | 42 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/glutin/src/api/egl/display.rs b/glutin/src/api/egl/display.rs index fa98513827..6a30f7fbe2 100644 --- a/glutin/src/api/egl/display.rs +++ b/glutin/src/api/egl/display.rs @@ -485,29 +485,10 @@ impl Display { Version::new(major as u8, minor as u8) }; - // Sanitize for libglvnd's aliasing. + // Sanitize the display provider, as the received EGL 1.4 display could have + // been marked incorrectly as `EglDisplay::Khr`. #[cfg(free_unix)] - let display = Self::sanitize_egl_display_provider(display, version); - - // Load extensions. - let display_extensions = get_extensions(egl, *display); - let features = Self::extract_display_features(&display_extensions, version); - - let inner = Arc::new(DisplayInner { - egl, - raw: display, - _native_display: raw_display_handle.map(NativeDisplay), - version, - display_extensions, - features, - }); - Ok(Self { inner }) - } - - #[cfg(free_unix)] - fn sanitize_egl_display_provider(display: EglDisplay, version: Version) -> EglDisplay { - let client_extensions = CLIENT_EXTENSIONS.get().unwrap(); - match display { + let display = match display { // Since according to libglvnd, `eglGetPlatformDisplay` and `GetPlatformDisplayEXT` // aren't really differentiated under the hood, we must check if the version of the // initialized display is not sensible for the EglDisplay type and downgrade it if so @@ -516,6 +497,7 @@ impl Display { // https://gitlab.freedesktop.org/glvnd/libglvnd/-/blob/606f6627cf481ee6dcb32387edc010c502cdf38b/include/glvnd/libeglabi.h#L231-232 // https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/251 EglDisplay::Khr(display) if version == Version { major: 1, minor: 4 } => { + let client_extensions = CLIENT_EXTENSIONS.get().unwrap(); if client_extensions.contains("EGL_EXT_platform_base") { EglDisplay::Ext(display) } else { @@ -524,7 +506,21 @@ impl Display { }, // We do not do anything otherwise. display => display, - } + }; + + // Load extensions. + let display_extensions = get_extensions(egl, *display); + let features = Self::extract_display_features(&display_extensions, version); + + let inner = Arc::new(DisplayInner { + egl, + raw: display, + _native_display: raw_display_handle.map(NativeDisplay), + version, + display_extensions, + features, + }); + Ok(Self { inner }) } }