1
0
Fork 0
forked from wry/wry

gfx: move shared memory contract into types crate

This commit is contained in:
kossLAN 2026-05-29 11:39:18 -04:00
parent 37ec1a4a3f
commit bf3859a026
No known key found for this signature in database
4 changed files with 36 additions and 27 deletions

View file

@ -47,7 +47,7 @@ use {
uapi::{OwnedFd, c},
};
pub use jay_gfx_types::AlphaMode;
pub use jay_gfx_types::{AlphaMode, ShmMemory, ShmMemoryBacking};
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Linearize)]
pub enum GfxApi {
@ -798,32 +798,6 @@ pub struct PendingShmTransfer {
id: u64,
}
pub trait ShmMemory {
fn len(&self) -> usize;
fn safe_access(&self) -> ShmMemoryBacking;
fn access(&self, f: &mut dyn FnMut(&[Cell<u8>])) -> Result<(), Box<dyn Error + Sync + Send>>;
}
pub enum ShmMemoryBacking {
Ptr(*const [Cell<u8>]),
Fd(Rc<OwnedFd>, usize),
}
impl ShmMemory for Vec<Cell<u8>> {
fn len(&self) -> usize {
self.len()
}
fn safe_access(&self) -> ShmMemoryBacking {
ShmMemoryBacking::Ptr(&**self)
}
fn access(&self, f: &mut dyn FnMut(&[Cell<u8>])) -> Result<(), Box<dyn Error + Sync + Send>> {
f(self);
Ok(())
}
}
pub trait AsyncShmGfxTexture: GfxTexture {
fn staging_size(&self) -> usize {
0