1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Minimal test for render stats - static UI with animation.
//! Tests layout skipping, paint caching, and flatten caching during animation frames.
//!
//! Run with:
//! ```bash
//! cargo run --example render_stats_test --features render-stats
//! ```
//!
//! The rotating container triggers continuous rendering,
//! but the static children should have their layouts skipped and paint cached.
use guido::prelude::*;
#[tokio::main]
async fn main() {
App::new().run(|app| {
// Signal to drive rotation animation
let rotation = create_signal(0.0f32);
// Continuously update rotation to force frame rendering
let rotation_w = rotation.writer();
create_task(move |ctx| async move {
while ctx.is_running() {
rotation_w.update(|r| *r += 1.0);
tokio::time::sleep(std::time::Duration::from_millis(16)).await; // ~60fps
}
});
let view = container()
.width(400.0)
.height(200.0)
.padding(16.0)
.background(Color::rgb(0.1, 0.1, 0.15))
.layout(Flex::column().spacing(8.0))
// Animated container (will re-layout due to transform animation)
.child(
container()
.padding(8.0)
.background(Color::rgb(0.2, 0.2, 0.3))
.rotate(move || rotation.get())
.child(text("Rotating").color(Color::WHITE)),
)
// Static containers (should have layout skipped after first frame)
.child(
container()
.padding(8.0)
.background(Color::rgb(0.2, 0.3, 0.2))
.child(text("Static text 1").color(Color::WHITE)),
)
.child(
container()
.padding(8.0)
.background(Color::rgb(0.3, 0.2, 0.2))
.child(text("Static text 2").color(Color::WHITE)),
);
app.add_surface(
SurfaceConfig::new()
.width(400)
.height(200)
.anchor(Anchor::TOP | Anchor::LEFT)
.layer(Layer::Top)
.namespace("render-stats-test")
.background_color(Color::rgb(0.08, 0.08, 0.12)),
move || view,
);
});
}