[Spice-devel] [PATCH spice-gtk 3/4] session: add gl-scanout property

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Thu Jan 3 17:13:25 UTC 2019


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Allow to set whether GL scanout capability is set, at the session level.

SPICE_DISABLE_GL_SCANOUT environment variable can be used for tweaking
and testing. Note: the server doesn't seem to handle this case very
nicely yet: the simplest solution could perhaps be to disconnect the
client, instead of having it hang waiting for a display.

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 src/channel-display.c    |  7 ++++---
 src/spice-session-priv.h |  1 +
 src/spice-session.c      | 43 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/src/channel-display.c b/src/channel-display.c
index bec72ab..581ca80 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -845,6 +845,7 @@ static SpiceImageSurfacesOps image_surfaces_ops = {
 
 static void spice_display_channel_set_capabilities(SpiceChannel *channel)
 {
+    SpiceSession *s = spice_channel_get_session(channel);
     guint i;
 
     spice_channel_set_capability(channel, SPICE_DISPLAY_CAP_SIZED_STREAM);
@@ -857,9 +858,9 @@ static void spice_display_channel_set_capabilities(SpiceChannel *channel)
     if (SPICE_DISPLAY_CHANNEL(channel)->priv->enable_adaptive_streaming) {
         spice_channel_set_capability(channel, SPICE_DISPLAY_CAP_STREAM_REPORT);
     }
-#ifdef G_OS_UNIX
-    spice_channel_set_capability(channel, SPICE_DISPLAY_CAP_GL_SCANOUT);
-#endif
+    if (spice_session_get_gl_scanout_enabled(s)) {
+        spice_channel_set_capability(channel, SPICE_DISPLAY_CAP_GL_SCANOUT);
+    }
     spice_channel_set_capability(channel, SPICE_DISPLAY_CAP_MULTI_CODEC);
 #ifdef HAVE_BUILTIN_MJPEG
     spice_channel_set_capability(channel, SPICE_DISPLAY_CAP_CODEC_MJPEG);
diff --git a/src/spice-session-priv.h b/src/spice-session-priv.h
index 0190c1f..6ece7e0 100644
--- a/src/spice-session-priv.h
+++ b/src/spice-session-priv.h
@@ -89,6 +89,7 @@ void spice_session_sync_playback_latency(SpiceSession *session);
 gboolean spice_session_get_audio_enabled(SpiceSession *session);
 gboolean spice_session_get_smartcard_enabled(SpiceSession *session);
 gboolean spice_session_get_usbredir_enabled(SpiceSession *session);
+gboolean spice_session_get_gl_scanout_enabled(SpiceSession *session);
 
 const guint8* spice_session_get_webdav_magic(SpiceSession *session);
 PhodavServer *spice_session_get_webdav_server(SpiceSession *session);
diff --git a/src/spice-session.c b/src/spice-session.c
index a2ed401..74c1f6e 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -61,6 +61,9 @@ struct _SpiceSessionPrivate {
     /* whether to enable smartcard event forwarding to the server */
     gboolean          smartcard;
 
+    /* whether to enable GL scanout */
+    gboolean          gl_scanout;
+
     /* list of certificates to use for the software smartcard reader if
      * enabled. For now, it has to contain exactly 3 certificates for
      * the software reader to be functional
@@ -191,6 +194,7 @@ enum {
     PROP_USERNAME,
     PROP_UNIX_PATH,
     PROP_PREF_COMPRESSION,
+    PROP_GL_SCANOUT,
 };
 
 /* signals */
@@ -699,6 +703,9 @@ static void spice_session_get_property(GObject    *gobject,
     case PROP_PREF_COMPRESSION:
         g_value_set_enum(value, s->preferred_compression);
         break;
+    case PROP_GL_SCANOUT:
+        g_value_set_boolean(value, s->gl_scanout);
+        break;
     default:
 	G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
 	break;
@@ -838,6 +845,13 @@ static void spice_session_set_property(GObject      *gobject,
     case PROP_PREF_COMPRESSION:
         s->preferred_compression = g_value_get_enum(value);
         break;
+    case PROP_GL_SCANOUT:
+#ifdef G_OS_UNIX
+        s->gl_scanout = g_value_get_boolean(value);
+#else
+        g_warning("SpiceSession:gl-scanout is only available on Unix");
+#endif
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
         break;
@@ -1478,6 +1492,35 @@ static void spice_session_class_init(SpiceSessionClass *klass)
                            SPICE_IMAGE_COMPRESSION_INVALID,
                            G_PARAM_READWRITE |
                            G_PARAM_STATIC_STRINGS));
+
+    /**
+     * SpiceSession:gl-scanout:
+     *
+     * Whether to enable gl-scanout (Unix only).  Set to TRUE by
+     * default on EGL-enabled host, unless SPICE_DISABLE_GL_SCANOUT
+     * environment variable is set.
+     *
+     * Since: 0.36
+     **/
+    g_object_class_install_property
+        (gobject_class, PROP_GL_SCANOUT,
+         g_param_spec_boolean("gl-scanout",
+                              "Enable GL scanout support",
+                              "Enable GL scanout support",
+#ifdef HAVE_EGL
+                              g_getenv("SPICE_DISABLE_GL_SCANOUT") == NULL,
+                              G_PARAM_CONSTRUCT |
+#else
+                              false,
+#endif
+                              G_PARAM_READWRITE |
+                              G_PARAM_STATIC_STRINGS));
+}
+
+G_GNUC_INTERNAL
+gboolean spice_session_get_gl_scanout_enabled(SpiceSession *session)
+{
+    return session->priv->gl_scanout;
 }
 
 /* ------------------------------------------------------------------ */
-- 
2.20.1.2.gb21ebb671b



More information about the Spice-devel mailing list