mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 11:29:25 +00:00
Don't draw scene elements if their size is zero
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
e7d0bf1c36
commit
47b40e3839
1 changed files with 21 additions and 6 deletions
|
@ -279,7 +279,9 @@ impl Layer {
|
|||
}
|
||||
|
||||
fn push_quad(&mut self, quad: Quad) {
|
||||
self.quads.push(quad);
|
||||
if can_draw(quad.bounds) {
|
||||
self.quads.push(quad);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn quads(&self) -> &[Quad] {
|
||||
|
@ -287,7 +289,9 @@ impl Layer {
|
|||
}
|
||||
|
||||
fn push_underline(&mut self, underline: Underline) {
|
||||
self.underlines.push(underline);
|
||||
if underline.width > 0. {
|
||||
self.underlines.push(underline);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn underlines(&self) -> &[Underline] {
|
||||
|
@ -295,7 +299,9 @@ impl Layer {
|
|||
}
|
||||
|
||||
fn push_image(&mut self, image: Image) {
|
||||
self.images.push(image);
|
||||
if can_draw(image.bounds) {
|
||||
self.images.push(image);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn images(&self) -> &[Image] {
|
||||
|
@ -303,7 +309,9 @@ impl Layer {
|
|||
}
|
||||
|
||||
fn push_shadow(&mut self, shadow: Shadow) {
|
||||
self.shadows.push(shadow);
|
||||
if can_draw(shadow.bounds) {
|
||||
self.shadows.push(shadow);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn shadows(&self) -> &[Shadow] {
|
||||
|
@ -319,7 +327,9 @@ impl Layer {
|
|||
}
|
||||
|
||||
pub fn push_icon(&mut self, icon: Icon) {
|
||||
self.icons.push(icon);
|
||||
if can_draw(icon.bounds) {
|
||||
self.icons.push(icon);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn icons(&self) -> &[Icon] {
|
||||
|
@ -327,7 +337,7 @@ impl Layer {
|
|||
}
|
||||
|
||||
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.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue