Debian Codegraph @

src/vblank.h

raw symbols SCIP
1 // SPDX-License-Identifier: MPL-2.0
2 // Copyright (c) Yuxuan Shui <[email protected]>
3
4 #pragma once
5
6 #include <stdbool.h>
7 #include <stdint.h>
8 #include <xcb/present.h>
9 #include <xcb/xcb.h>
10
11 #include <ev.h>
12 #include <xcb/xproto.h>
13
14 #include "config.h"
15 #include "x.h"
16
17 /// An object that schedule vblank events.
18 struct vblank_scheduler;
19
20 struct vblank_event {
21 uint64_t msc;
22 uint64_t ust;
23 };
24
25 enum vblank_callback_action {
26 /// The callback should be called again in the next vblank.
27 VBLANK_CALLBACK_AGAIN,
28 /// The callback is done and should not be called again.
29 VBLANK_CALLBACK_DONE,
30 };
31
32 typedef enum vblank_callback_action (*vblank_callback_t)(struct vblank_event *event,
33 void *user_data);
34
35 /// Schedule a vblank event.
36 ///
37 /// Schedule for `cb` to be called when the current vblank ends. If this is called
38 /// from a callback function for the current vblank, the newly scheduled callback
39 /// will be called in the next vblank.
40 ///
41 /// Returns whether the scheduling is successful. Scheduling can fail if there
42 /// is not enough memory.
43 bool vblank_scheduler_schedule(struct vblank_scheduler *self, vblank_callback_t cb,
44 void *user_data);
45 struct vblank_scheduler *
46 vblank_scheduler_new(struct ev_loop *loop, struct x_connection *c, xcb_window_t target_window,
47 enum vblank_scheduler_type type, bool use_realtime_scheduling);
48 void vblank_scheduler_free(struct vblank_scheduler *);
49
50 bool vblank_handle_x_events(struct vblank_scheduler *self);