[Spice-commits] 2 commits - server/display-channel.c

Fabiano Fidêncio fidencio at kemper.freedesktop.org
Wed Nov 25 06:05:02 PST 2015


 server/display-channel.c |  103 +++++++++++++++++++++++------------------------
 1 file changed, 52 insertions(+), 51 deletions(-)

New commits:
commit 00526f0733a2afa68ba74aca73d66f454597fd80
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Mon Nov 23 17:02:04 2015 +0000

    display: factor out current_find_intersects_rect
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/display-channel.c b/server/display-channel.c
index d2ee523..e158d59 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1305,6 +1305,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).
@@ -1376,11 +1400,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);
 
@@ -1391,21 +1412,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);
 
commit 3d0f4e3642aa5610e99a60ae92627bd7b0450b55
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Mon Nov 23 17:02:03 2015 +0000

    display: factor out draw_until
    
    Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

diff --git a/server/display-channel.c b/server/display-channel.c
index d54f725..d2ee523 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1282,6 +1282,29 @@ static void surface_update_dest(RedSurface *surface, const SpiceRect *area)
     canvas->ops->read_bits(canvas, dest, -stride, area);
 }
 
+static void draw_until(DisplayChannel *display, RedSurface *surface, Drawable *last)
+{
+    RingItem *ring_item;
+    Container *container;
+    Drawable *now;
+
+    do {
+        ring_item = ring_get_tail(&surface->current_list);
+        now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link);
+        now->refs++;
+        container = now->tree_item.base.container;
+        current_remove_drawable(display, now);
+        container_cleanup(container);
+        /* drawable_draw may call display_channel_draw for the surfaces 'now' depends on. Notice,
+           that it is valid to call display_channel_draw in this case and not display_channel_draw_till:
+           It is impossible that there was newer item then 'last' in one of the surfaces
+           that display_channel_draw is called for, Otherwise, 'now' would have already been rendered.
+           See the call for red_handle_depends_on_target_surface in red_process_draw */
+        drawable_draw(display, now);
+        display_channel_drawable_unref(display, now);
+    } while (now != last);
+}
+
 /*
  * Renders drawables for updating the requested area, but only drawables that are older
  * than 'last' (exclusive).
@@ -1345,23 +1368,8 @@ void display_channel_draw_till(DisplayChannel *display, const SpiceRect *area, i
         return;
     }
 
-    do {
-        Container *container;
+    draw_until(display, surface, surface_last);
 
-        ring_item = ring_get_tail(&surface->current_list);
-        now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link);
-        now->refs++;
-        container = now->tree_item.base.container;
-        current_remove_drawable(display, now);
-        container_cleanup(container);
-        /* drawable_draw may call display_channel_draw for the surfaces 'now' depends on. Notice,
-           that it is valid to call display_channel_draw in this case and not display_channel_draw_till:
-           It is impossible that there was newer item then 'last' in one of the surfaces
-           that display_channel_draw is called for, Otherwise, 'now' would have already been rendered.
-           See the call for red_handle_depends_on_target_surface in red_process_draw */
-        drawable_draw(display, now);
-        display_channel_drawable_unref(display, now);
-    } while (now != surface_last);
     surface_update_dest(surface, area);
 }
 
@@ -1398,22 +1406,8 @@ void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int su
     }
     region_destroy(&rgn);
 
-    if (!last) {
-        surface_update_dest(surface, area);
-        return;
-    }
-
-    do {
-        Container *container;
+    if (last)
+        draw_until(display, surface, last);
 
-        ring_item = ring_get_tail(&surface->current_list);
-        now = SPICE_CONTAINEROF(ring_item, Drawable, surface_list_link);
-        now->refs++;
-        container = now->tree_item.base.container;
-        current_remove_drawable(display, now);
-        container_cleanup(container);
-        drawable_draw(display, now);
-        display_channel_drawable_unref(display, now);
-    } while (now != last);
     surface_update_dest(surface, area);
 }


More information about the Spice-commits mailing list