compositor, clients: make damage double-buffered
authorPekka Paalanen <ppaalanen@gmail.com>
Wed, 10 Oct 2012 09:49:25 +0000 (12:49 +0300)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 11 Oct 2012 01:38:31 +0000 (21:38 -0400)
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 <ppaalanen@gmail.com>
clients/simple-touch.c
clients/smoke.c
src/compositor.c
src/compositor.h

index 72a7e07..fa248f5 100644 (file)
@@ -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
index 69d4f23..905e53f 100644 (file)
@@ -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
index 79b6651..b17a1b3 100644 (file)
@@ -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 = {
index b79eebb..61fcdee 100644 (file)
@@ -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;
 
        /*