Replace Primitive::Translate with Transform

This commit is contained in:
Héctor Ramón Jiménez 2023-10-23 03:13:28 +02:00
parent 759f0e9225
commit 5467c19c80
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
11 changed files with 205 additions and 133 deletions

View file

@ -102,10 +102,10 @@ impl<T: Damage> Damage for Primitive<T> {
.fold(Rectangle::with_size(Size::ZERO), |a, b| {
Rectangle::union(&a, &b)
}),
Self::Translate {
translation,
Self::Transform {
transformation,
content,
} => content.bounds() + *translation,
} => content.bounds() * *transformation,
Self::Cache { content } => content.bounds(),
Self::Custom(custom) => custom.bounds(),
}
@ -144,19 +144,19 @@ fn regions<T: Damage>(a: &Primitive<T>, b: &Primitive<T>) -> Vec<Rectangle> {
}
}
(
Primitive::Translate {
translation: translation_a,
Primitive::Transform {
transformation: transformation_a,
content: content_a,
},
Primitive::Translate {
translation: translation_b,
Primitive::Transform {
transformation: transformation_b,
content: content_b,
},
) => {
if translation_a == translation_b {
if transformation_a == transformation_b {
return regions(content_a, content_b)
.into_iter()
.map(|r| r + *translation_a)
.map(|r| r * *transformation_a)
.collect();
}
}