From f3671e8843b5e6dbf13c8300aa5aed50a557d36a Mon Sep 17 00:00:00 2001 From: i509VCB Date: Tue, 17 May 2022 19:36:22 -0500 Subject: [PATCH] expose egl display in gles --- wgpu-hal/src/gles/egl.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 9539fe211e9..2e5bf15dbb4 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -1,5 +1,5 @@ use glow::HasContext; -use parking_lot::{Mutex, MutexGuard}; +use parking_lot::{MappedMutexGuard, Mutex, MutexGuard}; use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; use std::{ffi, os::raw, ptr, sync::Arc, time::Duration}; @@ -580,6 +580,25 @@ pub struct Instance { inner: Mutex, } +impl Instance { + pub fn raw_display(&self) -> MappedMutexGuard<'_, egl::Display> { + MutexGuard::map( + self.inner + .try_lock() + .expect("Could not lock instance. This is most-likely a deadlock."), + |inner| &mut inner.egl.display, + ) + } + + /// Returns the version of the EGL display. + pub fn egl_version(&self) -> (i32, i32) { + self.inner + .try_lock() + .expect("Could not lock instance. This is most-likely a deadlock.") + .version + } +} + unsafe impl Send for Instance {} unsafe impl Sync for Instance {}