From 73447bd66862820fb14ec398f9ec7d8c6c0100e4 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Mon, 18 May 2020 20:19:42 +0200 Subject: [PATCH] egl: Pass clonable display handle to native-impls --- src/backend/drm/gbm/egl.rs | 3 ++- src/backend/egl/native.rs | 7 ++++--- src/backend/egl/surface.rs | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/backend/drm/gbm/egl.rs b/src/backend/drm/gbm/egl.rs index 4be4583..6e8d830 100644 --- a/src/backend/drm/gbm/egl.rs +++ b/src/backend/drm/gbm/egl.rs @@ -17,6 +17,7 @@ use drm::control::{connector, crtc, Device as ControlDevice, Mode}; use gbm::AsRaw; use nix::libc::{c_int, c_void}; use std::marker::PhantomData; +use std::sync::Arc; /// Egl Gbm backend type /// @@ -89,7 +90,7 @@ unsafe impl NativeSurface for GbmSurface { unsafe fn create( &self, - display: &EGLDisplayHandle, + display: &Arc, config_id: ffi::egl::types::EGLConfig, surface_attributes: &[c_int], ) -> Result<*const c_void, SurfaceCreationError> { diff --git a/src/backend/egl/native.rs b/src/backend/egl/native.rs index b2db1b3..b878cf3 100644 --- a/src/backend/egl/native.rs +++ b/src/backend/egl/native.rs @@ -4,6 +4,7 @@ use super::{ display::EGLDisplayHandle, ffi, wrap_egl_call, EGLError, Error, SurfaceCreationError, SwapBuffersError, }; use nix::libc::{c_int, c_void}; +use std::sync::Arc; #[cfg(feature = "backend_winit")] use wayland_egl as wegl; @@ -211,7 +212,7 @@ pub unsafe trait NativeSurface { /// This is usually an unsafe operation returning a raw pointer. unsafe fn create( &self, - display: &EGLDisplayHandle, + display: &Arc, config_id: ffi::egl::types::EGLConfig, surface_attributes: &[c_int], ) -> Result<*const c_void, SurfaceCreationError>; @@ -248,7 +249,7 @@ unsafe impl NativeSurface for XlibWindow { unsafe fn create( &self, - display: &EGLDisplayHandle, + display: &Arc, config_id: ffi::egl::types::EGLConfig, surface_attributes: &[c_int], ) -> Result<*const c_void, SurfaceCreationError> { @@ -270,7 +271,7 @@ unsafe impl NativeSurface for wegl::WlEglSurface { unsafe fn create( &self, - display: &EGLDisplayHandle, + display: &Arc, config_id: ffi::egl::types::EGLConfig, surface_attributes: &[c_int], ) -> Result<*const c_void, SurfaceCreationError> { diff --git a/src/backend/egl/surface.rs b/src/backend/egl/surface.rs index 8556556..00d1d42 100644 --- a/src/backend/egl/surface.rs +++ b/src/backend/egl/surface.rs @@ -69,7 +69,7 @@ impl EGLSurface { out }; - let surface = unsafe { native.create(&*display, config, &surface_attributes)? }; + let surface = unsafe { native.create(&display, config, &surface_attributes)? }; if surface == ffi::egl::NO_SURFACE { return Err(SurfaceCreationError::EGLSurfaceCreationFailed( @@ -111,7 +111,7 @@ impl EGLSurface { } self.surface.set(unsafe { self.native - .create(&*self.display, self.config_id, &self.surface_attributes) + .create(&self.display, self.config_id, &self.surface_attributes) .map_err(|err| match err { SurfaceCreationError::EGLSurfaceCreationFailed(err) => { SwapBuffersError::EGLCreateWindowSurface(err)