From 8e159180cc2cb149399b20300cbed106e298241f Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 10 Oct 2012 12:49:25 +0300 Subject: [PATCH] compositor, clients: make damage double-buffered This change depends on the Wayland commit "protocol: double-buffered state for wl_surface". Implement double-buffering of damage in the compositor as required by the new protocol. Ensure all Weston demo clients call wl_surface_commit() after wl_surface_damage(). Mesa does not need a fix for this, as the patch adding wl_surface_commit() call to Mesa already takes care of damage, too; Mesa commit: "wayland: use wl_surface_commit()" Signed-off-by: Pekka Paalanen --- clients/simple-touch.c | 4 ++++ clients/smoke.c | 1 + src/compositor.c | 15 ++++++++++++--- src/compositor.h | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/clients/simple-touch.c b/clients/simple-touch.c index 72a7e07..fa248f5 100644 --- a/clients/simple-touch.c +++ b/clients/simple-touch.c @@ -142,6 +142,10 @@ touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id) p[2] = c; wl_surface_damage(touch->surface, x - 2, y - 2, 5, 5); + /* todo: We could queue up more damage before committing, if there + * are more input events to handle. + */ + wl_surface_commit(touch->surface); } static void diff --git a/clients/smoke.c b/clients/smoke.c index 69d4f23..905e53f 100644 --- a/clients/smoke.c +++ b/clients/smoke.c @@ -223,6 +223,7 @@ redraw_handler(struct widget *widget, void *data) callback = wl_surface_frame(window_get_wl_surface(smoke->window)); wl_callback_add_listener(callback, &listener, smoke); + wl_surface_commit(window_get_wl_surface(smoke->window)); } static int diff --git a/src/compositor.c b/src/compositor.c index 79b6651..b17a1b3 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -274,6 +274,7 @@ weston_surface_create(struct weston_compositor *compositor) surface->pending.buffer_destroy_listener.notify = surface_handle_pending_buffer_destroy; + pixman_region32_init(&surface->pending.damage); return surface; } @@ -780,6 +781,8 @@ destroy_surface(struct wl_resource *resource) if (weston_surface_is_mapped(surface)) weston_surface_unmap(surface); + pixman_region32_fini(&surface->pending.damage); + if (surface->pending.buffer) wl_list_remove(&surface->pending.buffer_destroy_listener.link); @@ -1166,11 +1169,11 @@ surface_damage(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { - struct weston_surface *es = resource->data; + struct weston_surface *surface = resource->data; - pixman_region32_union_rect(&es->damage, &es->damage, + pixman_region32_union_rect(&surface->pending.damage, + &surface->pending.damage, x, y, width, height); - weston_surface_schedule_repaint(es); } static void @@ -1265,6 +1268,12 @@ surface_commit(struct wl_client *client, struct wl_resource *resource) if (surface->buffer && surface->configure) surface->configure(surface, surface->pending.sx, surface->pending.sy); + + /* wl_surface.damage */ + pixman_region32_union(&surface->damage, &surface->damage, + &surface->pending.damage); + empty_region(&surface->pending.damage); + weston_surface_schedule_repaint(surface); } static const struct wl_surface_interface surface_interface = { diff --git a/src/compositor.h b/src/compositor.h index b79eebb..61fcdee 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -474,6 +474,9 @@ struct weston_surface { struct wl_listener buffer_destroy_listener; int32_t sx; int32_t sy; + + /* wl_surface.damage */ + pixman_region32_t damage; } pending; /* -- 2.7.4