diff --git a/anvil/src/buffer_utils.rs b/anvil/src/buffer_utils.rs index af1d194..e784177 100644 --- a/anvil/src/buffer_utils.rs +++ b/anvil/src/buffer_utils.rs @@ -3,7 +3,7 @@ use std::{cell::RefCell, rc::Rc}; use slog::Logger; #[cfg(feature = "egl")] -use smithay::backend::egl::display::WaylandEGLDisplay; +use smithay::backend::egl::display::EGLBufferReader; use smithay::{ reexports::wayland_server::protocol::wl_buffer::WlBuffer, wayland::shm::with_buffer_contents as shm_buffer_contents, @@ -13,15 +13,18 @@ use smithay::{ #[derive(Clone)] pub struct BufferUtils { #[cfg(feature = "egl")] - egl_display: Rc>>, + egl_buffer_reader: Rc>>, log: Logger, } impl BufferUtils { /// Creates a new `BufferUtils`. #[cfg(feature = "egl")] - pub fn new(egl_display: Rc>>, log: Logger) -> Self { - Self { egl_display, log } + pub fn new(egl_buffer_reader: Rc>>, log: Logger) -> Self { + Self { + egl_buffer_reader, + log, + } } /// Creates a new `BufferUtils`. @@ -34,7 +37,7 @@ impl BufferUtils { #[cfg(feature = "egl")] pub fn dimensions(&self, buffer: &WlBuffer) -> Option<(i32, i32)> { // Try to retrieve the EGL dimensions of this buffer, and, if that fails, the shm dimensions. - self.egl_display + self.egl_buffer_reader .borrow() .as_ref() .and_then(|display| display.egl_buffer_dimensions(buffer)) diff --git a/anvil/src/glium_drawer.rs b/anvil/src/glium_drawer.rs index 19b8c89..b8e6f10 100644 --- a/anvil/src/glium_drawer.rs +++ b/anvil/src/glium_drawer.rs @@ -12,7 +12,7 @@ use glium::{ use slog::Logger; #[cfg(feature = "egl")] -use smithay::backend::egl::display::WaylandEGLDisplay; +use smithay::backend::egl::display::EGLBufferReader; use smithay::{ backend::{ egl::{BufferAccessError, EGLImages, Format}, @@ -44,7 +44,7 @@ pub struct GliumDrawer { index_buffer: glium::IndexBuffer, programs: [glium::Program; shaders::FRAGMENT_COUNT], #[cfg(feature = "egl")] - egl_display: Rc>>, + egl_buffer_reader: Rc>>, log: Logger, } @@ -58,7 +58,7 @@ impl> + GLGraphicsBackend + 'static> GliumDrawer #[cfg(feature = "egl")] pub fn init( backend: T, - egl_display: Rc>>, + egl_buffer_reader: Rc>>, log: Logger, ) -> GliumDrawer { let display = backend.into(); @@ -98,7 +98,7 @@ impl> + GLGraphicsBackend + 'static> GliumDrawer vertex_buffer, index_buffer, programs, - egl_display, + egl_buffer_reader, log, } } @@ -151,7 +151,7 @@ impl GliumDrawer { #[cfg(feature = "egl")] pub fn texture_from_buffer(&self, buffer: wl_buffer::WlBuffer) -> Result { // try to retrieve the egl contents of this buffer - let images = if let Some(display) = &self.egl_display.borrow().as_ref() { + let images = if let Some(display) = &self.egl_buffer_reader.borrow().as_ref() { display.egl_buffer_contents(buffer) } else { Err(BufferAccessError::NotManaged(buffer)) diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index ed6f9c9..5fc1c81 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -15,7 +15,7 @@ use glium::Surface as GliumSurface; use slog::Logger; #[cfg(feature = "egl")] -use smithay::backend::egl::{display::WaylandEGLDisplay, EGLGraphicsBackend}; +use smithay::backend::egl::{display::EGLBufferReader, EGLGraphicsBackend}; use smithay::{ backend::{ drm::{ @@ -85,10 +85,10 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop, log ::std::env::set_var("WAYLAND_DISPLAY", name); #[cfg(feature = "egl")] - let active_egl_context = Rc::new(RefCell::new(None)); + let egl_buffer_reader = Rc::new(RefCell::new(None)); #[cfg(feature = "egl")] - let buffer_utils = BufferUtils::new(active_egl_context.clone(), log.clone()); + let buffer_utils = BufferUtils::new(egl_buffer_reader.clone(), log.clone()); #[cfg(not(feature = "egl"))] let buffer_utils = BufferUtils::new(log.clone()); @@ -127,7 +127,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop, log UdevHandlerImpl { compositor_token, #[cfg(feature = "egl")] - active_egl_context, + egl_buffer_reader, session: session.clone(), backends: HashMap::new(), display: display.clone(), @@ -294,7 +294,7 @@ struct BackendData { struct UdevHandlerImpl { compositor_token: CompositorToken, #[cfg(feature = "egl")] - active_egl_context: Rc>>, + egl_buffer_reader: Rc>>, session: AutoSession, backends: HashMap>, display: Rc>, @@ -313,7 +313,7 @@ impl UdevHandlerImpl { #[cfg(feature = "egl")] pub fn scan_connectors( device: &mut RenderDevice, - egl_display: Rc>>, + egl_buffer_reader: Rc>>, logger: &::slog::Logger, ) -> HashMap> { // Get a set of all modesetting resource handles (excluding planes): @@ -343,7 +343,7 @@ impl UdevHandlerImpl { if let Entry::Vacant(entry) = backends.entry(crtc) { let renderer = GliumDrawer::init( device.create_surface(crtc).unwrap(), - egl_display.clone(), + egl_buffer_reader.clone(), logger.clone(), ); @@ -419,7 +419,7 @@ impl UdevHandler for UdevHandlerImpl #[cfg(feature = "egl")] { if path.canonicalize().ok() == self.primary_gpu { - *self.active_egl_context.borrow_mut() = + *self.egl_buffer_reader.borrow_mut() = device.bind_wl_display(&*self.display.borrow()).ok(); } } @@ -427,7 +427,7 @@ impl UdevHandler for UdevHandlerImpl #[cfg(feature = "egl")] let backends = Rc::new(RefCell::new(UdevHandlerImpl::::scan_connectors( &mut device, - self.active_egl_context.clone(), + self.egl_buffer_reader.clone(), &self.logger, ))); @@ -491,7 +491,7 @@ impl UdevHandler for UdevHandlerImpl #[cfg(feature = "egl")] let new_backends = UdevHandlerImpl::::scan_connectors( &mut (*evented).0, - self.active_egl_context.clone(), + self.egl_buffer_reader.clone(), &self.logger, ); #[cfg(not(feature = "egl"))] @@ -532,7 +532,7 @@ impl UdevHandler for UdevHandlerImpl #[cfg(feature = "egl")] { if device.dev_path().and_then(|path| path.canonicalize().ok()) == self.primary_gpu { - *self.active_egl_context.borrow_mut() = None; + *self.egl_buffer_reader.borrow_mut() = None; } } diff --git a/anvil/src/winit.rs b/anvil/src/winit.rs index c29c3bd..bdf13e5 100644 --- a/anvil/src/winit.rs +++ b/anvil/src/winit.rs @@ -37,10 +37,10 @@ pub fn run_winit( let (renderer, mut input) = winit::init(log.clone()).map_err(|_| ())?; #[cfg(feature = "egl")] - let egl_display = Rc::new(RefCell::new( - if let Ok(egl_display) = renderer.bind_wl_display(&display) { + let egl_buffer_reader = Rc::new(RefCell::new( + if let Ok(egl_buffer_reader) = renderer.bind_wl_display(&display) { info!(log, "EGL hardware-acceleration enabled"); - Some(egl_display) + Some(egl_buffer_reader) } else { None }, @@ -48,12 +48,12 @@ pub fn run_winit( let (w, h) = renderer.get_framebuffer_dimensions(); #[cfg(feature = "egl")] - let drawer = GliumDrawer::init(renderer, egl_display.clone(), log.clone()); + let drawer = GliumDrawer::init(renderer, egl_buffer_reader.clone(), log.clone()); #[cfg(not(feature = "egl"))] let drawer = GliumDrawer::init(renderer, log.clone()); #[cfg(feature = "egl")] - let buffer_utils = BufferUtils::new(egl_display, log.clone()); + let buffer_utils = BufferUtils::new(egl_buffer_reader, log.clone()); #[cfg(not(feature = "egl"))] let buffer_utils = BufferUtils::new(log.clone()); diff --git a/src/backend/drm/egl/mod.rs b/src/backend/drm/egl/mod.rs index dfb9839..2be43c0 100644 --- a/src/backend/drm/egl/mod.rs +++ b/src/backend/drm/egl/mod.rs @@ -19,7 +19,7 @@ use super::{Device, DeviceHandler, Surface}; use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface}; use crate::backend::egl::Error as EGLError; #[cfg(feature = "use_system_lib")] -use crate::backend::egl::{display::WaylandEGLDisplay, EGLGraphicsBackend}; +use crate::backend::egl::{display::EGLBufferReader, EGLGraphicsBackend}; mod surface; pub use self::surface::*; @@ -199,7 +199,7 @@ where D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { - fn bind_wl_display(&self, display: &Display) -> Result { + fn bind_wl_display(&self, display: &Display) -> Result { self.dev.bind_wl_display(display) } } diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index 8cb8e3e..4fc73d6 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -410,7 +410,7 @@ impl> EGLGraphicsBackend for EGL /// /// This might return [`OtherEGLDisplayAlreadyBound`](ErrorKind::OtherEGLDisplayAlreadyBound) /// if called for the same [`Display`] multiple times, as only one egl display may be bound at any given time. - fn bind_wl_display(&self, display: &Display) -> Result { + fn bind_wl_display(&self, display: &Display) -> Result { if !self.extensions.iter().any(|s| s == "EGL_WL_bind_wayland_display") { return Err(Error::EglExtensionNotSupported(&["EGL_WL_bind_wayland_display"])); } @@ -418,7 +418,7 @@ impl> EGLGraphicsBackend for EGL if res == 0 { return Err(Error::OtherEGLDisplayAlreadyBound); } - Ok(WaylandEGLDisplay::new( + Ok(EGLBufferReader::new( Arc::downgrade(&self.display), display.c_ptr(), &self.extensions, @@ -430,7 +430,7 @@ impl> EGLGraphicsBackend for EGL /// /// Can be created by using [`EGLGraphicsBackend::bind_wl_display`]. #[cfg(feature = "use_system_lib")] -pub struct WaylandEGLDisplay { +pub struct EGLBufferReader { display: Weak, wayland: *mut wl_display, #[cfg(feature = "renderer_gl")] @@ -440,7 +440,7 @@ pub struct WaylandEGLDisplay { } #[cfg(feature = "use_system_lib")] -impl WaylandEGLDisplay { +impl EGLBufferReader { fn new( display: Weak, wayland: *mut wl_display, @@ -609,7 +609,7 @@ impl WaylandEGLDisplay { } #[cfg(feature = "use_system_lib")] -impl Drop for WaylandEGLDisplay { +impl Drop for EGLBufferReader { fn drop(&mut self) { if let Some(display) = self.display.upgrade() { if !self.wayland.is_null() { diff --git a/src/backend/egl/mod.rs b/src/backend/egl/mod.rs index 16d29d1..b2a31dc 100644 --- a/src/backend/egl/mod.rs +++ b/src/backend/egl/mod.rs @@ -41,7 +41,7 @@ pub mod native; pub mod surface; pub use self::surface::EGLSurface; #[cfg(feature = "use_system_lib")] -use crate::backend::egl::display::WaylandEGLDisplay; +use crate::backend::egl::display::EGLBufferReader; use std::ffi::CString; use std::sync::Weak; @@ -246,7 +246,7 @@ impl Drop for EGLImages { } /// Trait any backend type may implement that allows binding a [`Display`](wayland_server::Display) -/// to create an [`WaylandDisplay`](display::WaylandDisplay) for EGL-based [`WlBuffer`]s. +/// to create an [`EGLBufferReader`](display::EGLBufferReader) for EGL-based [`WlBuffer`]s. #[cfg(feature = "use_system_lib")] pub trait EGLGraphicsBackend { /// Binds this EGL context to the given Wayland display. @@ -261,5 +261,5 @@ pub trait EGLGraphicsBackend { /// /// This might return [`OtherEGLDisplayAlreadyBound`](ErrorKind::OtherEGLDisplayAlreadyBound) /// if called for the same [`Display`] multiple times, as only one context may be bound at any given time. - fn bind_wl_display(&self, display: &Display) -> Result; + fn bind_wl_display(&self, display: &Display) -> Result; } diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 5c4b28b..4c4e6ea 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -33,7 +33,7 @@ use winit::{ }; #[cfg(feature = "use_system_lib")] -use crate::backend::egl::{display::WaylandEGLDisplay, EGLGraphicsBackend}; +use crate::backend::egl::{display::EGLBufferReader, EGLGraphicsBackend}; /// Errors thrown by the `winit` backends #[derive(thiserror::Error, Debug)] @@ -336,7 +336,7 @@ impl GLGraphicsBackend for WinitGraphicsBackend { #[cfg(feature = "use_system_lib")] impl EGLGraphicsBackend for WinitGraphicsBackend { - fn bind_wl_display(&self, wl_display: &Display) -> Result { + fn bind_wl_display(&self, wl_display: &Display) -> Result { match *self.window { Window::Wayland { ref display, .. } => display.bind_wl_display(wl_display), Window::X11 { ref display, .. } => display.bind_wl_display(wl_display),