[Spice-devel] [PATCH] display: factor out current_find_intersects_rect

Fabiano Fidêncio fidencio at redhat.com
Wed Nov 25 05:30:52 PST 2015


From: Marc-André Lureau <marcandre.lureau at gmail.com>

Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 server/display-channel.c | 45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 1837c9b..0d482c0 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1300,6 +1300,30 @@ static void draw_until(DisplayChannel *display, RedSurface *surface, Drawable *l
     } while (now != last);
 }
 
+static Drawable* current_find_intersects_rect(Ring *current, const SpiceRect *area)
+{
+    Ring *ring;
+    RingItem *ring_item;
+    QRegion rgn;
+    Drawable *last = NULL;
+
+    ring = current;
+    ring_item = ring;
+    region_init(&rgn);
+    region_add(&rgn, area);
+
+    while ((ring_item = ring_next(ring, ring_item))) {
+        Drawable *now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link);
+        if (region_intersects(&rgn, &now->tree_item.base.rgn)) {
+            last = now;
+            break;
+        }
+    }
+
+    region_destroy(&rgn);
+    return last;
+}
+
 /*
  * Renders drawables for updating the requested area, but only drawables that are older
  * than 'last' (exclusive).
@@ -1380,11 +1404,8 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i
 void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int surface_id)
 {
     RedSurface *surface;
-    Ring *ring;
-    RingItem *ring_item;
-    QRegion rgn;
     Drawable *last;
-    Drawable *now;
+
     spice_debug("surface %d: area ==>", surface_id);
     rect_debug(area);
 
@@ -1395,21 +1416,7 @@ void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int su
 
     surface = &display->surfaces[surface_id];
 
-    last = NULL;
-    ring = &surface->current_list;
-    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);
-        if (region_intersects(&rgn, &now->tree_item.base.rgn)) {
-            last = now;
-            break;
-        }
-    }
-    region_destroy(&rgn);
-
+    last = current_find_intersects_rect(&surface->current_list, area);
     if (last)
         draw_until(display, surface, last);
 
-- 
2.5.0



More information about the Spice-devel mailing list