1
0
Fork 0
forked from wry/wry

text: use udmabuf for text upload

This commit is contained in:
Julian Orth 2025-10-01 14:05:33 +02:00
parent 5758e16658
commit c008b7ea35
12 changed files with 301 additions and 80 deletions

View file

@ -2,7 +2,10 @@ use {
crate::{
allocator::{Allocator, AllocatorError, BufferObject, BufferUsage, MappedBuffer},
format::Format,
utils::{compat::IoctlNumber, oserror::OsError, page_size::page_size},
utils::{
clonecell::CloneCell, compat::IoctlNumber, errorfmt::ErrorFmt, oserror::OsError,
page_size::page_size,
},
video::{
LINEAR_MODIFIER, Modifier,
dmabuf::{DmaBuf, DmaBufIds, DmaBufPlane, PlaneVec},
@ -51,6 +54,32 @@ pub enum UdmabufError {
Map(#[source] OsError),
}
#[derive(Default)]
pub struct UdmabufHolder {
udmabuf: CloneCell<Option<Option<Rc<Udmabuf>>>>,
}
impl UdmabufHolder {
pub fn get(&self) -> Option<Rc<Udmabuf>> {
if let Some(u) = self.udmabuf.get() {
return u;
}
match Udmabuf::new() {
Ok(u) => {
let u = Rc::new(u);
self.udmabuf.set(Some(Some(u.clone())));
Some(u)
}
Err(UdmabufError::Open(OsError(c::EPERM))) => None,
Err(e) => {
log::error!("Could not create udmabuf device: {}", ErrorFmt(e));
self.udmabuf.set(Some(None));
None
}
}
}
}
pub struct Udmabuf {
fd: OwnedFd,
}