Track image damage in iced_tiny_skia

This commit is contained in:
Héctor Ramón Jiménez 2024-04-10 19:55:27 +02:00
parent 32cd456fb9
commit fdd9896dc5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 20 additions and 1 deletions

View file

@ -7,7 +7,7 @@ use crate::core::svg;
use crate::core::{Color, Rectangle};
/// A raster or vector image.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub enum Image {
/// A raster image.
Raster {
@ -33,6 +33,17 @@ pub enum Image {
},
}
impl Image {
/// Returns the bounds of the [`Image`].
pub fn bounds(&self) -> Rectangle {
match self {
Image::Raster { bounds, .. } | Image::Vector { bounds, .. } => {
*bounds
}
}
}
}
#[cfg(feature = "image")]
/// Tries to load an image by its [`Handle`].
///

View file

@ -241,8 +241,16 @@ impl Layer {
},
);
let images = damage::list(
&previous.images,
&current.images,
|image| vec![image.bounds().expand(1.0)],
Image::eq,
);
damage.extend(text);
damage.extend(primitives);
damage.extend(images);
damage
}
}