[Spice-devel] [PATCH spice-gtk 2/7] egl: check context is ready
Marc-André Lureau
marcandre.lureau at gmail.com
Mon Mar 21 18:14:44 UTC 2016
Add a new GL status field to check if the GL context is ready. This
helps debugging races where GL is called before the context is ready.
Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
---
src/spice-widget-egl.c | 7 ++++++-
src/spice-widget-priv.h | 1 +
src/spice-widget.c | 5 +++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
index a9bea52..338bb3d 100644
--- a/src/spice-widget-egl.c
+++ b/src/spice-widget-egl.c
@@ -267,7 +267,12 @@ gboolean spice_egl_init(SpiceDisplay *display, GError **err)
eglMakeCurrent(d->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE,
d->egl.ctx);
- return spice_egl_init_shaders(display, err);
+ if (!spice_egl_init_shaders(display, err))
+ return FALSE;
+
+ d->egl.context_ready = TRUE;
+
+ return TRUE;
}
static gboolean spice_widget_init_egl_win(SpiceDisplay *display, GdkWindow *win,
diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 2f7e39e..bafeb7d 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -129,6 +129,7 @@ struct _SpiceDisplayPrivate {
#endif
#ifndef G_OS_WIN32
struct {
+ gboolean context_ready;
gboolean enabled;
EGLSurface surface;
EGLDisplay display;
diff --git a/src/spice-widget.c b/src/spice-widget.c
index c8bb72c..f2ba62d 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2486,6 +2486,8 @@ static void gl_scanout(SpiceDisplay *display)
const SpiceGlScanout *scanout;
GError *err = NULL;
+ g_return_if_fail(d->egl.context_ready);
+
scanout = spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display));
g_return_if_fail(scanout != NULL);
@@ -2504,6 +2506,9 @@ static void gl_draw(SpiceDisplay *display,
SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("%s", __FUNCTION__);
+
+ g_return_if_fail(d->egl.context_ready);
+
set_egl_enabled(display, true);
#if GTK_CHECK_VERSION(3,16,0)
--
2.5.0
More information about the Spice-devel
mailing list