Skip to main content

Module frame

Module frame 

Source
Expand description

Frame clock / continuous-animation driver (§8.4, docs/animation.md).

Backends deliver a single vsync-aligned callback through day_spec::Platform::request_frame; this driver owns the registry of frame CONSUMERS (game loops, self-driven interpolations) and re-arms the backend each tick while any remain — stopping requests when none do, so an idle app never wakes the display link (battery). Consumers receive the wall-clock delta since the previous frame, clamped so a backgrounded/paused window can’t deliver a huge jump.

It is main-thread only (like the rest of the runtime): all state lives in a thread-local and the backend guarantees request_frame/its callback run on the main thread.

Structs§

FrameConsumer
Identifies a registered frame consumer; pass it to remove_frame_consumer to stop it.

Functions§

add_frame_consumer
Register cb to run every animation frame with the delta since the previous frame, and start the vsync loop if it wasn’t already running. Remove with remove_frame_consumer; the frame_clock piece ties that to its scope so it stops when the piece unmounts.
frame_consumer_count
Live consumer count — for diagnostics/tests.
install_frame_requester
Install the backend’s vsync requester (called once at launch by launch_with). f forwards to day_spec::Platform::request_frame.
remove_frame_consumer
Stop delivering frames to a consumer. When the last one is removed, the loop stops re-arming and the display link goes idle.
Day API ↩ Guides· daybrite.dev