Remove unnecessary last_ prefix in Surface of iced_tiny_skia

This commit is contained in:
Héctor Ramón Jiménez 2023-04-27 15:51:51 +02:00
parent eb1b2bf241
commit a755472ee3
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -15,8 +15,8 @@ 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: Option<Vec<Primitive>>, primitives: Option<Vec<Primitive>>,
last_background_color: Color, background_color: Color,
} }
impl<Theme> crate::graphics::Compositor for Compositor<Theme> { impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
@ -48,8 +48,8 @@ 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: None, primitives: None,
last_background_color: Color::BLACK, background_color: Color::BLACK,
} }
} }
@ -62,7 +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.primitives = None;
} }
fn fetch_information(&self) -> Information { fn fetch_information(&self) -> Information {
@ -121,10 +121,10 @@ pub fn present<T: AsRef<str>>(
.expect("Create pixel map"); .expect("Create pixel map");
let damage = surface let damage = surface
.last_primitives .primitives
.as_deref() .as_deref()
.and_then(|last_primitives| { .and_then(|last_primitives| {
(surface.last_background_color == background_color) (surface.background_color == background_color)
.then(|| damage::list(last_primitives, primitives)) .then(|| damage::list(last_primitives, primitives))
}) })
.unwrap_or_else(|| vec![Rectangle::with_size(viewport.logical_size())]); .unwrap_or_else(|| vec![Rectangle::with_size(viewport.logical_size())]);
@ -133,8 +133,8 @@ pub fn present<T: AsRef<str>>(
return Ok(()); return Ok(());
} }
surface.last_primitives = Some(primitives.to_vec()); surface.primitives = Some(primitives.to_vec());
surface.last_background_color = background_color; surface.background_color = background_color;
let damage = damage::group(damage, scale_factor, physical_size); let damage = damage::group(damage, scale_factor, physical_size);