[Spice-devel] [PATCH v4 6/6] Handle GL_DRAW_DONE

Marc-André Lureau marcandre.lureau at gmail.com
Tue Feb 9 13:35:06 UTC 2016


When a client is done with drawing and sends
SPICE_MSGC_DISPLAY_GL_DRAW_DONE, or when it ends, update the number of
async counts.

Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
[reduce critical message to a warning; do not reset gl_draw_ongoing
 - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/dcc.c             | 24 ++++++++++++++++++++++++
 server/display-channel.c |  5 +++++
 server/display-channel.h |  1 +
 3 files changed, 30 insertions(+)

diff --git a/server/dcc.c b/server/dcc.c
index 6972616..5ccbda1 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -494,6 +494,8 @@ static void dcc_destroy_stream_agents(DisplayChannelClient *dcc)
 
 void dcc_stop(DisplayChannelClient *dcc)
 {
+    DisplayChannel *dc = DCC_TO_DC(dcc);
+
     pixmap_cache_unref(dcc->pixmap_cache);
     dcc->pixmap_cache = NULL;
     dcc_release_glz(dcc);
@@ -502,6 +504,10 @@ void dcc_stop(DisplayChannelClient *dcc)
     free(dcc->send_data.free_list.res);
     dcc_destroy_stream_agents(dcc);
     dcc_encoders_free(dcc);
+
+    if (dcc->gl_draw_ongoing) {
+        display_channel_gl_draw_done(dc);
+    }
 }
 
 void dcc_stream_agent_clip(DisplayChannelClient* dcc, StreamAgent *agent)
@@ -1391,6 +1397,22 @@ static int dcc_handle_preferred_compression(DisplayChannelClient *dcc,
     return TRUE;
 }
 
+static int dcc_handle_gl_draw_done(DisplayChannelClient *dcc)
+{
+    DisplayChannel *display = DCC_TO_DC(dcc);
+
+    if (G_UNLIKELY(!dcc->gl_draw_ongoing)) {
+        g_warning("unexpected DRAW_DONE received\n");
+        /* close client connection */
+        return FALSE;
+    }
+
+    dcc->gl_draw_ongoing = FALSE;
+    display_channel_gl_draw_done(display);
+
+    return TRUE;
+}
+
 int dcc_handle_message(RedChannelClient *rcc, uint32_t size, uint16_t type, void *msg)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
@@ -1403,6 +1425,8 @@ int dcc_handle_message(RedChannelClient *rcc, uint32_t size, uint16_t type, void
     case SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION:
         return dcc_handle_preferred_compression(dcc,
             (SpiceMsgcDisplayPreferredCompression *)msg);
+    case SPICE_MSGC_DISPLAY_GL_DRAW_DONE:
+        return dcc_handle_gl_draw_done(dcc);
     default:
         return red_channel_client_handle_message(rcc, size, type, msg);
     }
diff --git a/server/display-channel.c b/server/display-channel.c
index 936c74a..b4f7ede 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2178,3 +2178,8 @@ void display_channel_gl_draw(DisplayChannel *display, SpiceMsgDisplayGlDraw *dra
     num = red_channel_pipes_new_add_push(RED_CHANNEL(display), dcc_gl_draw_item_new, draw);
     set_gl_draw_async_count(display, num);
 }
+
+void display_channel_gl_draw_done(DisplayChannel *display)
+{
+    set_gl_draw_async_count(display, display->gl_draw_async_count - 1);
+}
diff --git a/server/display-channel.h b/server/display-channel.h
index 3d2a465..82fd663 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -313,6 +313,7 @@ void                       display_channel_update_compression        (DisplayCha
 void                       display_channel_gl_scanout                (DisplayChannel *display);
 void                       display_channel_gl_draw                   (DisplayChannel *display,
                                                                       SpiceMsgDisplayGlDraw *draw);
+void                       display_channel_gl_draw_done              (DisplayChannel *display);
 
 static inline int validate_surface(DisplayChannel *display, uint32_t surface_id)
 {
-- 
2.5.0



More information about the Spice-devel mailing list