1
0
Fork 0
forked from wry/wry

render: propagate errors

This commit is contained in:
Julian Orth 2024-03-22 13:26:56 +01:00
parent d9fa3f6732
commit 1b4492c670
14 changed files with 169 additions and 105 deletions

View file

@ -10,6 +10,7 @@ use {
renderer::context::GlRenderContext,
run_ops,
sys::{GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
RenderError,
},
theme::Color,
},
@ -64,9 +65,9 @@ impl Framebuffer {
});
}
pub fn render(&self, ops: Vec<GfxApiOpt>, clear: Option<&Color>) {
pub fn render(&self, ops: Vec<GfxApiOpt>, clear: Option<&Color>) -> Result<(), RenderError> {
let gles = self.ctx.ctx.dpy.gles;
let _ = self.ctx.ctx.with_current(|| {
let res = self.ctx.ctx.with_current(|| {
unsafe {
(gles.glBindFramebuffer)(GL_FRAMEBUFFER, self.gl.fbo);
(gles.glViewport)(0, 0, self.gl.width, self.gl.height);
@ -83,6 +84,7 @@ impl Framebuffer {
Ok(())
});
*self.ctx.gfx_ops.borrow_mut() = ops;
res
}
}
@ -101,8 +103,8 @@ impl GfxFramebuffer for Framebuffer {
(self.gl.width, self.gl.height)
}
fn render(&self, ops: Vec<GfxApiOpt>, clear: Option<&Color>) {
self.render(ops, clear);
fn render(&self, ops: Vec<GfxApiOpt>, clear: Option<&Color>) -> Result<(), GfxError> {
self.render(ops, clear).map_err(|e| e.into())
}
fn copy_to_shm(

View file

@ -173,6 +173,8 @@ pub enum VulkanError {
height: i32,
stride: i32,
},
#[error(transparent)]
GfxError(GfxError),
}
impl From<VulkanError> for GfxError {

View file

@ -525,8 +525,10 @@ impl GfxFramebuffer for VulkanImage {
(self.width as _, self.height as _)
}
fn render(&self, ops: Vec<GfxApiOpt>, clear: Option<&Color>) {
self.renderer.execute(self, &ops, clear).unwrap();
fn render(&self, ops: Vec<GfxApiOpt>, clear: Option<&Color>) -> Result<(), GfxError> {
self.renderer
.execute(self, &ops, clear)
.map_err(|e| e.into())
}
fn copy_to_shm(

View file

@ -698,7 +698,9 @@ impl VulkanRenderer {
&[],
true,
)?;
(&*tmp_tex as &dyn GfxFramebuffer).copy_texture(&(tex.clone() as _), x, y);
(&*tmp_tex as &dyn GfxFramebuffer)
.copy_texture(&(tex.clone() as _), x, y)
.map_err(VulkanError::GfxError)?;
self.read_all_pixels(&tmp_tex, stride, dst)
}