Skip to content

Commit

Permalink
Prevent ImageBundles from causing constant layout recalculations (#1299)
Browse files Browse the repository at this point in the history
Prevent ImageBundles from causing constant layout recalculations
  • Loading branch information
Davier authored Jan 25, 2021
1 parent 32acbfb commit 5edf2d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/bevy_ui/src/widget/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ pub fn image_node_system(
.and_then(|material| material.texture.as_ref())
.and_then(|texture_handle| textures.get(texture_handle))
{
calculated_size.size = Size {
let size = Size {
width: texture.size.width as f32,
height: texture.size.height as f32,
};
// Update only if size has changed to avoid needless layout calculations
if size != calculated_size.size {
calculated_size.size = size;
}
}
}
}

0 comments on commit 5edf2d2

Please sign in to comment.