diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-08-09 15:58:41 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-08-09 17:31:38 -0400 |
commit | 8306f46dfb93bd8d791803897927f43e0888e2bd (patch) | |
tree | 6ba4a3f4e6d7ecfa13ef0193fbc1b741c418feb1 /examples/compositor | |
parent | 87fe13a9faa6cb3bb243426f03812f2011f6d2ec (diff) |
implement surface frame
The surface frame callback lets a window know when it is a good time to show the
next frame if it is animating. In particular, this callback is used by
weston-simple-shm to throttle drawing.
Diffstat (limited to 'examples/compositor')
-rw-r--r-- | examples/compositor/main.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/compositor/main.c b/examples/compositor/main.c index 9d320c97..7ac549e5 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -23,6 +23,13 @@ struct sample_state { struct xdg_shell_state xdg_shell; }; +/* + * Convert timespec to milliseconds + */ +static inline int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} + void handle_output_frame(struct output_state *output, struct timespec *ts) { struct compositor_state *state = output->compositor; struct sample_state *sample = state->data; @@ -39,6 +46,12 @@ void handle_output_frame(struct output_state *output, struct timespec *ts) { wlr_texture_get_matrix(surface->texture, &matrix, &wlr_output->transform_matrix, 200, 200); wlr_render_with_matrix(sample->renderer, surface->texture, &matrix); + + struct wlr_frame_callback *cb, *cnext; + wl_list_for_each_safe(cb, cnext, &surface->frame_callback_list, link) { + wl_callback_send_done(cb->resource, timespec_to_msec(ts)); + wl_resource_destroy(cb->resource); + } } } |