calculate clipping bounds only if arrangement has changed
the change forces ui to update clipping bounds only if  arrangement of the root node has changed, it frees cpu clocks if the ui remains static
@@ -781,7 +781,7 @@ impl UserInterface {
self.handle_layout_events();
self.measure_node(self.root_canvas, screen_size);
- self.arrange_node(
+ let arrangement_changed = self.arrange_node(
self.root_canvas,
&Rect::new(0.0, 0.0, screen_size.x, screen_size.y),
);
@@ -791,6 +791,13 @@ impl UserInterface {
self.need_update_global_transform = false;
}
+ if arrangement_changed {
+ self.calculate_clip_bounds(
+ self.root_canvas,
+ Rect::new(0.0, 0.0, self.screen_size.x, self.screen_size.y),
+ );
+ }
+
let sender = self.sender.clone();
for node in self.nodes.iter_mut() {
node.update(dt, &sender)
@@ -821,10 +828,6 @@ impl UserInterface {
pub fn draw(&mut self) -> &DrawingContext {
scope_profile!();
- self.calculate_clip_bounds(
- self.root_canvas,
- Rect::new(0.0, 0.0, self.screen_size.x, self.screen_size.y),
- );
self.drawing_context.clear();
for node in self.nodes.iter_mut() {
