glx: Move error trap even further out

This way we only create one error trap for all attempts to create a
context instead of up to 3.
This commit is contained in:
Benjamin Otte 2023-06-06 04:57:12 +02:00
parent 1e60ad1430
commit 14e44f36bf

View File

@ -543,8 +543,6 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
if (share != NULL)
share_glx = GDK_X11_GL_CONTEXT_GLX (share);
gdk_x11_display_error_trap_push (display);
supported_versions = gdk_gl_versions_get_for_api (api);
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
{
@ -572,8 +570,6 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
break;
}
gdk_x11_display_error_trap_pop_ignored (display);
if (ctx == NULL)
{
GDK_DISPLAY_DEBUG (display, OPENGL, "Failed to create a GLX context");
@ -660,25 +656,35 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
if (share != NULL && gdk_gl_context_is_legacy (share))
legacy = TRUE;
gdk_x11_display_error_trap_push (display);
if (preferred_api == GDK_GL_API_GL)
{
if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) ||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy)) ||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE)))
return api;
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy);
if (api == 0)
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy);
if (api == 0)
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE);
}
else
{
if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE)) ||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) ||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE)))
return api;
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE);
if (api == 0)
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy);
if (api == 0)
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE);
}
gdk_x11_display_error_trap_pop_ignored (display);
if (api == 0)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("Unable to create a GL context"));
return 0;
}
return api;
}
#undef N_GLX_ATTRS