[Spice-commits] 5 commits - src/Makefile.am src/spice-widget.c src/spice-widget-egl.c src/spice-widget-priv.h

Marc-André Lureau elmarco at kemper.freedesktop.org
Thu Jun 15 10:48:25 UTC 2017


 src/Makefile.am         |    1 -
 src/spice-widget-egl.c  |    4 +++-
 src/spice-widget-priv.h |    2 +-
 src/spice-widget.c      |   29 ++++++++++++++++++-----------
 4 files changed, 22 insertions(+), 14 deletions(-)

New commits:
commit 90ccba3487147d02c8ff478715187322b8c1daf5
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Wed Jun 14 20:11:57 2017 +0400

    build-sys: remove -DSPICE_DISABLE_ABORT
    
    spice-gtk doesn't use spice_abort().
    
    SPICE_DISABLE_ABORT was mostly used to change default abort behaviour
    on criticals in spice-common, but since it works fine without this
    flag since 2012 (commit 05a203af120016), we can safely remove that
    unused define from spice-gtk.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/Makefile.am b/src/Makefile.am
index bb7ad6c..5430d84 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,7 +74,6 @@ SPICE_COMMON_CPPFLAGS =						\
 	-DSPICE_GTK_LOCALEDIR=\"${SPICE_GTK_LOCALEDIR}\"	\
 	-DPNP_IDS=\""$(PNP_IDS)"\"				\
 	-DUSB_IDS=\""$(USB_IDS)"\"				\
-	-DSPICE_DISABLE_ABORT					\
 	-I$(top_srcdir)						\
 	$(COMMON_CFLAGS)					\
 	$(PIXMAN_CFLAGS)					\
commit 3c1f46c4b34344b1b879c47da77607d91618a8a9
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Jun 8 00:46:43 2017 +0400

    widget: switch 'display' type to DisplayChannel*
    
    This avoids the long casts. The Channel* type is less commonly used.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
index f9c024c..7c21113 100644
--- a/src/spice-widget-egl.c
+++ b/src/spice-widget-egl.c
@@ -275,7 +275,7 @@ end:
 
     d->egl.context_ready = TRUE;
 
-    if (spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display)) != NULL) {
+    if (spice_display_get_gl_scanout(d->display) != NULL) {
         DISPLAY_DEBUG(display, "scanout present during egl init, updating widget");
         spice_display_widget_gl_scanout(display);
         spice_display_widget_update_monitor_area(display);
diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 5b3216f..ea7ed8e 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -91,7 +91,7 @@ struct _SpiceDisplayPrivate {
     SpiceSession            *session;
     SpiceGtkSession         *gtk_session;
     SpiceMainChannel        *main;
-    SpiceChannel            *display;
+    SpiceDisplayChannel     *display;
     SpiceCursorChannel      *cursor;
     SpiceInputsChannel      *inputs;
     SpiceSmartcardChannel   *smartcard;
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 979e5fb..0945ac6 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -301,7 +301,8 @@ void spice_display_widget_update_monitor_area(SpiceDisplay *display)
     if (c == NULL) {
         DISPLAY_DEBUG(display, "update monitor: no monitor %d", d->monitor_id);
         set_monitor_ready(display, false);
-        if (spice_channel_test_capability(d->display, SPICE_DISPLAY_CAP_MONITORS_CONFIG)) {
+        if (spice_channel_test_capability(SPICE_CHANNEL(d->display),
+                                          SPICE_DISPLAY_CAP_MONITORS_CONFIG)) {
             DISPLAY_DEBUG(display, "waiting until MonitorsConfig is received");
             g_clear_pointer(&monitors, g_array_unref);
             return;
@@ -586,7 +587,7 @@ gl_area_render(GtkGLArea *area, GdkGLContext *context, gpointer user_data)
     spice_egl_update_display(display);
     glFlush();
     if (d->egl.call_draw_done) {
-        spice_display_gl_draw_done(SPICE_DISPLAY_CHANNEL(d->display));
+        spice_display_gl_draw_done(d->display);
         d->egl.call_draw_done = FALSE;
     }
 
@@ -619,9 +620,9 @@ drawing_area_realize(GtkWidget *area, gpointer user_data)
     SpiceDisplay *display = SPICE_DISPLAY(user_data);
 
     if (GDK_IS_X11_DISPLAY(gdk_display_get_default()) &&
-        spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(display->priv->display)) != NULL)
+        spice_display_get_gl_scanout(display->priv->display) != NULL) {
         spice_display_widget_gl_scanout(display);
-
+    }
 #endif
 }
 
@@ -2503,7 +2504,7 @@ static void update_area(SpiceDisplay *display,
 #if HAVE_EGL
     if (egl_enabled(d)) {
         const SpiceGlScanout *so =
-            spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display));
+            spice_display_get_gl_scanout(d->display);
         g_return_if_fail(so != NULL);
         primary = (GdkRectangle) {
             .width = so->width,
@@ -2553,7 +2554,7 @@ static void primary_create(SpiceChannel *channel, gint format,
     spice_display_widget_update_monitor_area(display);
 }
 
-static void primary_destroy(SpiceChannel *channel, gpointer data)
+static void primary_destroy(SpiceDisplayChannel *channel, gpointer data)
 {
     SpiceDisplay *display = SPICE_DISPLAY(data);
     SpiceDisplayPrivate *d = display->priv;
@@ -2871,7 +2872,7 @@ void spice_display_widget_gl_scanout(SpiceDisplay *display)
     if (d->egl.context_ready) {
         const SpiceGlScanout *scanout;
 
-        scanout = spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display));
+        scanout = spice_display_get_gl_scanout(d->display);
         /* should only be called when the display has a scanout */
         g_return_if_fail(scanout != NULL);
 
@@ -2893,7 +2894,7 @@ static void gl_draw(SpiceDisplay *display,
 
     if (!d->egl.context_ready) {
         DISPLAY_DEBUG(display, "Draw without GL context, skipping");
-        spice_display_gl_draw_done(SPICE_DISPLAY_CHANNEL(d->display));
+        spice_display_gl_draw_done(d->display);
         return;
     }
 
@@ -2910,7 +2911,7 @@ static void gl_draw(SpiceDisplay *display,
 #endif
     {
         spice_egl_update_display(display);
-        spice_display_gl_draw_done(SPICE_DISPLAY_CHANNEL(d->display));
+        spice_display_gl_draw_done(d->display);
     }
 }
 #endif
@@ -2934,7 +2935,7 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
         SpiceDisplayPrimary primary;
         if (id != d->channel_id)
             return;
-        d->display = channel;
+        d->display = SPICE_DISPLAY_CHANNEL(channel);
         spice_g_signal_connect_object(channel, "display-primary-create",
                                       G_CALLBACK(primary_create), display, 0);
         spice_g_signal_connect_object(channel, "display-primary-destroy",
commit 214b3396de62ace3e93ba14e5cff015244a52aff
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Jun 8 00:41:49 2017 +0400

    widget: call gl-draw when skipping draw
    
    It's a bad idea to hold the GL scanout for a long time, especially in
    error cases. (fwiw, qemu has 1s tolerance before complaining, and the
    guest is most likely going to hang meanwhile, stuck on the GPU)
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 1e09389..979e5fb 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2891,7 +2891,11 @@ static void gl_draw(SpiceDisplay *display,
 
     set_egl_enabled(display, true);
 
-    g_return_if_fail(d->egl.context_ready);
+    if (!d->egl.context_ready) {
+        DISPLAY_DEBUG(display, "Draw without GL context, skipping");
+        spice_display_gl_draw_done(SPICE_DISPLAY_CHANNEL(d->display));
+        return;
+    }
 
 #if GTK_CHECK_VERSION(3,16,0)
     GtkWidget *gl = gtk_stack_get_child_by_name(d->stack, "gl-area");
commit c576359ce356c071e8955c773d0781151d5b199b
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Jun 8 00:38:45 2017 +0400

    widget: skip spice_egl_resize_display() if context is not ready
    
    And call spice_egl_resize_display() when initializing the context.
    
    The display must not call spice_egl_resize_display() if the egl/gl
    context isn't ready. set_egl_enabled() is called whenever we get gl
    drawing command from spice server. But the egl/gl context may not be
    ready at that time. That function must still be run to switch the
    display to GL, but has to delay any GL call to after the GL context is
    realized.  Add spice_egl_resize_display() there, to do the remaining
    egl setup.
    
    This fixes the "Couldn't find current GL or GLX context" error for me
    on X11. I thought first it was somehow related to commit a395ac59447de
    "spice-widget: init egl only after first gl_scanout", but reverting it
    didn't solve the problem, there are other timing changes, probably at
    gtk level.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 1a1d5a6..1e09389 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1327,7 +1327,7 @@ static void set_egl_enabled(SpiceDisplay *display, bool enabled)
                                          enabled ? "gl-area" : "draw-area");
     }
 
-    if (enabled) {
+    if (enabled && d->egl.context_ready) {
         spice_egl_resize_display(display, d->ww, d->wh);
     }
 
@@ -2861,6 +2861,8 @@ void spice_display_widget_gl_scanout(SpiceDisplay *display)
             g_critical("egl realize failed: %s", err->message);
             g_clear_error(&err);
         }
+
+        spice_egl_resize_display(display, d->ww, d->wh);
     }
 #endif
 
commit 422572c37793bf6141bc58d441bcda37090c74f3
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Jun 8 00:35:57 2017 +0400

    egl: add a precondition on gl_make_current()
    
    To ease with debugging GL issues.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
index 130710e..f9c024c 100644
--- a/src/spice-widget-egl.c
+++ b/src/spice-widget-egl.c
@@ -289,6 +289,8 @@ gl_make_current(SpiceDisplay *display, GError **err)
 {
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
 
+    g_return_val_if_fail(d->egl.context_ready, FALSE);
+
     if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
         EGLBoolean success = eglMakeCurrent(d->egl.display,
                                             d->egl.surface,


More information about the Spice-commits mailing list