Invalidate last_primitives on resize in iced_tiny_skia
This commit is contained in:
parent
38f82ab35f
commit
eb1b2bf241
1 changed files with 12 additions and 10 deletions
|
|
@ -15,7 +15,7 @@ pub struct Surface {
|
||||||
window: softbuffer::GraphicsContext,
|
window: softbuffer::GraphicsContext,
|
||||||
buffer: Vec<u32>,
|
buffer: Vec<u32>,
|
||||||
clip_mask: tiny_skia::Mask,
|
clip_mask: tiny_skia::Mask,
|
||||||
last_primitives: Vec<Primitive>,
|
last_primitives: Option<Vec<Primitive>>,
|
||||||
last_background_color: Color,
|
last_background_color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
|
||||||
buffer: vec![0; width as usize * height as usize],
|
buffer: vec![0; width as usize * height as usize],
|
||||||
clip_mask: tiny_skia::Mask::new(width, height)
|
clip_mask: tiny_skia::Mask::new(width, height)
|
||||||
.expect("Create clip mask"),
|
.expect("Create clip mask"),
|
||||||
last_primitives: Vec::new(),
|
last_primitives: None,
|
||||||
last_background_color: Color::BLACK,
|
last_background_color: Color::BLACK,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -62,8 +62,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
|
||||||
surface.buffer.resize((width * height) as usize, 0);
|
surface.buffer.resize((width * height) as usize, 0);
|
||||||
surface.clip_mask =
|
surface.clip_mask =
|
||||||
tiny_skia::Mask::new(width, height).expect("Create clip mask");
|
tiny_skia::Mask::new(width, height).expect("Create clip mask");
|
||||||
|
surface.last_primitives = None;
|
||||||
surface.last_primitives.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_information(&self) -> Information {
|
fn fetch_information(&self) -> Information {
|
||||||
|
|
@ -121,17 +120,20 @@ pub fn present<T: AsRef<str>>(
|
||||||
)
|
)
|
||||||
.expect("Create pixel map");
|
.expect("Create pixel map");
|
||||||
|
|
||||||
let damage = if surface.last_background_color == background_color {
|
let damage = surface
|
||||||
damage::list(&surface.last_primitives, primitives)
|
.last_primitives
|
||||||
} else {
|
.as_deref()
|
||||||
vec![Rectangle::with_size(viewport.logical_size())]
|
.and_then(|last_primitives| {
|
||||||
};
|
(surface.last_background_color == background_color)
|
||||||
|
.then(|| damage::list(last_primitives, primitives))
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| vec![Rectangle::with_size(viewport.logical_size())]);
|
||||||
|
|
||||||
if damage.is_empty() {
|
if damage.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
surface.last_primitives = primitives.to_vec();
|
surface.last_primitives = Some(primitives.to_vec());
|
||||||
surface.last_background_color = background_color;
|
surface.last_background_color = background_color;
|
||||||
|
|
||||||
let damage = damage::group(damage, scale_factor, physical_size);
|
let damage = damage::group(damage, scale_factor, physical_size);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue