1
0
Fork 0
forked from wry/wry

wl-buffer: remove unnecessary Result wrapper

This commit is contained in:
Julian Orth 2025-10-02 14:55:08 +02:00
parent 1883b42d21
commit da33f26918
2 changed files with 12 additions and 22 deletions

View file

@ -274,7 +274,7 @@ impl WlBuffer {
ctx: &Rc<dyn GfxContext>, ctx: &Rc<dyn GfxContext>,
mem: &Rc<ClientMemOffset>, mem: &Rc<ClientMemOffset>,
dmabuf_buffer_params: &mut DmabufBufferParams, dmabuf_buffer_params: &mut DmabufBufferParams,
) -> Result<Option<Rc<dyn GfxBuffer>>, GfxError> { ) -> Option<Rc<dyn GfxBuffer>> {
let DmabufBufferParams { let DmabufBufferParams {
size, size,
udmabuf, udmabuf,
@ -285,20 +285,20 @@ impl WlBuffer {
host_buffer_impossible, host_buffer_impossible,
} = dmabuf_buffer_params; } = dmabuf_buffer_params;
if let Some(hb) = host_buffer { if let Some(hb) = host_buffer {
return Ok(Some(hb.clone())); return Some(hb.clone());
} }
if *host_buffer_impossible { if *host_buffer_impossible {
return Ok(None); return None;
} }
let udmabuf = 'udmabuf: { let udmabuf = 'udmabuf: {
if let Some(b) = udmabuf { if let Some(b) = udmabuf {
break 'udmabuf b.clone(); break 'udmabuf b.clone();
} }
if *udmabuf_impossible { if *udmabuf_impossible {
return Ok(None); return None;
} }
let Some(dev) = self.client.state.udmabuf.get() else { let Some(dev) = self.client.state.udmabuf.get() else {
return Ok(None); return None;
}; };
let mask = page_size() - 1; let mask = page_size() - 1;
let offset = mem.offset() & mask; let offset = mem.offset() & mask;
@ -316,7 +316,7 @@ impl WlBuffer {
Err(e) => { Err(e) => {
*udmabuf_impossible = true; *udmabuf_impossible = true;
log::debug!("Could not create udmabuf: {}", ErrorFmt(e)); log::debug!("Could not create udmabuf: {}", ErrorFmt(e));
return Ok(None); return None;
} }
} }
}; };
@ -326,11 +326,11 @@ impl WlBuffer {
Err(e) => { Err(e) => {
*host_buffer_impossible = true; *host_buffer_impossible = true;
log::debug!("Could not create gfx host buffer: {}", ErrorFmt(e)); log::debug!("Could not create gfx host buffer: {}", ErrorFmt(e));
return Ok(None); return None;
} }
}; };
*host_buffer = Some(hb.clone()); *host_buffer = Some(hb.clone());
Ok(Some(hb)) Some(hb)
} }
fn update_texture(&self, surface: &WlSurface, sync_shm: bool) -> Result<(), WlBufferError> { fn update_texture(&self, surface: &WlSurface, sync_shm: bool) -> Result<(), WlBufferError> {

View file

@ -14,7 +14,6 @@ use {
utils::{ utils::{
clonecell::CloneCell, clonecell::CloneCell,
copyhashmap::CopyHashMap, copyhashmap::CopyHashMap,
errorfmt::ErrorFmt,
hash_map_ext::HashMapExt, hash_map_ext::HashMapExt,
linkedlist::{LinkedList, LinkedNode, NodeRef}, linkedlist::{LinkedList, LinkedNode, NodeRef},
numcell::NumCell, numcell::NumCell,
@ -649,19 +648,10 @@ fn schedule_async_upload(
back_tex back_tex
} }
}; };
match buf.get_gfx_buffer(&ctx, mem, dmabuf_buffer_params) { if let Some(hb) = buf.get_gfx_buffer(&ctx, mem, dmabuf_buffer_params) {
Ok(Some(hb)) => { return back_tex
return back_tex .async_upload_from_buffer(&hb, node_ref.clone(), back.damage.get())
.async_upload_from_buffer(&hb, node_ref.clone(), back.damage.get()) .map_err(WlSurfaceError::PrepareAsyncUpload);
.map_err(WlSurfaceError::PrepareAsyncUpload);
}
Ok(None) => {}
Err(e) => {
log::error!(
"Could not create GPU mapping of host buffer: {}",
ErrorFmt(e),
);
}
} }
let mut staging_opt = surface.shm_staging.get(); let mut staging_opt = surface.shm_staging.get();
if let Some(staging) = &staging_opt if let Some(staging) = &staging_opt