Fix error on chromium like browser when canvas initial size (0,0)

Co-authored-by: EleDiaz <elediaz@users.noreply.github.com>
This commit is contained in:
Eleazar Díaz Delgado 2025-03-06 12:48:37 +00:00 • committed by Héctor Ramón Jiménez
parent a81f0a2459
commit 50026c5e49
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -66,16 +66,26 @@ impl crate::graphics::Compositor for Compositor {
) )
.expect("Create softbuffer surface for window"); .expect("Create softbuffer surface for window");
let clip_mask = {
if width > 0 && height > 0 {
tiny_skia::Mask::new(width, height)
} else {
tiny_skia::Mask::new(1, 1)
}
}
.expect("Create clip mask");
let mut surface = Surface { let mut surface = Surface {
window, window,
clip_mask: tiny_skia::Mask::new(width, height) clip_mask,
.expect("Create clip mask"),
layer_stack: VecDeque::new(), layer_stack: VecDeque::new(),
background_color: Color::BLACK, background_color: Color::BLACK,
max_age: 0, max_age: 0,
}; };
self.configure_surface(&mut surface, width, height); if width > 0 && height > 0 {
self.configure_surface(&mut surface, width, height);
}
surface surface
} }