[Spice-devel] [PATCH RFC 06/14] Pass surface directly calling draw_depend_on_me and display_channel_destroy_surface

Frediano Ziglio fziglio at redhat.com
Thu Sep 29 08:44:05 UTC 2016


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/display-channel.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index dcbd250..87c801b 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -949,13 +949,10 @@ static int handle_surface_deps(DisplayChannel *display, Drawable *drawable)
     return TRUE;
 }
 
-static void draw_depend_on_me(DisplayChannel *display, uint32_t surface_id)
+static void draw_depend_on_me(DisplayChannel *display, RedSurface *surface)
 {
-    RedSurface *surface;
     RingItem *ring_item;
 
-    surface = &display->priv->surfaces[surface_id];
-
     while ((ring_item = ring_get_tail(&surface->depend_on_me))) {
         Drawable *drawable;
         DependItem *depended_item = SPICE_CONTAINEROF(ring_item, DependItem, ring_item);
@@ -1048,7 +1045,6 @@ static Drawable *display_channel_get_drawable(DisplayChannel *display, uint8_t e
  */
 static void display_channel_add_drawable(DisplayChannel *display, Drawable *drawable)
 {
-    int surface_id = drawable->surface->id;
     RedDrawable *red_drawable = drawable->red_drawable;
 
     red_drawable->mm_time = reds_get_mm_time();
@@ -1072,7 +1068,7 @@ static void display_channel_add_drawable(DisplayChannel *display, Drawable *draw
         handle_self_bitmap(display, drawable);
     }
 
-    draw_depend_on_me(display, surface_id);
+    draw_depend_on_me(display, drawable->surface);
 
     if (!handle_surface_deps(display, drawable)) {
         return;
@@ -1711,15 +1707,14 @@ static void clear_surface_drawables_from_pipes(DisplayChannel *display, int surf
 }
 
 /* TODO: cleanup/refactor destroy functions */
-static void display_channel_destroy_surface(DisplayChannel *display, uint32_t surface_id)
+static void display_channel_destroy_surface(DisplayChannel *display, RedSurface *surface)
 {
-    RedSurface *surface = &display->priv->surfaces[surface_id];
-    draw_depend_on_me(display, surface_id);
+    draw_depend_on_me(display, surface);
     /* note that draw_depend_on_me must be called before current_remove_all.
        otherwise "current" will hold items that other drawables may depend on, and then
        current_remove_all will remove them from the pipe. */
     current_remove_all(display, surface);
-    clear_surface_drawables_from_pipes(display, surface_id, FALSE);
+    clear_surface_drawables_from_pipes(display, surface->id, FALSE);
     display_channel_surface_unref(display, surface);
 }
 
@@ -1730,11 +1725,12 @@ void display_channel_destroy_surface_wait(DisplayChannel *display, uint32_t surf
     if (!display->priv->surfaces[surface_id].context.canvas)
         return;
 
-    draw_depend_on_me(display, surface_id);
+    RedSurface *surface = &display->priv->surfaces[surface_id];
+    draw_depend_on_me(display, surface);
     /* note that draw_depend_on_me must be called before current_remove_all.
        otherwise "current" will hold items that other drawables may depend on, and then
        current_remove_all will remove them from the pipe. */
-    current_remove_all(display, &display->priv->surfaces[surface_id]);
+    current_remove_all(display, surface);
     clear_surface_drawables_from_pipes(display, surface_id, TRUE);
 }
 
@@ -2003,7 +1999,7 @@ void display_channel_process_surface_cmd(DisplayChannel *display,
             break;
         }
         surface->destroy = surface_cmd->release_info_ext;
-        display_channel_destroy_surface(display, surface_id);
+        display_channel_destroy_surface(display, surface);
         break;
     default:
         spice_warn_if_reached();
-- 
2.7.4



More information about the Spice-devel mailing list