Track image damage in iced_tiny_skia
This commit is contained in:
parent
32cd456fb9
commit
fdd9896dc5
2 changed files with 20 additions and 1 deletions
|
|
@ -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`].
|
||||
///
|
||||
|
|
|
|||
|
|
@ -241,8 +241,16 @@ impl Layer {
|
|||
},
|
||||
);
|
||||
|
||||
let images = damage::list(
|
||||
&previous.images,
|
||||
¤t.images,
|
||||
|image| vec![image.bounds().expand(1.0)],
|
||||
Image::eq,
|
||||
);
|
||||
|
||||
damage.extend(text);
|
||||
damage.extend(primitives);
|
||||
damage.extend(images);
|
||||
damage
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue