[PATCH 4/9] nested: Add damage tracking to the nested compositor example

Neil Roberts neil at linux.intel.com
Mon Sep 9 08:41:40 PDT 2013


The nested compositor example now responds to damage requests and
tracks them in the pending buffer state. This isn't currently used for
anything and it is immediately discarded when the surface is commited
but it will be used later when the example is converted to use
subsurfaces.
---
 clients/nested.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/clients/nested.c b/clients/nested.c
index c6bbe92..6d72f4e 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -95,6 +95,9 @@ struct nested_surface {
 
 		/* wl_surface.frame */
 		struct wl_list frame_callback_list;
+
+		/* wl_surface.damage */
+		pixman_region32_t damage;
 	} pending;
 };
 
@@ -368,6 +371,8 @@ destroy_surface(struct wl_resource *resource)
 
 	nested_buffer_reference(&surface->buffer_ref, NULL);
 
+	pixman_region32_fini(&surface->pending.damage);
+
 	free(surface);
 }
 
@@ -467,6 +472,11 @@ surface_damage(struct wl_client *client,
 	       struct wl_resource *resource,
 	       int32_t x, int32_t y, int32_t width, int32_t height)
 {
+	struct nested_surface *surface = wl_resource_get_user_data(resource);
+
+	pixman_region32_union_rect(&surface->pending.damage,
+				   &surface->pending.damage,
+				   x, y, width, height);
 }
 
 static void
@@ -517,6 +527,13 @@ surface_set_input_region(struct wl_client *client,
 }
 
 static void
+empty_region(pixman_region32_t *region)
+{
+	pixman_region32_fini(region);
+	pixman_region32_init(region);
+}
+
+static void
 surface_commit(struct wl_client *client, struct wl_resource *resource)
 {
 	struct nested_surface *surface = wl_resource_get_user_data(resource);
@@ -532,6 +549,9 @@ surface_commit(struct wl_client *client, struct wl_resource *resource)
 	}
 	surface->pending.newly_attached = 0;
 
+	/* wl_surface.damage */
+	empty_region(&surface->pending.damage);
+
 	/* wl_surface.frame */
 	wl_list_insert_list(&nested->frame_callback_list,
 			    &surface->pending.frame_callback_list);
@@ -586,6 +606,7 @@ compositor_create_surface(struct wl_client *client,
 	wl_list_init(&surface->pending.frame_callback_list);
 	surface->pending.buffer_destroy_listener.notify =
 		surface_handle_pending_buffer_destroy;
+	pixman_region32_init(&surface->pending.damage);
 
 	display_acquire_window_surface(nested->display,
 				       nested->window, NULL);
-- 
1.8.3.1



More information about the wayland-devel mailing list