Merge pull request #602 from zed-industries/fix-atlas-panic

Don't draw scene elements if their size is zero
This commit is contained in:
Antonio Scandurra 2022-03-14 15:38:42 +01:00 committed by GitHub
commit e62781a57b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -279,32 +279,40 @@ impl Layer {
}
fn push_quad(&mut self, quad: Quad) {
if can_draw(quad.bounds) {
self.quads.push(quad);
}
}
pub fn quads(&self) -> &[Quad] {
self.quads.as_slice()
}
fn push_underline(&mut self, underline: Underline) {
if underline.width > 0. {
self.underlines.push(underline);
}
}
pub fn underlines(&self) -> &[Underline] {
self.underlines.as_slice()
}
fn push_image(&mut self, image: Image) {
if can_draw(image.bounds) {
self.images.push(image);
}
}
pub fn images(&self) -> &[Image] {
self.images.as_slice()
}
fn push_shadow(&mut self, shadow: Shadow) {
if can_draw(shadow.bounds) {
self.shadows.push(shadow);
}
}
pub fn shadows(&self) -> &[Shadow] {
self.shadows.as_slice()
@ -319,15 +327,17 @@ impl Layer {
}
pub fn push_icon(&mut self, icon: Icon) {
if can_draw(icon.bounds) {
self.icons.push(icon);
}
}
pub fn icons(&self) -> &[Icon] {
self.icons.as_slice()
}
fn push_path(&mut self, path: Path) {
if !path.bounds.is_empty() {
if can_draw(path.bounds) {
self.paths.push(path);
}
}
@ -429,3 +439,8 @@ impl ToJson for Border {
value
}
}
fn can_draw(bounds: RectF) -> bool {
let size = bounds.size();
size.x() > 0. && size.y() > 0.
}