Resize base layer in Stack before drawing
This commit is contained in:
parent
46167c78c7
commit
d2f36a0a58
7 changed files with 14 additions and 13 deletions
|
|
@ -60,8 +60,8 @@ pub trait Renderer {
|
|||
/// Fills a [`Quad`] with the provided [`Background`].
|
||||
fn fill_quad(&mut self, quad: Quad, background: impl Into<Background>);
|
||||
|
||||
/// Clears all of the recorded primitives in the [`Renderer`].
|
||||
fn clear(&mut self);
|
||||
/// Resets the [`Renderer`] to start drawing in the `new_bounds` from scratch.
|
||||
fn reset(&mut self, new_bounds: Rectangle);
|
||||
}
|
||||
|
||||
/// A polygon with four sides.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ impl Renderer for () {
|
|||
|
||||
fn end_transformation(&mut self) {}
|
||||
|
||||
fn clear(&mut self) {}
|
||||
fn reset(&mut self, _new_bounds: Rectangle) {}
|
||||
|
||||
fn fill_quad(
|
||||
&mut self,
|
||||
|
|
|
|||
|
|
@ -158,12 +158,15 @@ impl<T: Layer> Stack<T> {
|
|||
|
||||
/// Clears the layers of the [`Stack`], allowing reuse.
|
||||
///
|
||||
/// It resizes the base layer bounds to the `new_bounds`.
|
||||
///
|
||||
/// This will normally keep layer allocations for future drawing operations.
|
||||
pub fn clear(&mut self) {
|
||||
pub fn reset(&mut self, new_bounds: Rectangle) {
|
||||
for layer in self.layers[..self.active_count].iter_mut() {
|
||||
layer.reset();
|
||||
}
|
||||
|
||||
self.layers[0].resize(new_bounds);
|
||||
self.current = 0;
|
||||
self.active_count = 1;
|
||||
self.previous.clear();
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ where
|
|||
delegate!(self, renderer, renderer.fill_quad(quad, background.into()));
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
delegate!(self, renderer, renderer.clear());
|
||||
fn reset(&mut self, new_bounds: Rectangle) {
|
||||
delegate!(self, renderer, renderer.reset(new_bounds));
|
||||
}
|
||||
|
||||
fn start_layer(&mut self, bounds: Rectangle) {
|
||||
|
|
|
|||
|
|
@ -482,10 +482,8 @@ where
|
|||
style: &renderer::Style,
|
||||
cursor: mouse::Cursor,
|
||||
) {
|
||||
// TODO: Move to shell level (?)
|
||||
renderer.clear();
|
||||
|
||||
let viewport = Rectangle::with_size(self.bounds);
|
||||
renderer.reset(viewport);
|
||||
|
||||
let base_cursor = match &self.overlay {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -225,8 +225,8 @@ impl core::Renderer for Renderer {
|
|||
layer.draw_quad(quad, background.into(), transformation);
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.layers.clear();
|
||||
fn reset(&mut self, new_bounds: Rectangle) {
|
||||
self.layers.reset(new_bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -648,8 +648,8 @@ impl core::Renderer for Renderer {
|
|||
layer.draw_quad(quad, background.into(), transformation);
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.layers.clear();
|
||||
fn reset(&mut self, new_bounds: Rectangle) {
|
||||
self.layers.reset(new_bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue