From 69383107ea337a50d2c032f8f2c78ed99a4f06d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 24 May 2016 21:23:20 +0200 Subject: [PATCH] egl: fix delayed widget realize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the display is not yet realized, spice_display_widget_gl_scanout() will fail because the egl context is not ready. The display is never marked ready because the egl.image (and egl.scanout) is not set, and some clients, such as virt-viewer will not realize the widget until the display is ready. Deal with gl scanout updates when the widget is not yet realized, and mark the display as ready when egl is enabled (when last display draw signal is from gl). Signed-off-by: Marc-André Lureau Acked-by: Pavel Grunt --- src/spice-widget.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/spice-widget.c b/src/spice-widget.c index f13a066..9a4b204 100644 --- a/src/spice-widget.c +++ b/src/spice-widget.c @@ -238,7 +238,7 @@ static void update_ready(SpiceDisplay *display) if (d->monitor_ready) { #ifndef G_OS_WIN32 - ready = d->egl.enabled ? d->egl.image != NULL : d->mark != 0; + ready = d->egl.enabled || d->mark != 0; #else ready = d->mark != 0; #endif @@ -2296,9 +2296,12 @@ static void update_area(SpiceDisplay *display, #ifndef G_OS_WIN32 if (d->egl.enabled) { + const SpiceGlScanout *so = + spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display)); + g_return_if_fail(so != NULL); primary = (GdkRectangle) { - .width = d->egl.scanout.width, - .height = d->egl.scanout.height + .width = so->width, + .height = so->height }; } else #endif @@ -2611,21 +2614,22 @@ G_GNUC_INTERNAL void spice_display_widget_gl_scanout(SpiceDisplay *display) { SpiceDisplayPrivate *d = display->priv; - const SpiceGlScanout *scanout; - GError *err = NULL; SPICE_DEBUG("%s: got scanout", __FUNCTION__); set_egl_enabled(display, true); - g_return_if_fail(d->egl.context_ready); + if (d->egl.context_ready) { + const SpiceGlScanout *scanout; + GError *err = NULL; - scanout = spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display)); - /* should only be called when the display has a scanout */ - g_return_if_fail(scanout != NULL); + scanout = spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display)); + /* should only be called when the display has a scanout */ + g_return_if_fail(scanout != NULL); - if (!spice_egl_update_scanout(display, scanout, &err)) { - g_critical("update scanout failed: %s", err->message); - g_clear_error(&err); + if (!spice_egl_update_scanout(display, scanout, &err)) { + g_critical("update scanout failed: %s", err->message); + g_clear_error(&err); + } } }