Expand damage regions of Clip primitives a bit

This commit is contained in:
Héctor Ramón Jiménez 2023-04-27 15:25:59 +02:00
parent 200a29c069
commit 38f82ab35f
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 5 additions and 3 deletions

View file

@ -17,19 +17,21 @@ pub fn regions(a: &Primitive, b: &Primitive) -> Vec<Rectangle> {
Primitive::Clip {
bounds: bounds_a,
content: content_a,
..
},
Primitive::Clip {
bounds: bounds_b,
content: content_b,
..
},
) => {
if bounds_a == bounds_b {
return regions(content_a, content_b)
.into_iter()
.filter_map(|r| r.intersection(bounds_a))
.filter_map(|r| r.intersection(&bounds_a.expand(1.0)))
.collect();
} else {
return vec![*bounds_a, *bounds_b];
return vec![bounds_a.expand(1.0), bounds_b.expand(1.0)];
}
}
(

View file

@ -179,7 +179,7 @@ impl Primitive {
Self::Quad { bounds, .. }
| Self::Image { bounds, .. }
| Self::Svg { bounds, .. } => bounds.expand(1.0),
Self::Clip { bounds, .. } => *bounds,
Self::Clip { bounds, .. } => bounds.expand(1.0),
Self::SolidMesh { size, .. } | Self::GradientMesh { size, .. } => {
Rectangle::with_size(*size)
}