diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 21:53:42 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 21:53:42 +0300 |
| commit | 927ae621c9a3d46dbc401b8e9ea7bbed1bf2e97b (patch) | |
| tree | aeb00c16770dcf5a36d28c1167cc39c6759059fb /include/yasl/timing.h | |
initial: Yet Another Surface Library (YASL) 0.1.0
A minimal, modern desktop window surface library in C.
Supports Wayland on Linux and Cocoa/Metal on macOS with
presentation timing, fractional scaling, IME, and CSD.
Diffstat (limited to 'include/yasl/timing.h')
| -rw-r--r-- | include/yasl/timing.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/yasl/timing.h b/include/yasl/timing.h new file mode 100644 index 0000000..7c66967 --- /dev/null +++ b/include/yasl/timing.h @@ -0,0 +1,51 @@ +#ifndef YASL_TIMING_H +#define YASL_TIMING_H + +#include <stdbool.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct yasl_resize_stats { + uint64_t count; + double avg_us; + double max_us; + long minflt; +}; + +struct yasl_timing { + double refresh_ns; + uint64_t last_present_ns; + uint64_t next_present_ns; + uint64_t frames_skipped; + struct yasl_resize_stats resize; +}; + +#define YASL_REFRESH_DEFAULT_NS 16666666.0 + +struct yasl_frame_clock { + uint64_t last_present_ns; + uint64_t resize_count; + uint64_t resize_sum_ns; + uint64_t resize_max_ns; + long resize_minflt; + uint64_t frame_time_ns; + double refresh_ns; +}; + +uint64_t yasl_clock_extend_ms(uint32_t ms, uint64_t now_ns); +void yasl_clock_presented(struct yasl_frame_clock *c, uint64_t now, bool sample); +void yasl_clock_note_resize(struct yasl_frame_clock *c, uint64_t dt_ns); +void yasl_clock_resize_stats(const struct yasl_frame_clock *c, + struct yasl_resize_stats *out); +double yasl_clock_refresh_ms(const struct yasl_frame_clock *c); +uint64_t yasl_clock_next_present_ns(const struct yasl_frame_clock *c); +uint64_t yasl_clock_frame_timestamp_ns(struct yasl_frame_clock *c, uint64_t now); + +#ifdef __cplusplus +} +#endif + +#endif /* YASL_TIMING_H */ |
