cosmic-comp/src/wayland/handlers/dmabuf.rs

41 lines
1.2 KiB
Rust
Raw Normal View History

// SPDX-License-Identifier: GPL-3.0-only
2022-07-04 16:00:29 +02:00
use crate::state::{BackendData, State};
use smithay::{
2022-07-04 16:00:29 +02:00
backend::{allocator::dmabuf::Dmabuf, renderer::ImportDma},
delegate_dmabuf,
wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError},
};
impl DmabufHandler for State {
fn dmabuf_state(&mut self) -> &mut DmabufState {
&mut self.common.dmabuf_state
}
2022-07-04 16:00:29 +02:00
fn dmabuf_imported(
&mut self,
global: &DmabufGlobal,
dmabuf: Dmabuf,
) -> Result<(), ImportError> {
match &mut self.backend {
BackendData::Kms(ref mut state) => state
2022-08-31 13:01:23 +02:00
.dmabuf_imported(global, dmabuf)
.map_err(|_| ImportError::Failed),
2022-07-04 16:00:29 +02:00
BackendData::Winit(ref mut state) => state
.backend
.renderer()
.import_dmabuf(&dmabuf, None)
.map(|_| ())
.map_err(|_| ImportError::Failed),
2022-07-04 16:00:29 +02:00
BackendData::X11(ref mut state) => state
.renderer
.import_dmabuf(&dmabuf, None)
.map(|_| ())
.map_err(|_| ImportError::Failed),
_ => unreachable!("No backend set when importing dmabuf"),
}
}
}
delegate_dmabuf!(State);