aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/mod.rs8
-rw-r--r--src/backend/tty.rs12
-rw-r--r--src/backend/winit.rs13
-rw-r--r--src/handlers/mod.rs13
4 files changed, 35 insertions, 11 deletions
diff --git a/src/backend/mod.rs b/src/backend/mod.rs
index 18c7ea10..05b898dc 100644
--- a/src/backend/mod.rs
+++ b/src/backend/mod.rs
@@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::time::Duration;
+use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::output::Output;
@@ -93,6 +94,13 @@ impl Backend {
}
}
+ pub fn import_dmabuf(&mut self, dmabuf: &Dmabuf) -> Result<(), ()> {
+ match self {
+ Backend::Tty(tty) => tty.import_dmabuf(dmabuf),
+ Backend::Winit(winit) => winit.import_dmabuf(dmabuf),
+ }
+ }
+
#[cfg_attr(not(feature = "dbus"), allow(unused))]
pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
match self {
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index e0858e6b..679073e5 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -8,6 +8,7 @@ use std::time::Duration;
use anyhow::{anyhow, Context};
use libc::dev_t;
+use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
use smithay::backend::allocator::Fourcc;
use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
@@ -974,6 +975,17 @@ impl Tty {
}
}
+ pub fn import_dmabuf(&mut self, dmabuf: &Dmabuf) -> Result<(), ()> {
+ let device = self.output_device.as_mut().ok_or(())?;
+ match device.gles.import_dmabuf(dmabuf, None) {
+ Ok(_texture) => Ok(()),
+ Err(err) => {
+ debug!("error importing dmabuf: {err:?}");
+ Err(())
+ }
+ }
+ }
+
pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
self.connectors.clone()
}
diff --git a/src/backend/winit.rs b/src/backend/winit.rs
index 7c16aaf2..3adecd4b 100644
--- a/src/backend/winit.rs
+++ b/src/backend/winit.rs
@@ -5,9 +5,10 @@ use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::time::Duration;
+use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::renderer::damage::OutputDamageTracker;
use smithay::backend::renderer::gles::GlesRenderer;
-use smithay::backend::renderer::{DebugFlags, ImportEgl, Renderer};
+use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};
use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};
use smithay::output::{Mode, Output, PhysicalProperties, Scale, Subpixel};
use smithay::reexports::calloop::LoopHandle;
@@ -199,6 +200,16 @@ impl Winit {
renderer.set_debug_flags(renderer.debug_flags() ^ DebugFlags::TINT);
}
+ pub fn import_dmabuf(&mut self, dmabuf: &Dmabuf) -> Result<(), ()> {
+ match self.backend.renderer().import_dmabuf(dmabuf, None) {
+ Ok(_texture) => Ok(()),
+ Err(err) => {
+ debug!("error importing dmabuf: {err:?}");
+ Err(())
+ }
+ }
+ }
+
pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
self.connectors.clone()
}
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index f7d94ed0..0b3d19b6 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -9,7 +9,6 @@ use std::sync::Arc;
use std::thread;
use smithay::backend::allocator::dmabuf::Dmabuf;
-use smithay::backend::renderer::ImportDma;
use smithay::desktop::{PopupKind, PopupManager};
use smithay::input::pointer::{CursorIcon, CursorImageStatus, PointerHandle};
use smithay::input::{Seat, SeatHandler, SeatState};
@@ -202,17 +201,11 @@ impl DmabufHandler for State {
dmabuf: Dmabuf,
notifier: ImportNotifier,
) {
- let Some(renderer) = self.backend.renderer() else {
- notifier.failed();
- return;
- };
-
- match renderer.import_dmabuf(&dmabuf, None) {
- Ok(_texture) => {
+ match self.backend.import_dmabuf(&dmabuf) {
+ Ok(_) => {
let _ = notifier.successful::<State>();
}
- Err(err) => {
- debug!("error importing dmabuf: {err:?}");
+ Err(_) => {
notifier.failed();
}
}