compositor: Implement damage_below by using the new compositor->damage
authorKristian Høgsberg <krh@bitplanet.net>
Wed, 29 Feb 2012 03:47:14 +0000 (22:47 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 1 Mar 2012 17:47:23 +0000 (12:47 -0500)
We can now clip the surface bounding box against the previous frame
opaque clip, and then just union the result (visible damage) into
compositor->damage immediately.

src/compositor.c

index 434c493..7e4e7a6 100644 (file)
@@ -282,17 +282,15 @@ surface_to_global_float(struct weston_surface *surface,
 WL_EXPORT void
 weston_surface_damage_below(struct weston_surface *surface)
 {
-       struct weston_surface *below;
-
-       if (surface->output == NULL)
-               return;
-
-       if (surface->link.next == &surface->compositor->surface_list)
-               return;
+       struct weston_compositor *compositor = surface->compositor;
+       pixman_region32_t damage;
 
-       below = container_of(surface->link.next, struct weston_surface, link);
-       pixman_region32_union(&below->damage, &below->damage,
-                             &surface->transform.boundingbox);
+       pixman_region32_init(&damage);
+       pixman_region32_subtract(&damage, &surface->transform.boundingbox,
+                                &surface->clip);
+       pixman_region32_union(&compositor->damage,
+                             &compositor->damage, &damage);
+       pixman_region32_fini(&damage);
 }
 
 static void
@@ -511,21 +509,6 @@ weston_surface_damage(struct weston_surface *surface)
        weston_compositor_schedule_repaint(surface->compositor);
 }
 
-static void
-weston_surface_flush_damage(struct weston_surface *surface)
-{
-       struct weston_surface *below;
-
-       if (surface->output &&
-           surface->link.next != &surface->compositor->surface_list) {
-               below = container_of(surface->link.next,
-                                    struct weston_surface, link);
-
-               pixman_region32_union(&below->damage,
-                                     &below->damage, &surface->damage);
-       }
-}
-
 WL_EXPORT void
 weston_surface_configure(struct weston_surface *surface,
                         GLfloat x, GLfloat y, int width, int height)
@@ -615,7 +598,6 @@ static void
 weston_surface_unmap(struct weston_surface *surface)
 {
        weston_surface_damage_below(surface);
-       weston_surface_flush_damage(surface);
        surface->output = NULL;
        wl_list_remove(&surface->link);
        weston_compositor_repick(surface->compositor);