renderer: Allow clear calls on specific regions
This commit is contained in:
parent
55ec6dc7cb
commit
57f45d9941
|
@ -31,6 +31,7 @@
|
|||
- `X11Surface::buffer` now additionally returns the age of the buffer
|
||||
- `X11Surface` now has an explicit `submit` function
|
||||
- `X11Surface` is now multi-window capable.
|
||||
- `Renderer::clear` now expects a second argument to optionally only clear parts of the buffer/surface
|
||||
|
||||
### Additions
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn render_layers_and_windows(
|
|||
output_scale: f32,
|
||||
logger: &Logger,
|
||||
) -> Result<(), SwapBuffersError> {
|
||||
frame.clear([0.8, 0.8, 0.9, 1.0])?;
|
||||
frame.clear([0.8, 0.8, 0.9, 1.0], None)?;
|
||||
|
||||
for layer in [Layer::Background, Layer::Bottom] {
|
||||
draw_layers(
|
||||
|
|
|
@ -873,7 +873,7 @@ fn initial_render(surface: &mut RenderSurface, renderer: &mut Gles2Renderer) ->
|
|||
renderer
|
||||
.render((1, 1).into(), Transform::Normal, |_, frame| {
|
||||
frame
|
||||
.clear([0.8, 0.8, 0.9, 1.0])
|
||||
.clear([0.8, 0.8, 0.9, 1.0], None)
|
||||
.map_err(Into::<SwapBuffersError>::into)
|
||||
})
|
||||
.map_err(Into::<SwapBuffersError>::into)
|
||||
|
|
|
@ -1121,10 +1121,17 @@ impl Frame for Gles2Frame {
|
|||
type Error = Gles2Error;
|
||||
type TextureId = Gles2Texture;
|
||||
|
||||
fn clear(&mut self, color: [f32; 4]) -> Result<(), Self::Error> {
|
||||
fn clear(&mut self, color: [f32; 4], at: Option<Rectangle<i32, Physical>>) -> Result<(), Self::Error> {
|
||||
unsafe {
|
||||
if let Some(rect) = at {
|
||||
self.gl.Enable(ffi::SCISSOR_TEST);
|
||||
self.gl.Scissor(rect.loc.x, rect.loc.y, rect.size.w, rect.size.h);
|
||||
}
|
||||
self.gl.ClearColor(color[0], color[1], color[2], color[3]);
|
||||
self.gl.Clear(ffi::COLOR_BUFFER_BIT);
|
||||
if at.is_some() {
|
||||
self.gl.Disable(ffi::SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -171,7 +171,7 @@ pub trait Frame {
|
|||
///
|
||||
/// This operation is only valid in between a `begin` and `finish`-call.
|
||||
/// If called outside this operation may error-out, do nothing or modify future rendering results in any way.
|
||||
fn clear(&mut self, color: [f32; 4]) -> Result<(), Self::Error>;
|
||||
fn clear(&mut self, color: [f32; 4], at: Option<Rectangle<i32, Physical>>) -> Result<(), Self::Error>;
|
||||
|
||||
/// Render a texture to the current target as a flat 2d-plane at a given
|
||||
/// position and applying the given transformation with the given alpha value.
|
||||
|
|
Loading…
Reference in New Issue