return GDK_GL_CONTEXT (GSIZE_TO_POINTER (GPOINTER_TO_SIZE (mask) & ~(gsize) 1));
}
+static inline gboolean
+mask_is_surfaceless (MaskedContext *mask)
+{
+ return GPOINTER_TO_SIZE (mask) & (gsize) 1;
+}
+
static void
unref_unmasked (gpointer data)
{
}
}
+/*<private>
+ * gdk_gl_context_clear_current_if_surface:
+ * @surface: surface to clear for
+ *
+ * Does a gdk_gl_context_clear_current() if the current context is attached
+ * to @surface, leaves the current context alone otherwise.
+ **/
+void
+gdk_gl_context_clear_current_if_surface (GdkSurface *surface)
+{
+ MaskedContext *current;
+
+ current = g_private_get (&thread_current_context);
+ if (current != NULL && !mask_is_surfaceless (current))
+ {
+ GdkGLContext *context = unmask_context (current);
+
+ if (gdk_gl_context_get_surface (context) != surface)
+ return;
+
+ if (GDK_GL_CONTEXT_GET_CLASS (context)->clear_current (context))
+ g_private_replace (&thread_current_context, NULL);
+ }
+}
+
/**
* gdk_gl_context_get_current:
*
GError **error);
void gdk_gl_backend_use (GdkGLBackend backend_type);
+void gdk_gl_context_clear_current_if_surface (GdkSurface *surface);
+
GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
GdkSurface *surface);
if (priv->egl_surface != NULL)
{
+ gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_surface_get_display (self), priv->egl_surface);
priv->egl_surface = NULL;
}
priv->egl_surface != NULL &&
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
{
+ gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_surface_get_display (self), priv->egl_surface);
priv->egl_surface = NULL;
}
if (self->glx_drawable == None)
return;
+ gdk_gl_context_clear_current_if_surface (GDK_SURFACE (self));
+
glXDestroyWindow (gdk_x11_display_get_xdisplay (gdk_surface_get_display (GDK_SURFACE (self))),
self->glx_drawable);