[cogl/cogl-1.14] cogland: Handle damage events for non-shm buffers too



commit 20d64cbb3937a3d418a9d91783827744d53a31a3
Author: Neil Roberts <neil linux intel com>
Date:   Thu Apr 11 16:41:17 2013 +0100

    cogland: Handle damage events for non-shm buffers too
    
    When a Wayland compositor gets a commit it only needs to redraw the
    region specified by the pending damage event. Previously Cogland was
    ignoring damage events for non-shm buffers and just always queuing a
    redraw after a commit event. This patch changes it to queue a redraw
    only in response to a damage event. In practice this doesn't really
    make much difference because Cogland doesn't do anything clever to
    handle updating a sub-region of the screen, but it more costly matches
    the model a compositor should use.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit 15f00609e41f689234ee8d5b2f9e95fb74612d12)

 examples/cogland.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/examples/cogland.c b/examples/cogland.c
index 348001c..0f82d60 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -336,15 +336,16 @@ cogland_queue_redraw (CoglandCompositor *compositor)
 }
 
 static void
-shm_buffer_damaged (CoglandSurface *surface,
-                    int32_t x,
-                    int32_t y,
-                    int32_t width,
-                    int32_t height)
+surface_damaged (CoglandSurface *surface,
+                 int32_t x,
+                 int32_t y,
+                 int32_t width,
+                 int32_t height)
 {
   struct wl_buffer *wayland_buffer = surface->buffer;
 
-  if (surface->texture)
+  if (surface->texture &&
+      wl_buffer_is_shm (surface->buffer))
     {
       CoglPixelFormat format;
       int stride = wl_shm_buffer_get_stride (wayland_buffer);
@@ -381,6 +382,8 @@ shm_buffer_damaged (CoglandSurface *surface,
                                stride,
                                data);
     }
+
+  cogland_queue_redraw (surface->compositor);
 }
 
 static void
@@ -558,7 +561,6 @@ cogland_surface_commit (struct wl_client *client,
 
   /* wl_surface.damage */
   if (surface->buffer &&
-      wl_buffer_is_shm (surface->buffer) &&
       surface->texture &&
       !region_is_empty (&surface->pending.damage))
     {
@@ -574,11 +576,11 @@ cogland_surface_commit (struct wl_client *client,
       if (region->y1 < 0)
         region->y1 = 0;
 
-      shm_buffer_damaged (surface,
-                          region->x1,
-                          region->y1,
-                          region->x2 - region->x1,
-                          region->y2 - region->y1);
+      surface_damaged (surface,
+                       region->x1,
+                       region->y1,
+                       region->x2 - region->x1,
+                       region->y2 - region->y1);
     }
   region_init (&surface->pending.damage);
 
@@ -586,8 +588,6 @@ cogland_surface_commit (struct wl_client *client,
   wl_list_insert_list (&compositor->frame_callbacks,
                        &surface->pending.frame_callback_list);
   wl_list_init (&surface->pending.frame_callback_list);
-
-  cogland_queue_redraw (compositor);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]