[Spice-commits] server/red_worker.c server/tree.c server/tree.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Nov 12 04:27:38 PST 2015


 server/red_worker.c |   32 ++++----------------------------
 server/tree.c       |   27 +++++++++++++++++++++++++++
 server/tree.h       |    2 ++
 3 files changed, 33 insertions(+), 28 deletions(-)

New commits:
commit 120c9ae38bb26150f5d90d1817a99065dfa37133
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Sep 17 01:45:01 2013 +0200

    worker: move some tree container functions
    
    Acked-by: Fabiano FidĂȘncio <fidencio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 11aa3f0..286bde4 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -974,30 +974,6 @@ static inline void remove_shadow(DrawItem *item)
     free(shadow);
 }
 
-static inline void current_remove_container(RedWorker *worker, Container *container)
-{
-    spice_assert(ring_is_empty(&container->items));
-    ring_remove(&container->base.siblings_link);
-    region_destroy(&container->base.rgn);
-    free(container);
-}
-
-static inline void container_cleanup(RedWorker *worker, Container *container)
-{
-    while (container && container->items.next == container->items.prev) {
-        Container *next = container->base.container;
-        if (container->items.next != &container->items) {
-            TreeItem *item = (TreeItem *)ring_get_head(&container->items);
-            spice_assert(item);
-            ring_remove(&item->siblings_link);
-            ring_add_after(&item->siblings_link, &container->base.siblings_link);
-            item->container = container->base.container;
-        }
-        current_remove_container(worker, container);
-        container = next;
-    }
-}
-
 static void display_stream_trace_add_drawable(DisplayChannel *display, Drawable *item)
 {
     ItemTrace *trace;
@@ -1076,7 +1052,7 @@ static inline void current_remove(RedWorker *worker, TreeItem *item)
                 continue;
             }
             ring_item = now->siblings_link.prev;
-            current_remove_container(worker, container);
+            container_free(container);
         }
         if (now == item) {
             return;
@@ -2659,7 +2635,7 @@ static bool free_one_drawable(RedWorker *worker, int force_glz_free)
     container = drawable->tree_item.base.container;
 
     current_remove_drawable(worker, drawable);
-    container_cleanup(worker, container);
+    container_cleanup(container);
 
     return TRUE;
 }
@@ -3157,7 +3133,7 @@ static void red_update_area_till(RedWorker *worker, const SpiceRect *area, int s
         now->refs++;
         container = now->tree_item.base.container;
         current_remove_drawable(worker, now);
-        container_cleanup(worker, container);
+        container_cleanup(container);
         /* red_draw_drawable may call red_update_area for the surfaces 'now' depends on. Notice,
            that it is valid to call red_update_area in this case and not red_update_area_till:
            It is impossible that there was newer item then 'last' in one of the surfaces
@@ -3216,7 +3192,7 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
         now->refs++;
         container = now->tree_item.base.container;
         current_remove_drawable(worker, now);
-        container_cleanup(worker, container);
+        container_cleanup(container);
         red_draw_drawable(worker, now);
         display_channel_drawable_unref(display, now);
     } while (now != last);
diff --git a/server/tree.c b/server/tree.c
index bf50edf..ad31f09 100644
--- a/server/tree.c
+++ b/server/tree.c
@@ -223,3 +223,30 @@ Container* container_new(DrawItem *item)
 
     return container;
 }
+
+void container_free(Container *container)
+{
+    spice_return_if_fail(ring_is_empty(&container->items));
+
+    ring_remove(&container->base.siblings_link);
+    region_destroy(&container->base.rgn);
+    free(container);
+}
+
+void container_cleanup(Container *container)
+{
+    /* visit upward, removing containers */
+    /* non-empty container get its element moving up ?? */
+    while (container && container->items.next == container->items.prev) {
+        Container *next = container->base.container;
+        if (container->items.next != &container->items) {
+            TreeItem *item = (TreeItem *)ring_get_head(&container->items);
+            spice_assert(item);
+            ring_remove(&item->siblings_link);
+            ring_add_after(&item->siblings_link, &container->base.siblings_link);
+            item->container = container->base.container;
+        }
+        container_free(container);
+        container = next;
+    }
+}
diff --git a/server/tree.h b/server/tree.h
index 6249c28..01d4ff9 100644
--- a/server/tree.h
+++ b/server/tree.h
@@ -82,5 +82,7 @@ static inline int is_opaque_item(TreeItem *item)
 void       tree_item_dump                           (TreeItem *item);
 Shadow*    shadow_new                               (DrawItem *item, const SpicePoint *delta);
 Container* container_new                            (DrawItem *item);
+void       container_free                           (Container *container);
+void       container_cleanup                        (Container *container);
 
 #endif /* TREE_H_ */


More information about the Spice-commits mailing list