Fix wl_drm on winit backend

This commit is contained in:
Victor Brekenfeld 2021-06-27 22:18:45 +02:00
parent ad55ab71c9
commit eb5e4bcf92
2 changed files with 10 additions and 17 deletions

View File

@ -1,7 +1,10 @@
use std::{cell::RefCell, rc::Rc, sync::atomic::Ordering, time::Duration}; use std::{cell::RefCell, rc::Rc, sync::atomic::Ordering, time::Duration};
#[cfg(feature = "egl")] #[cfg(feature = "egl")]
use smithay::{backend::renderer::ImportDma, wayland::dmabuf::init_dmabuf_global}; use smithay::{
backend::renderer::{ImportDma, ImportEgl},
wayland::dmabuf::init_dmabuf_global,
};
use smithay::{ use smithay::{
backend::{input::InputBackend, renderer::Frame, winit, SwapBuffersError}, backend::{input::InputBackend, renderer::Frame, winit, SwapBuffersError},
reexports::{ reexports::{
@ -38,7 +41,12 @@ pub fn run_winit(
let renderer = Rc::new(RefCell::new(renderer)); let renderer = Rc::new(RefCell::new(renderer));
#[cfg(feature = "egl")] #[cfg(feature = "egl")]
if renderer.borrow().bind_wl_display(&display.borrow()).is_ok() { if renderer
.borrow_mut()
.renderer()
.bind_wl_display(&display.borrow())
.is_ok()
{
info!(log, "EGL hardware-acceleration enabled"); info!(log, "EGL hardware-acceleration enabled");
let dmabuf_formats = renderer let dmabuf_formats = renderer
.borrow_mut() .borrow_mut()

View File

@ -28,11 +28,6 @@ use winit::{
window::{Window as WinitWindow, WindowBuilder}, window::{Window as WinitWindow, WindowBuilder},
}; };
#[cfg(feature = "use_system_lib")]
use crate::backend::egl::display::EGLBufferReader;
#[cfg(feature = "use_system_lib")]
use wayland_server::Display;
/// Errors thrown by the `winit` backends /// Errors thrown by the `winit` backends
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum Error { pub enum Error {
@ -235,16 +230,6 @@ pub enum WinitEvent {
} }
impl WinitGraphicsBackend { impl WinitGraphicsBackend {
/// Bind a `wl_display` to allow hardware-accelerated clients using `wl_drm`.
///
/// Returns an `EGLBufferReader` used to access the contents of these buffers.
///
/// *Note*: Only on implementation of `wl_drm` can be bound by a single wayland display.
#[cfg(feature = "use_system_lib")]
pub fn bind_wl_display(&self, wl_display: &Display) -> Result<EGLBufferReader, EGLError> {
self.display.bind_wl_display(wl_display)
}
/// Window size of the underlying window /// Window size of the underlying window
pub fn window_size(&self) -> WindowSize { pub fn window_size(&self) -> WindowSize {
self.size.borrow().clone() self.size.borrow().clone()