1
0
Fork 0
forked from wry/wry

gfx: implement async shm downloads

This commit is contained in:
Julian Orth 2024-10-06 15:11:00 +02:00
parent aca14d48dd
commit 028d0ed44c
11 changed files with 194 additions and 198 deletions

View file

@ -1,7 +1,11 @@
use {
crate::{
format::Format,
gfx_api::{AcquireSync, GfxApiOpt, GfxError, GfxFramebuffer, ReleaseSync, SyncFile},
gfx_api::{
AcquireSync, AsyncShmGfxTextureCallback, GfxApiOpt, GfxError, GfxFramebuffer,
GfxInternalFramebuffer, GfxStagingBuffer, PendingShmTransfer, ReleaseSync, ShmMemory,
SyncFile,
},
gfx_apis::gl::{
gl::{
frame_buffer::GlFrameBuffer,
@ -13,6 +17,7 @@ use {
sys::{GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
RenderError,
},
rect::Region,
theme::Color,
},
std::{
@ -104,11 +109,31 @@ impl GfxFramebuffer for Framebuffer {
self.render(acquire_sync, ops, clear).map_err(|e| e.into())
}
fn copy_to_shm(self: Rc<Self>, shm: &[Cell<u8>]) -> Result<(), GfxError> {
(*self).copy_to_shm(shm).map_err(|e| e.into())
}
fn format(&self) -> &'static Format {
self.gl.rb.format
}
}
impl GfxInternalFramebuffer for Framebuffer {
fn into_fb(self: Rc<Self>) -> Rc<dyn GfxFramebuffer> {
self
}
fn staging_size(&self) -> usize {
0
}
fn download(
self: Rc<Self>,
_staging: &Rc<dyn GfxStagingBuffer>,
_callback: Rc<dyn AsyncShmGfxTextureCallback>,
mem: Rc<dyn ShmMemory>,
_damage: Region,
) -> Result<Option<PendingShmTransfer>, GfxError> {
let mut res = Ok(());
mem.access(&mut |mem| res = self.copy_to_shm(mem))
.map_err(RenderError::AccessFailed)?;
res?;
Ok(None)
}
}