[Spice-devel] [PATCH RFC 10/14] Pass surface directly to dcc_create_surface

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


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/dcc.c             | 13 ++++++-------
 server/dcc.h             |  3 +--
 server/display-channel.c | 11 ++++++-----
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/server/dcc.c b/server/dcc.c
index c4510b0..8a63caf 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -127,10 +127,10 @@ int dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, RedSurface
     return red_channel_client_wait_outgoing_item(rcc, DISPLAY_CLIENT_SHORT_TIMEOUT);
 }
 
-void dcc_create_surface(DisplayChannelClient *dcc, int surface_id)
+void dcc_create_surface(DisplayChannelClient *dcc, RedSurface *surface)
 {
     DisplayChannel *display;
-    RedSurface *surface;
+    uint32_t surface_id = surface->id;
     RedSurfaceCreateItem *create;
     uint32_t flags;
 
@@ -139,14 +139,13 @@ void dcc_create_surface(DisplayChannelClient *dcc, int surface_id)
     }
 
     display = DCC_TO_DC(dcc);
-    flags = is_primary_surface_id(DCC_TO_DC(dcc), surface_id) ? SPICE_SURFACE_FLAGS_PRIMARY : 0;
+    flags = is_primary_surface(DCC_TO_DC(dcc), surface) ? SPICE_SURFACE_FLAGS_PRIMARY : 0;
 
     /* don't send redundant create surface commands to client */
     if (!dcc || display->common.during_target_migrate ||
         dcc->priv->surface_client_created[surface_id]) {
         return;
     }
-    surface = &display->priv->surfaces[surface_id];
     create = red_surface_create_item_new(RED_CHANNEL(display),
                                          surface_id, surface->context.width,
                                          surface->context.height,
@@ -256,7 +255,7 @@ static void add_drawable_surface_images(DisplayChannelClient *dcc, Drawable *dra
             if (dcc->priv->surface_client_created[surface_id] == TRUE) {
                 continue;
             }
-            dcc_create_surface(dcc, surface_id);
+            dcc_create_surface(dcc, drawable->surface_deps[x]);
             display_channel_current_flush(display, drawable->surface_deps[x]);
             dcc_push_surface_image(dcc, surface_id);
         }
@@ -266,7 +265,7 @@ static void add_drawable_surface_images(DisplayChannelClient *dcc, Drawable *dra
         return;
     }
 
-    dcc_create_surface(dcc, drawable->surface->id);
+    dcc_create_surface(dcc, drawable->surface);
     display_channel_current_flush(display, drawable->surface);
     dcc_push_surface_image(dcc, drawable->surface->id);
 }
@@ -439,7 +438,7 @@ void dcc_start(DisplayChannelClient *dcc)
     if (display->priv->surfaces[0].context.canvas) {
         display_channel_current_flush(display, &display->priv->surfaces[0]);
         red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
-        dcc_create_surface(dcc, 0);
+        dcc_create_surface(dcc, &display->priv->surfaces[0]);
         dcc_push_surface_image(dcc, 0);
         dcc_push_monitors_config(dcc);
         red_pipe_add_verb(rcc, SPICE_MSG_DISPLAY_MARK);
diff --git a/server/dcc.h b/server/dcc.h
index 47386ff..2068d78 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -122,8 +122,7 @@ void                       dcc_stream_agent_clip                     (DisplayCha
                                                                       StreamAgent *agent);
 void                       dcc_create_stream                         (DisplayChannelClient *dcc,
                                                                       Stream *stream);
-void                       dcc_create_surface                        (DisplayChannelClient *dcc,
-                                                                      int surface_id);
+void dcc_create_surface(DisplayChannelClient *dcc, struct RedSurface *surface);
 void                       dcc_push_surface_image                    (DisplayChannelClient *dcc,
                                                                       int surface_id);
 RedImageItem *             dcc_add_surface_area_image                (DisplayChannelClient *dcc,
diff --git a/server/display-channel.c b/server/display-channel.c
index e0a91a3..64a59de 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1773,15 +1773,15 @@ void display_channel_destroy_surfaces(DisplayChannel *display)
     display_channel_free_glz_drawables(display);
 }
 
-static void send_create_surface(DisplayChannel *display, int surface_id, int image_ready)
+static void send_create_surface(DisplayChannel *display, RedSurface *surface, int image_ready)
 {
     DisplayChannelClient *dcc;
     GListIter iter;
 
     FOREACH_DCC(display, iter, dcc) {
-        dcc_create_surface(dcc, surface_id);
+        dcc_create_surface(dcc, surface);
         if (image_ready)
-            dcc_push_surface_image(dcc, surface_id);
+            dcc_push_surface_image(dcc, surface->id);
     }
 }
 
@@ -1854,8 +1854,9 @@ void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id
     }
 
     spice_return_if_fail(surface->context.canvas);
-    if (send_client)
-        send_create_surface(display, surface_id, data_is_valid);
+    if (send_client) {
+        send_create_surface(display, surface, data_is_valid);
+    }
 }
 
 static void on_disconnect(RedChannelClient *rcc)
-- 
2.7.4



More information about the Spice-devel mailing list