ferroui_base/rendering/i_render_loop.rs
1use std::sync::Arc;
2
3use super::IRenderLoopTask;
4
5/// The application render loop.
6///
7/// The render loop is responsible for advancing the animation timer and
8/// updating the scene graph for visible windows.
9pub trait IRenderLoop: Send + Sync {
10 /// Adds an update task.
11 ///
12 /// Registered update tasks will be polled on each tick of the render loop
13 /// after the animation timer has been pulsed.
14 fn add(&self, i: Arc<dyn IRenderLoopTask>);
15
16 /// Removes an update task.
17 fn remove(&self, i: &Arc<dyn IRenderLoopTask>);
18
19 /// Indicates if the rendering is done on a non-UI thread.
20 fn runs_in_background(&self) -> bool;
21
22 /// Wakes up the render loop to schedule the next tick.
23 /// Thread-safe: can be called from any thread.
24 fn wakeup(&self);
25
26 /// Asks for a frame out of turn: a tick as soon as the thread that ticks
27 /// can produce one. Not from upstream.
28 ///
29 /// Called by the thread of a compositor before it blocks until a batch
30 /// has been processed or rendered by the render thread, after the batch
31 /// was committed (which wakes the loop up). The frame is never rendered
32 /// on the calling thread. The default does nothing: the caller then
33 /// waits for the next tick of the loop.
34 fn request_frame_out_of_turn(&self) {}
35}