render: remove clear OP
This commit is contained in:
parent
e0ed29038e
commit
1500b10de3
4 changed files with 18 additions and 38 deletions
|
|
@ -25,7 +25,6 @@ use {
|
|||
|
||||
pub enum GfxApiOpt {
|
||||
Sync,
|
||||
Clear(Clear),
|
||||
FillRect(FillRect),
|
||||
CopyTexture(CopyTexture),
|
||||
}
|
||||
|
|
@ -87,10 +86,6 @@ pub struct AbsoluteRect {
|
|||
pub y2: f32,
|
||||
}
|
||||
|
||||
pub struct Clear {
|
||||
pub color: Color,
|
||||
}
|
||||
|
||||
pub struct FillRect {
|
||||
pub rect: AbsoluteRect,
|
||||
pub color: Color,
|
||||
|
|
@ -175,7 +170,12 @@ impl dyn GfxFramebuffer {
|
|||
self.render(ops, clear);
|
||||
}
|
||||
|
||||
pub fn render_custom(&self, scale: Scale, f: &mut dyn FnMut(&mut RendererBase)) {
|
||||
pub fn render_custom(
|
||||
&self,
|
||||
scale: Scale,
|
||||
clear: Option<&Color>,
|
||||
f: &mut dyn FnMut(&mut RendererBase),
|
||||
) {
|
||||
let mut ops = self.take_render_ops();
|
||||
let mut renderer = RendererBase {
|
||||
ops: &mut ops,
|
||||
|
|
@ -184,7 +184,7 @@ impl dyn GfxFramebuffer {
|
|||
scalef: scale.to_f64(),
|
||||
};
|
||||
f(&mut renderer);
|
||||
self.render(ops, None);
|
||||
self.render(ops, clear);
|
||||
}
|
||||
|
||||
pub fn render_node(
|
||||
|
|
|
|||
|
|
@ -28,11 +28,10 @@ use {
|
|||
gl::texture::image_target,
|
||||
renderer::{context::GlRenderContext, framebuffer::Framebuffer, texture::Texture},
|
||||
sys::{
|
||||
glActiveTexture, glBindTexture, glClear, glClearColor, glDisable,
|
||||
glDisableVertexAttribArray, glDrawArrays, glEnable, glEnableVertexAttribArray,
|
||||
glTexParameteri, glUniform1i, glUniform4f, glUseProgram, glVertexAttribPointer,
|
||||
GL_BLEND, GL_COLOR_BUFFER_BIT, GL_FALSE, GL_FLOAT, GL_LINEAR, GL_TEXTURE0,
|
||||
GL_TEXTURE_MIN_FILTER, GL_TRIANGLES, GL_TRIANGLE_STRIP,
|
||||
glActiveTexture, glBindTexture, glDisable, glDisableVertexAttribArray,
|
||||
glDrawArrays, glEnable, glEnableVertexAttribArray, glTexParameteri, glUniform1i,
|
||||
glUniform4f, glUseProgram, glVertexAttribPointer, GL_BLEND, GL_FALSE, GL_FLOAT,
|
||||
GL_LINEAR, GL_TEXTURE0, GL_TEXTURE_MIN_FILTER, GL_TRIANGLES, GL_TRIANGLE_STRIP,
|
||||
},
|
||||
},
|
||||
theme::Color,
|
||||
|
|
@ -164,13 +163,6 @@ fn run_ops(fb: &Framebuffer, ops: &[GfxApiOpt]) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
GfxApiOpt::Clear(c) => {
|
||||
if has_ops!() {
|
||||
break;
|
||||
}
|
||||
clear(&c.color);
|
||||
i += 1;
|
||||
}
|
||||
GfxApiOpt::FillRect(f) => {
|
||||
fill_rect.push(f);
|
||||
i += 1;
|
||||
|
|
@ -234,13 +226,6 @@ fn run_ops(fb: &Framebuffer, ops: &[GfxApiOpt]) {
|
|||
}
|
||||
}
|
||||
|
||||
fn clear(c: &Color) {
|
||||
unsafe {
|
||||
glClearColor(c.r, c.g, c.b, c.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
fn fill_boxes3(ctx: &GlRenderContext, boxes: &[f32], color: &Color) {
|
||||
unsafe {
|
||||
glUseProgram(ctx.fill_prog.prog);
|
||||
|
|
|
|||
|
|
@ -638,12 +638,12 @@ impl WindowData {
|
|||
self.have_frame.set(false);
|
||||
buf.free.set(false);
|
||||
|
||||
buf.fb.render_custom(self.scale.get(), &mut |r| {
|
||||
r.clear(&Color::from_gray(0));
|
||||
if let Some(content) = self.content.get() {
|
||||
content.render_at(r, 0.0, 0.0)
|
||||
}
|
||||
});
|
||||
buf.fb
|
||||
.render_custom(self.scale.get(), Some(&Color::from_gray(0)), &mut |r| {
|
||||
if let Some(content) = self.content.get() {
|
||||
content.render_at(r, 0.0, 0.0)
|
||||
}
|
||||
});
|
||||
|
||||
self.surface.attach(&buf.wl);
|
||||
self.surface.commit();
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ use {
|
|||
crate::{
|
||||
format::Format,
|
||||
gfx_api::{
|
||||
AbsoluteRect, BufferPoint, BufferPoints, Clear, CopyTexture, FillRect, GfxApiOpt,
|
||||
GfxTexture,
|
||||
AbsoluteRect, BufferPoint, BufferPoints, CopyTexture, FillRect, GfxApiOpt, GfxTexture,
|
||||
},
|
||||
rect::Rect,
|
||||
scale::Scale,
|
||||
|
|
@ -62,10 +61,6 @@ impl RendererBase<'_> {
|
|||
rect
|
||||
}
|
||||
|
||||
pub fn clear(&mut self, c: &Color) {
|
||||
self.ops.push(GfxApiOpt::Clear(Clear { color: *c }))
|
||||
}
|
||||
|
||||
pub fn fill_boxes(&mut self, boxes: &[Rect], color: &Color) {
|
||||
self.fill_boxes2(boxes, color, 0, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue