compositor: Track which plane a surface is on
authorKristian Høgsberg <krh@bitplanet.net>
Tue, 19 Jun 2012 02:37:35 +0000 (22:37 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 19 Jun 2012 02:37:35 +0000 (22:37 -0400)
We start tracking which hardware plane a surface is displayed on, which
lets us avoid generating damage when a hardware overlay/cursor is moved
around.

src/compositor-drm.c
src/compositor.c
src/compositor.h

index 1bb8929..6b21fca 100644 (file)
 #include "launcher-util.h"
 #include "log.h"
 
+enum {
+       WESTON_PLANE_DRM_CURSOR = 0x100
+};
+
 struct drm_compositor {
        struct weston_compositor base;
 
@@ -635,7 +639,6 @@ weston_output_set_cursor(struct weston_output *output,
                         pixman_region32_t *overlap)
 {
        pixman_region32_t cursor_region;
-       int prior_was_hardware;
 
        if (seat->sprite == NULL)
                return;
@@ -650,19 +653,18 @@ weston_output_set_cursor(struct weston_output *output,
                goto out;
        }
 
-       prior_was_hardware = seat->hw_cursor;
        if (pixman_region32_not_empty(overlap) ||
            drm_output_set_cursor(output, seat) < 0) {
-               if (prior_was_hardware) {
+               if (seat->sprite->plane == WESTON_PLANE_DRM_CURSOR) {
                        weston_surface_damage(seat->sprite);
                        drm_output_set_cursor(output, NULL);
                }
-               seat->hw_cursor = 0;
+               seat->sprite->plane = WESTON_PLANE_PRIMARY;
        } else {
-               if (!prior_was_hardware)
+               if (seat->sprite->plane == WESTON_PLANE_PRIMARY)
                        weston_surface_damage_below(seat->sprite);
                wl_list_remove(&seat->sprite->link);
-               seat->hw_cursor = 1;
+               seat->sprite->plane = WESTON_PLANE_DRM_CURSOR;
        }
 
 out:
@@ -705,7 +707,7 @@ drm_assign_planes(struct weston_output *output)
                        weston_output_set_cursor(output, seat,
                                                 &surface_overlap);
 
-                       if (!seat->hw_cursor)
+                       if (seat->sprite->plane == WESTON_PLANE_PRIMARY)
                                pixman_region32_union(&overlap, &overlap,
                                                      &es->transform.boundingbox);
                } else if (!drm_output_prepare_overlay_surface(output, es,
index c93da34..73fed3e 100644 (file)
@@ -306,6 +306,9 @@ weston_surface_damage_below(struct weston_surface *surface)
        struct weston_compositor *compositor = surface->compositor;
        pixman_region32_t damage;
 
+       if (surface->plane != WESTON_PLANE_PRIMARY)
+               return;
+
        pixman_region32_init(&damage);
        pixman_region32_subtract(&damage, &surface->transform.boundingbox,
                                 &surface->clip);
index 9df1933..22e5eb8 100644 (file)
@@ -222,7 +222,6 @@ struct weston_seat {
        int32_t hotspot_x, hotspot_y;
        struct wl_list link;
        enum weston_keyboard_modifier modifier_state;
-       int hw_cursor;
        struct wl_surface *saved_kbd_focus;
        struct wl_listener saved_kbd_focus_listener;
 
@@ -382,6 +381,10 @@ struct weston_region {
  * transformation in global coordinates, add it to the tail of the list.
  */
 
+enum {
+       WESTON_PLANE_PRIMARY
+};
+
 struct weston_surface {
        struct wl_surface surface;
        struct weston_compositor *compositor;
@@ -398,6 +401,7 @@ struct weston_surface {
        GLfloat opaque_rect[4];
        GLfloat alpha;
        int blend;
+       int plane;
 
        /* Surface geometry state, mutable.
         * If you change anything, set dirty = 1.