aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/mod.rs8
-rw-r--r--src/backend/tty.rs12
-rw-r--r--src/backend/winit.rs13
3 files changed, 32 insertions, 1 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()
}