mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-03 07:48:04 +02:00
[gl] Handle an absent visual.
If we cannot find the correct visual for the fbconfig, return an error instead of crashing. The difference is subtle, granted.
This commit is contained in:
parent
e74cb7fa3e
commit
30f45ce5f7
2 changed files with 12 additions and 3 deletions
|
|
@ -61,6 +61,11 @@ static const cairo_gl_context_t _nil_context = {
|
|||
CAIRO_STATUS_NO_MEMORY
|
||||
};
|
||||
|
||||
static const cairo_gl_context_t _nil_context__invalid_format = {
|
||||
CAIRO_REFERENCE_COUNT_INVALID,
|
||||
CAIRO_STATUS_INVALID_FORMAT
|
||||
};
|
||||
|
||||
static cairo_bool_t _cairo_surface_is_gl (cairo_surface_t *surface)
|
||||
{
|
||||
return surface->backend == &_cairo_gl_surface_backend;
|
||||
|
|
@ -72,6 +77,9 @@ _cairo_gl_context_create_in_error (cairo_status_t status)
|
|||
if (status == CAIRO_STATUS_NO_MEMORY)
|
||||
return (cairo_gl_context_t *) &_nil_context;
|
||||
|
||||
if (status == CAIRO_STATUS_INVALID_FORMAT)
|
||||
return (cairo_gl_context_t *) &_nil_context__invalid_format;
|
||||
|
||||
ASSERT_NOT_REACHED;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,8 +99,6 @@ _glx_dummy_ctx (Display *dpy, GLXContext gl_ctx, Window *dummy)
|
|||
Window win = None;
|
||||
int cnt;
|
||||
|
||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
/* Create a dummy window created for the target GLX context that we can
|
||||
* use to query the available GL/GLX extensions.
|
||||
*/
|
||||
|
|
@ -114,6 +112,9 @@ _glx_dummy_ctx (Display *dpy, GLXContext gl_ctx, Window *dummy)
|
|||
vi = glXGetVisualFromFBConfig (dpy, config[0]);
|
||||
XFree (config);
|
||||
|
||||
if (unlikely (vi == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
|
||||
|
||||
cmap = XCreateColormap (dpy,
|
||||
RootWindow (dpy, vi->screen),
|
||||
vi->visual,
|
||||
|
|
@ -136,7 +137,7 @@ _glx_dummy_ctx (Display *dpy, GLXContext gl_ctx, Window *dummy)
|
|||
}
|
||||
|
||||
*dummy = win;
|
||||
return status;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_gl_context_t *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue