Reintroduce damage tracking for iced_tiny_skia

This commit is contained in:
Héctor Ramón Jiménez 2024-04-10 15:21:42 +02:00
parent 14b9708f72
commit 1e802e776c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
10 changed files with 347 additions and 92 deletions

View file

@ -1,3 +1,5 @@
use crate::core::Rectangle;
#[derive(Debug, Clone, PartialEq)]
pub enum Primitive {
/// A path filled with some paint.
@ -19,3 +21,20 @@ pub enum Primitive {
stroke: tiny_skia::Stroke,
},
}
impl Primitive {
/// Returns the visible bounds of the [`Primitive`].
pub fn visible_bounds(&self) -> Rectangle {
let bounds = match self {
Primitive::Fill { path, .. } => path.bounds(),
Primitive::Stroke { path, .. } => path.bounds(),
};
Rectangle {
x: bounds.x(),
y: bounds.y(),
width: bounds.width(),
height: bounds.height(),
}
}
}