forge
Explore
Log in

Don't you dare go Hollow

Move import_dmabuf to backends

Browse files at this commit

57a73476207bd33a26b39964feb01bb673be8a2bIvan MolodetskikhParent: 628891d
src/backend/mod.rsmodified+8 -0
@@ -2,6 +2,7 @@ use std::collections::HashMap;
2 use std::sync::{Arc, Mutex};2 use std::sync::{Arc, Mutex};
3 use std::time::Duration;3 use std::time::Duration;
4 4
5+use smithay::backend::allocator::dmabuf::Dmabuf;
5 use smithay::backend::renderer::gles::GlesRenderer;6 use smithay::backend::renderer::gles::GlesRenderer;
6 use smithay::output::Output;7 use smithay::output::Output;
7 8
@@ -93,6 +94,13 @@ impl Backend {
93 }94 }
94 }95 }
95 96
97+ pub fn import_dmabuf(&mut self, dmabuf: &Dmabuf) -> Result<(), ()> {
98+ match self {
99+ Backend::Tty(tty) => tty.import_dmabuf(dmabuf),
100+ Backend::Winit(winit) => winit.import_dmabuf(dmabuf),
101+ }
102+ }
103+
96 #[cfg_attr(not(feature = "dbus"), allow(unused))]104 #[cfg_attr(not(feature = "dbus"), allow(unused))]
97 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {105 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
98 match self {106 match self {
src/backend/tty.rsmodified+12 -0
@@ -8,6 +8,7 @@ use std::time::Duration;
8 8
9 use anyhow::{anyhow, Context};9 use anyhow::{anyhow, Context};
10 use libc::dev_t;10 use libc::dev_t;
11+use smithay::backend::allocator::dmabuf::Dmabuf;
11 use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};12 use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
12 use smithay::backend::allocator::Fourcc;13 use smithay::backend::allocator::Fourcc;
13 use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};14 use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
@@ -974,6 +975,17 @@ impl Tty {
974 }975 }
975 }976 }
976 977
978+ pub fn import_dmabuf(&mut self, dmabuf: &Dmabuf) -> Result<(), ()> {
979+ let device = self.output_device.as_mut().ok_or(())?;
980+ match device.gles.import_dmabuf(dmabuf, None) {
981+ Ok(_texture) => Ok(()),
982+ Err(err) => {
983+ debug!("error importing dmabuf: {err:?}");
984+ Err(())
985+ }
986+ }
987+ }
988+
977 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {989 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
978 self.connectors.clone()990 self.connectors.clone()
979 }991 }
src/backend/winit.rsmodified+12 -1
@@ -5,9 +5,10 @@ use std::rc::Rc;
5 use std::sync::{Arc, Mutex};5 use std::sync::{Arc, Mutex};
6 use std::time::Duration;6 use std::time::Duration;
7 7
8+use smithay::backend::allocator::dmabuf::Dmabuf;
8 use smithay::backend::renderer::damage::OutputDamageTracker;9 use smithay::backend::renderer::damage::OutputDamageTracker;
9 use smithay::backend::renderer::gles::GlesRenderer;10 use smithay::backend::renderer::gles::GlesRenderer;
10-use smithay::backend::renderer::{DebugFlags, ImportEgl, Renderer};11+use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};
11 use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};12 use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};
12 use smithay::output::{Mode, Output, PhysicalProperties, Scale, Subpixel};13 use smithay::output::{Mode, Output, PhysicalProperties, Scale, Subpixel};
13 use smithay::reexports::calloop::LoopHandle;14 use smithay::reexports::calloop::LoopHandle;
@@ -199,6 +200,16 @@ impl Winit {
199 renderer.set_debug_flags(renderer.debug_flags() ^ DebugFlags::TINT);200 renderer.set_debug_flags(renderer.debug_flags() ^ DebugFlags::TINT);
200 }201 }
201 202
203+ pub fn import_dmabuf(&mut self, dmabuf: &Dmabuf) -> Result<(), ()> {
204+ match self.backend.renderer().import_dmabuf(dmabuf, None) {
205+ Ok(_texture) => Ok(()),
206+ Err(err) => {
207+ debug!("error importing dmabuf: {err:?}");
208+ Err(())
209+ }
210+ }
211+ }
212+
202 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {213 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
203 self.connectors.clone()214 self.connectors.clone()
204 }215 }
src/handlers/mod.rsmodified+3 -10
@@ -9,7 +9,6 @@ use std::sync::Arc;
9 use std::thread;9 use std::thread;
10 10
11 use smithay::backend::allocator::dmabuf::Dmabuf;11 use smithay::backend::allocator::dmabuf::Dmabuf;
12-use smithay::backend::renderer::ImportDma;
13 use smithay::desktop::{PopupKind, PopupManager};12 use smithay::desktop::{PopupKind, PopupManager};
14 use smithay::input::pointer::{CursorIcon, CursorImageStatus, PointerHandle};13 use smithay::input::pointer::{CursorIcon, CursorImageStatus, PointerHandle};
15 use smithay::input::{Seat, SeatHandler, SeatState};14 use smithay::input::{Seat, SeatHandler, SeatState};
@@ -202,17 +201,11 @@ impl DmabufHandler for State {
202 dmabuf: Dmabuf,201 dmabuf: Dmabuf,
203 notifier: ImportNotifier,202 notifier: ImportNotifier,
204 ) {203 ) {
205- let Some(renderer) = self.backend.renderer() else {204+ match self.backend.import_dmabuf(&dmabuf) {
206- notifier.failed();205+ Ok(_) => {
207- return;
208- };
209-
210- match renderer.import_dmabuf(&dmabuf, None) {
211- Ok(_texture) => {
212 let _ = notifier.successful::<State>();206 let _ = notifier.successful::<State>();
213 }207 }
214- Err(err) => {208+ Err(_) => {
215- debug!("error importing dmabuf: {err:?}");
216 notifier.failed();209 notifier.failed();
217 }210 }
218 }211 }