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