-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathloop.go
More file actions
68 lines (57 loc) · 2.19 KB
/
Copy pathloop.go
File metadata and controls
68 lines (57 loc) · 2.19 KB
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
package app
import (
"time"
"github.com/gogpu/ui/widget"
)
// FrameStats holds timing information for a single frame.
//
// This is useful for performance monitoring and debugging.
// FrameStats is passed to the [FrameCallback] after each call to
// [App.Frame] or [Window.Frame].
type FrameStats struct {
// FrameStart is the time when Frame() was called.
FrameStart time.Time
// LayoutDuration is how long the layout pass took.
// Zero if layout was not performed this frame.
LayoutDuration time.Duration
// DrawDuration is how long the draw pass took.
DrawDuration time.Duration
// TotalDuration is the total time spent in Frame().
TotalDuration time.Duration
// LayoutPerformed indicates whether layout was recalculated this frame.
LayoutPerformed bool
// DrawSkipped indicates that the draw pass was skipped because no
// widgets in the tree needed re-rendering. When true, the host
// application can reuse the previous frame's GPU framebuffer output.
//
// This is the primary retained-mode optimization: idle UIs skip
// rendering entirely, consuming zero CPU for the draw phase.
DrawSkipped bool
// DrawStats provides per-widget statistics from the draw traversal.
//
// When DrawSkipped is true, DrawStats is zero-valued (no traversal
// was performed). When DrawSkipped is false, DrawStats shows how many
// widgets were drawn, how many were dirty vs clean, and how many were
// skipped due to invisibility.
//
// This is primarily useful for performance monitoring and for
// validating that the retained-mode dirty-tracking system is
// working correctly.
DrawStats widget.DrawStats
}
// FrameCallback is called after each frame completes with timing statistics.
//
// This is useful for frame time monitoring and adaptive rendering.
// The callback is invoked synchronously at the end of each Frame() call.
type FrameCallback func(stats FrameStats)
// SetFrameCallback sets a callback that is invoked after each Frame call
// with timing statistics.
//
// Set to nil to disable statistics tracking. The callback is called
// synchronously on the same goroutine as Frame().
func (a *App) SetFrameCallback(cb FrameCallback) {
if a.window == nil {
return
}
a.window.frameCallback = cb
}