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
use std::cell::Cell;
thread_local! {
static NEEDS_COMPOSE: Cell<bool> = const { Cell::new(true) };
static NEEDS_PRESENT: Cell<bool> = const { Cell::new(false) };
static SIGNAL_FIRED: Cell<bool> = const { Cell::new(false) };
}
/// Request another frame (coalesced). Sets both compose and present flags.
#[inline]
pub fn request_frame() {
NEEDS_COMPOSE.set(true);
NEEDS_PRESENT.set(true);
}
/// Request a present-only (no full recompose), e.g. for texture uploads.
#[inline]
pub fn request_present() {
NEEDS_PRESENT.set(true);
}
/// Returns true if a compose was requested since last check, and clears the flag.
#[inline]
pub fn take_frame_request() -> bool {
NEEDS_COMPOSE.replace(false)
}
/// Returns true if a present was requested since last check, and clears the flag.
#[inline]
pub fn take_present_request() -> bool {
NEEDS_PRESENT.replace(false)
}
/// Non-consuming check (rarely needed).
#[inline]
pub fn peek_frame_request() -> bool {
NEEDS_COMPOSE.get()
}
/// Mark that a signal just fired (real data change).
#[inline]
pub fn signal_fired() {
SIGNAL_FIRED.set(true);
}
/// Returns true if `signal_fired()` was called since last check, and clears it.
#[inline]
pub fn take_signal_fired() -> bool {
SIGNAL_FIRED.replace(false)
}