Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent ImageBundles from causing constant layout recalculations #1299

Merged
merged 2 commits into from
Jan 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its probably a good idea to leave a comment here about why we're doing this check. People with less context might look at this and say "this check isn't needed".

calculated_size.size = size;
}
}
}
}