1
0
Fork 0
forked from wry/wry

gfx: remove GfxFramebuffer::take_render_ops

This commit is contained in:
Julian Orth 2024-09-09 20:52:00 +02:00
parent 02cfdc4be1
commit 5d5843df9a
8 changed files with 26 additions and 50 deletions

View file

@ -4,8 +4,8 @@ use {
cpu_worker::CpuWorker,
format::{Format, XRGB8888},
gfx_api::{
AsyncShmGfxTexture, BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat,
GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture,
AsyncShmGfxTexture, BufferResvUser, GfxContext, GfxError, GfxFormat, GfxFramebuffer,
GfxImage, ResetStatus, ShmGfxTexture,
},
gfx_apis::gl::{
egl::{context::EglContext, display::EglDisplay, image::EglImage},
@ -84,7 +84,6 @@ pub(in crate::gfx_apis::gl) struct GlRenderContext {
pub(crate) fill_prog_pos: GLint,
pub(crate) fill_prog_color: GLint,
pub(crate) gfx_ops: RefCell<Vec<GfxApiOpt>>,
pub(in crate::gfx_apis::gl) gl_state: RefCell<GfxGlState>,
pub(in crate::gfx_apis::gl) buffer_resv_user: BufferResvUser,
@ -169,7 +168,6 @@ impl GlRenderContext {
fill_prog_color: fill_prog.get_uniform_location(c"color"),
fill_prog,
gfx_ops: Default::default(),
gl_state: Default::default(),
buffer_resv_user: Default::default(),

View file

@ -17,7 +17,6 @@ use {
std::{
cell::Cell,
fmt::{Debug, Formatter},
mem,
rc::Rc,
},
};
@ -70,11 +69,11 @@ impl Framebuffer {
pub fn render(
&self,
mut ops: Vec<GfxApiOpt>,
ops: &[GfxApiOpt],
clear: Option<&Color>,
) -> Result<Option<SyncFile>, RenderError> {
let gles = self.ctx.ctx.dpy.gles;
let res = self.ctx.ctx.with_current(|| {
self.ctx.ctx.with_current(|| {
unsafe {
(gles.glBindFramebuffer)(GL_FRAMEBUFFER, self.gl.fbo);
(gles.glViewport)(0, 0, self.gl.width, self.gl.height);
@ -84,32 +83,25 @@ impl Framebuffer {
}
(gles.glBlendFunc)(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
let fd = run_ops(self, &ops);
let fd = run_ops(self, ops);
if fd.is_none() {
unsafe {
(gles.glFlush)();
}
}
Ok(fd)
});
ops.clear();
*self.ctx.gfx_ops.borrow_mut() = ops;
res
})
}
}
impl GfxFramebuffer for Framebuffer {
fn take_render_ops(&self) -> Vec<GfxApiOpt> {
mem::take(&mut *self.ctx.gfx_ops.borrow_mut())
}
fn physical_size(&self) -> (i32, i32) {
(self.gl.width, self.gl.height)
}
fn render(
&self,
ops: Vec<GfxApiOpt>,
ops: &[GfxApiOpt],
clear: Option<&Color>,
) -> Result<Option<SyncFile>, GfxError> {
self.render(ops, clear).map_err(|e| e.into())