[RFC] compositor: check for overlap when repainting

Jesse Barnes jbarnes at virtuousgeek.org
Fri Jan 20 10:34:08 PST 2012


We can use this in the output drivers to figure out if we can use
sprites for example.

diff --git a/src/compositor.c b/src/compositor.c
index 7afec94..87f4fee 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -201,6 +201,7 @@ weston_surface_create(struct weston_compositor *compositor,
 	surface->width = width;
 	surface->height = height;
 	surface->alpha = 255;
+	surface->overlaps = 0;
 
 	surface->fullscreen_output = NULL;
 	surface->buffer = NULL;
@@ -723,7 +724,8 @@ weston_output_repaint(struct weston_output *output)
 {
 	struct weston_compositor *ec = output->compositor;
 	struct weston_surface *es;
-	pixman_region32_t opaque, new_damage, total_damage, repaint;
+	pixman_region32_t opaque, new_damage, total_damage, repaint, overlap,
+		surf_intersect, surf_region;
 
 	output->prepare_render(output);
 
@@ -757,12 +759,34 @@ weston_output_repaint(struct weston_output *output)
 
 	es = container_of(ec->surface_list.next, struct weston_surface, link);
 
+	pixman_region32_init(&overlap);
+
+	wl_list_for_each(es, &ec->surface_list, link) {
+		pixman_region32_init(&surf_intersect);
+		pixman_region32_init_rect(&surf_region, es->x, es->y,
+					  es->width, es->height);
+		/* Set 'obscured' flags on each surface */
+		pixman_region32_intersect(&surf_intersect, &overlap,
+					  &surf_region);
+		if (pixman_region32_not_empty(&surf_intersect))
+			es->overlaps = 1;
+		else
+			es->overlaps = 0;
+		/* Sum the regions into the overlap area */
+		pixman_region32_union(&overlap, &overlap, &surf_region);
+		pixman_region32_fini(&surf_intersect);
+		pixman_region32_fini(&surf_region);
+	}
+
 	wl_list_for_each(es, &ec->surface_list, link) {
+		/* Sum the damage for the screen by walking each surf damage */
 		pixman_region32_copy(&es->damage, &total_damage);
 		pixman_region32_subtract(&total_damage, &total_damage,
 					 &es->opaque);
 	}
 
+	pixman_region32_fini(&overlap);
+
 	if (output->assign_planes)
 		/* This will queue flips for the fbs and sprites where
 		 * applicable and clear the damage for those surfaces.


More information about the wayland-devel mailing list