Fix scissor panics when window height is 1

This commit is contained in:
João Capucho 2021-06-05 13:56:38 +01:00
parent 7b8a398234
commit a148d4d01a
No known key found for this signature in database
GPG Key ID: 1AD5CE7CCAEBDA21
2 changed files with 11 additions and 4 deletions

View File

@ -708,10 +708,17 @@ impl IcedRenderer {
}
.intersection(self.window_scissor);
if intersection.is_valid() {
if intersection.is_valid() && intersection.size().map(|s| s > 0).reduce_and() {
intersection
} else {
Aabr::new_empty(Vec2::zero())
// Create a aabr with width 1 and height 1, technically
// it would be more correct to do it with 0,0 but that's
// a validation error in wgpu so enjoy your funky pixel
// in the top left of your screen
Aabr {
min: Vec2::zero(),
max: Vec2::one(),
}
}
};
// Not expecting this case: new_scissor == current_scissor

View File

@ -283,7 +283,7 @@ impl Ui {
pub fn handle_event(&mut self, event: Event) {
match event.0 {
Input::Resize(w, h) => {
if w > 1.0 && h > 1.0 {
if w > 0.0 && h > 0.0 {
self.window_resized = Some(Vec2::new(w, h))
}
},
@ -673,7 +673,7 @@ impl Ui {
}
.intersection(window_scissor);
if intersection.is_valid() {
if intersection.is_valid() && intersection.size().map(|s| s > 0).reduce_and() {
intersection
} else {
// TODO: What should we return here