[PATCH 11/18] display: reuse code in display_channel_draw_until

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

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>

---
 server/display-channel.c | 44 +++++++++++++-------------------------------
 server/display-channel.h |  2 +-
 server/red_worker.c      |  5 ++---
 3 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 9953a39..855b65a 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1300,20 +1300,18 @@ static void draw_until(DisplayChannel *display, RedSurface *surface, Drawable *l
     } while (now != last);
 }
 
-static Drawable* current_find_intersects_rect(Ring *current, const SpiceRect *area)
+static Drawable* current_find_intersects_rect(Ring *current, RingItem *from,
+                                              const SpiceRect *area)
 {
-    Ring *ring;
-    RingItem *ring_item;
+    RingItem *it;
     QRegion rgn;
     Drawable *last = NULL, *now;
 
-    ring = current;
-    ring_item = ring;
     region_init(&rgn);
     region_add(&rgn, area);
 
-    while ((ring_item = ring_next(ring, ring_item))) {
-        now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link);
+    for (it = from ?: ring_next(current, current); it != NULL; it = ring_next(current, it)) {
+        now = SPICE_CONTAINEROF(it, Drawable, surface_list_link);
         if (region_intersects(&rgn, &now->tree_item.base.rgn)) {
             last = now;
             break;
@@ -1329,7 +1327,7 @@ static Drawable* current_find_intersects_rect(Ring *current, const SpiceRect *ar
  * than 'last' (exclusive).
  * FIXME: merge with display_channel_draw()?
  */
-void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, int surface_id,
+void display_channel_draw_until(DisplayChannel *display, const SpiceRect *area, int surface_id,
                                Drawable *last)
 {
     RedSurface *surface;
@@ -1337,7 +1335,6 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i
     Ring *ring;
     RingItem *ring_item;
     Drawable *now;
-    QRegion rgn;
 
     spice_return_if_fail(last);
     spice_return_if_fail(ring_item_is_linked(&last->list_link));
@@ -1362,26 +1359,13 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i
         }
     }
 
-    if (!surface_last) {
+    if (!surface_last)
         return;
-    }
-
-    ring = &surface->current_list;
-    ring_item = &surface_last->surface_list_link;
-
-    region_init(&rgn);
-    region_add(&rgn, area);
-
-    // find the first older drawable that intersects with the area
-    do {
-        now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link);
-        if (region_intersects(&rgn, &now->tree_item.base.rgn)) {
-            surface_last = now;
-            break;
-        }
-    } while ((ring_item = ring_next(ring, ring_item)));
 
-    region_destroy(&rgn);
+    last = current_find_intersects_rect(&surface->current_list,
+                                        &surface_last->surface_list_link, area);
+    if (!last)
+        return;
 
     /* drawable_draw may call display_channel_draw for the surfaces
      * 'now' depends on. Notice, that it is valid to call
@@ -1392,9 +1376,7 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i
      * already been rendered.  See the call for
      * red_handle_depends_on_target_surface in red_process_draw
      */
-    if (surface_last)
-        draw_until(display, surface, surface_last);
-
+    draw_until(display, surface, last);
     surface_update_dest(surface, area);
 }
 
@@ -1413,7 +1395,7 @@ void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int su
 
     surface = &display->surfaces[surface_id];
 
-    last = current_find_intersects_rect(&surface->current_list, area);
+    last = current_find_intersects_rect(&surface->current_list, NULL, area);
     if (!last)
         return;
 
diff --git a/server/display-channel.h b/server/display-channel.h
index 391e4ab..0a6f120 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -254,7 +254,7 @@ typedef struct UpgradeItem {
 void                       display_channel_draw                      (DisplayChannel *display,
                                                                       const SpiceRect *area,
                                                                       int surface_id);
-void                       display_channel_draw_till                 (DisplayChannel *display,
+void                       display_channel_draw_until                (DisplayChannel *display,
                                                                       const SpiceRect *area,
                                                                       int surface_id,
                                                                       Drawable *last);
diff --git a/server/red_worker.c b/server/red_worker.c
index 649fdce..6761e6f 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -522,7 +522,7 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
                     stream_id, stream->current != NULL);
         rect_debug(&upgrade_area);
         if (update_area_limit) {
-            display_channel_draw_till(DCC_TO_DC(dcc), &upgrade_area, 0, update_area_limit);
+            display_channel_draw_until(DCC_TO_DC(dcc), &upgrade_area, 0, update_area_limit);
         } else {
             display_channel_draw(DCC_TO_DC(dcc), &upgrade_area, 0);
         }
@@ -1706,8 +1706,7 @@ static void red_add_lossless_drawable_dependencies(RedChannelClient *rcc,
     } else {
         sync_rendered = FALSE;
         for (i = 0; i < num_deps; i++) {
-            display_channel_draw_till(display, deps_areas[i],
-                                 deps_surfaces_ids[i], item);
+            display_channel_draw_until(display, deps_areas[i], deps_surfaces_ids[i], item);
         }
     }
 
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]