wl-shm: add support for more formats
This commit is contained in:
parent
09a56edd47
commit
0570669af2
20 changed files with 114 additions and 81 deletions
|
|
@ -109,16 +109,13 @@ impl WlBuffer {
|
|||
format: &'static Format,
|
||||
mem: &Rc<ClientMem>,
|
||||
) -> Result<Self, WlBufferError> {
|
||||
let Some(shm_info) = &format.shm_info else {
|
||||
return Err(WlBufferError::UnsupportedShmFormat(format.name));
|
||||
};
|
||||
let bytes = stride as u64 * height as u64;
|
||||
let required = bytes + offset as u64;
|
||||
if required > mem.len() as u64 {
|
||||
return Err(WlBufferError::OutOfBounds);
|
||||
}
|
||||
let mem = Rc::new(mem.offset(offset));
|
||||
let min_row_size = width as u64 * shm_info.bpp as u64;
|
||||
let min_row_size = width as u64 * format.bpp as u64;
|
||||
if (stride as u64) < min_row_size {
|
||||
return Err(WlBufferError::StrideTooSmall);
|
||||
}
|
||||
|
|
@ -310,14 +307,15 @@ impl WlBuffer {
|
|||
}
|
||||
}
|
||||
};
|
||||
let hb = match ctx.create_dmabuf_buffer(&udmabuf, *udmabuf_offset, *udmabuf_size) {
|
||||
Ok(hb) => hb,
|
||||
Err(e) => {
|
||||
*host_buffer_impossible = true;
|
||||
log::debug!("Could not create gfx host buffer: {}", ErrorFmt(e));
|
||||
return Ok(None);
|
||||
}
|
||||
};
|
||||
let hb =
|
||||
match ctx.create_dmabuf_buffer(&udmabuf, *udmabuf_offset, *udmabuf_size, self.format) {
|
||||
Ok(hb) => hb,
|
||||
Err(e) => {
|
||||
*host_buffer_impossible = true;
|
||||
log::debug!("Could not create gfx host buffer: {}", ErrorFmt(e));
|
||||
return Ok(None);
|
||||
}
|
||||
};
|
||||
*host_buffer = Some(hb.clone());
|
||||
Ok(Some(hb))
|
||||
}
|
||||
|
|
@ -407,8 +405,6 @@ pub enum WlBufferError {
|
|||
GfxError(#[from] GfxError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Buffer format {0} is not supported for shm buffers")]
|
||||
UnsupportedShmFormat(&'static str),
|
||||
}
|
||||
efrom!(WlBufferError, ClientMemError);
|
||||
efrom!(WlBufferError, ClientError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue