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:
parent
a81f0a2459
commit
50026c5e49
1 changed files with 13 additions and 3 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue