swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit ae35db94db2aa657394a208df3eba3dacf21a5a6
parent 79b3408fe488f538b9ec4cb059bd2473212f88d3
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 14 Jun 2013 04:31:20 -0700

Send frame callbacks

Diffstat:
Mcompositor.c | 15+++++++++++++++
Msurface.c | 16+++++++++++++++-
Msurface.h | 3+++
3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/compositor.c b/compositor.c @@ -163,10 +163,25 @@ static void handle_drm_event(struct wl_listener * listener, void * data) case SWC_DRM_PAGE_FLIP: { struct swc_output * output = event->data; + struct swc_surface * surface; + struct timeval timeval; + uint32_t time; output->repaint_scheduled = false; output->front_buffer ^= 1; + gettimeofday(&timeval, NULL); + time = timeval.tv_sec * 1000 + timeval.tv_usec / 1000; + + /* Handle all frame callbacks for surfaces on this output. */ + wl_list_for_each(surface, &compositor->surfaces, link) + { + swc_surface_send_frame_callbacks(surface, time); + + if (surface->state.buffer) + wl_buffer_send_release(&surface->state.buffer->resource); + } + break; } } diff --git a/surface.c b/surface.c @@ -64,7 +64,8 @@ static void frame(struct wl_client * client, struct wl_resource * resource, callback_resource = wl_client_add_object(client, &wl_callback_interface, NULL, id, NULL); - wl_list_insert(surface->pending.state.frame_callbacks.prev, &resource->link); + wl_list_insert(surface->pending.state.frame_callbacks.prev, + &callback_resource->link); } static void set_opaque_region(struct wl_client * client, @@ -174,4 +175,17 @@ void swc_surface_finish(struct swc_surface * surface) { } +void swc_surface_send_frame_callbacks(struct swc_surface * surface, + uint32_t time) +{ + struct wl_resource * callback; + + wl_list_for_each(callback, &surface->state.frame_callbacks, link) + { + wl_callback_send_done(callback, time); + wl_resource_destroy(callback); + } + + wl_list_init(&surface->state.frame_callbacks); +} diff --git a/surface.h b/surface.h @@ -67,5 +67,8 @@ bool swc_surface_initialize(struct swc_surface * surface, void swc_surface_finish(struct swc_surface * surface); +void swc_surface_send_frame_callbacks(struct swc_surface * surface, + uint32_t time); + #endif