gfx: move shared memory contract into types crate
This commit is contained in:
parent
37ec1a4a3f
commit
bf3859a026
4 changed files with 36 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue