summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2011-09-07 21:40:41 +0800
committerChia-I Wu <[email protected]>2011-09-08 01:23:48 +0800
commit287278352ea26947f8d304458c10bf0388beebb5 (patch)
tree9a433a48be844f3d3545383630cde951db5e6606 /src
parent477b74e85be8e468c63af9f2f3fe788e486764ce (diff)
st/egl: use new wl_callback mechanism in wayland
Follow the changes in 6602bda23ba6c4351eb7f04d34803103a68ac2db.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/egl/wayland/native_drm.c27
-rw-r--r--src/gallium/state_trackers/egl/wayland/native_wayland.c52
2 files changed, 30 insertions, 49 deletions
diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c
index e34b24b58b1..e18a8883dbf 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -66,25 +66,6 @@ wayland_drm_display(const struct native_display *ndpy)
return (struct wayland_drm_display *) ndpy;
}
-static void
-sync_callback(void *data)
-{
- int *done = data;
-
- *done = 1;
-}
-
-static void
-force_roundtrip(struct wl_display *display)
-{
- int done = 0;
-
- wl_display_sync_callback(display, sync_callback, &done);
- wl_display_iterate(display, WL_DISPLAY_WRITABLE);
- while (!done)
- wl_display_iterate(display, WL_DISPLAY_READABLE);
-}
-
static void
wayland_drm_display_destroy(struct native_display *ndpy)
{
@@ -183,7 +164,7 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1);
if (id == 0)
- force_roundtrip(drmdpy->base.dpy);
+ wl_display_roundtrip(drmdpy->base.dpy);
id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1);
if (id == 0)
return FALSE;
@@ -193,11 +174,11 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
return FALSE;
wl_drm_add_listener(drmdpy->wl_drm, &drm_listener, drmdpy);
- force_roundtrip(drmdpy->base.dpy);
+ wl_display_roundtrip(drmdpy->base.dpy);
if (drmdpy->fd == -1)
return FALSE;
- force_roundtrip(drmdpy->base.dpy);
+ wl_display_roundtrip(drmdpy->base.dpy);
if (!drmdpy->authenticated)
return FALSE;
@@ -228,7 +209,7 @@ wayland_drm_display_authenticate(void *user_data, uint32_t magic)
current_authenticate = drmdpy->authenticated;
wl_drm_authenticate(drmdpy->wl_drm, magic);
- force_roundtrip(drmdpy->base.dpy);
+ wl_display_roundtrip(drmdpy->base.dpy);
authenticated = drmdpy->authenticated;
drmdpy->authenticated = current_authenticate;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c
index 544d4be215a..ded4cc481d1 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
@@ -37,25 +37,6 @@
static const struct native_event_handler *wayland_event_handler;
-static void
-sync_callback(void *data)
-{
- int *done = data;
-
- *done = 1;
-}
-
-static void
-force_roundtrip(struct wl_display *display)
-{
- int done = 0;
-
- wl_display_sync_callback(display, sync_callback, &done);
- wl_display_iterate(display, WL_DISPLAY_WRITABLE);
- while (!done)
- wl_display_iterate(display, WL_DISPLAY_READABLE);
-}
-
static const struct native_config **
wayland_display_get_configs (struct native_display *ndpy, int *num_configs)
{
@@ -157,10 +138,14 @@ wayland_pixmap_surface_initialize(struct wayland_surface *surface)
}
static void
-wayland_release_pending_resource(void *data)
+wayland_release_pending_resource(void *data,
+ struct wl_callback *callback,
+ uint32_t time)
{
struct wayland_surface *surface = data;
+ wl_callback_destroy(callback);
+
/* FIXME: print internal error */
if (!surface->pending_resource)
return;
@@ -168,6 +153,10 @@ wayland_release_pending_resource(void *data)
pipe_resource_reference(&surface->pending_resource, NULL);
}
+static const struct wl_callback_listener release_buffer_listener = {
+ wayland_release_pending_resource
+};
+
static void
wayland_window_surface_handle_resize(struct wayland_surface *surface)
{
@@ -182,13 +171,16 @@ wayland_window_surface_handle_resize(struct wayland_surface *surface)
surface->win->width, surface->win->height)) {
if (surface->pending_resource)
- force_roundtrip(display->dpy);
+ wl_display_roundtrip(display->dpy);
if (front_resource) {
+ struct wl_callback *callback;
+
surface->pending_resource = front_resource;
front_resource = NULL;
- wl_display_sync_callback(display->dpy,
- wayland_release_pending_resource, surface);
+
+ callback = wl_display_sync(display->dpy);
+ wl_callback_add_listener(callback, &release_buffer_listener, surface);
}
for (i = 0; i < WL_BUFFER_COUNT; ++i) {
@@ -232,13 +224,19 @@ wayland_surface_validate(struct native_surface *nsurf, uint attachment_mask,
}
static void
-wayland_frame_callback(struct wl_surface *surf, void *data, uint32_t time)
+wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
struct wayland_surface *surface = data;
surface->block_swap_buffers = FALSE;
+
+ wl_callback_destroy(callback);
}
+static const struct wl_callback_listener frame_listener = {
+ wayland_frame_callback
+};
+
static INLINE void
wayland_buffers_swap(struct wl_buffer **buffer,
enum wayland_buffer_type buf1,
@@ -254,13 +252,15 @@ wayland_surface_swap_buffers(struct native_surface *nsurf)
{
struct wayland_surface *surface = wayland_surface(nsurf);
struct wayland_display *display = surface->display;
+ struct wl_callback *callback;
while (surface->block_swap_buffers)
wl_display_iterate(display->dpy, WL_DISPLAY_READABLE);
surface->block_swap_buffers = TRUE;
- wl_display_frame_callback(display->dpy, surface->win->surface,
- wayland_frame_callback, surface);
+
+ callback = wl_surface_frame(surface->win->surface);
+ wl_callback_add_listener(callback, &frame_listener, surface);
if (surface->type == WL_WINDOW_SURFACE) {
resource_surface_swap_buffers(surface->rsurf,