Don't bother trying to accept NULL in _cogl_winsys_onscreen_bind

The GLX and EGL winsys backends had a check for when onscreen==NULL
in which case they would instead try to bind the dummy surface. This
wouldn't work however because it would have already crashed by that
point when it tried to get the Cogl context out of the onscreen. The
function needs a bit of refactoring before it could support this but
presumably nothing is relying on this anyway because it wouldn't work
so for now we can just remove it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2011-12-12 15:03:18 +00:00
parent 7f74712a79
commit a72a2c99fe
2 changed files with 50 additions and 85 deletions

View File

@ -1507,28 +1507,11 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
if (egl_context->current_surface == egl_onscreen->egl_surface)
return;
if (G_UNLIKELY (!onscreen))
{
if (renderer->winsys_vtable->id == COGL_WINSYS_ID_EGL_X11 ||
renderer->winsys_vtable->id == COGL_WINSYS_ID_EGL_WAYLAND)
{
eglMakeCurrent (egl_renderer->edpy,
egl_display->dummy_surface,
egl_display->dummy_surface,
egl_display->egl_context);
egl_context->current_surface = egl_display->dummy_surface;
}
else
return;
}
else
{
eglMakeCurrent (egl_renderer->edpy,
egl_onscreen->egl_surface,
egl_onscreen->egl_surface,
egl_display->egl_context);
egl_context->current_surface = egl_onscreen->egl_surface;
}
eglMakeCurrent (egl_renderer->edpy,
egl_onscreen->egl_surface,
egl_onscreen->egl_surface,
egl_display->egl_context);
egl_context->current_surface = egl_onscreen->egl_surface;
if (onscreen->swap_throttled)
eglSwapInterval (egl_renderer->edpy, 1);

View File

@ -1034,70 +1034,52 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
CoglXlibTrapState old_state;
GLXDrawable drawable;
if (G_UNLIKELY (!onscreen))
drawable =
glx_onscreen->glxwin ? glx_onscreen->glxwin : xlib_onscreen->xwin;
if (glx_context->current_drawable == drawable)
return;
_cogl_xlib_renderer_trap_errors (context->display->renderer, &old_state);
COGL_NOTE (WINSYS,
"MakeContextCurrent dpy: %p, window: 0x%x (%s), context: %p",
xlib_renderer->xdpy,
(unsigned int) drawable,
xlib_onscreen->is_foreign_xwin ? "foreign" : "native",
glx_display->glx_context);
glx_renderer->glXMakeContextCurrent (xlib_renderer->xdpy,
drawable,
drawable,
glx_display->glx_context);
/* In case we are using GLX_SGI_swap_control for vblank syncing
* we need call glXSwapIntervalSGI here to make sure that it
* affects the current drawable.
*
* Note: we explicitly set to 0 when we aren't using the swap
* interval to synchronize since some drivers have a default
* swap interval of 1. Sadly some drivers even ignore requests
* to disable the swap interval.
*
* NB: glXSwapIntervalSGI applies to the context not the
* drawable which is why we can't just do this once when the
* framebuffer is allocated.
*
* FIXME: We should check for GLX_EXT_swap_control which allows
* per framebuffer swap intervals. GLX_MESA_swap_control also
* allows per-framebuffer swap intervals but the semantics tend
* to be more muddled since Mesa drivers tend to expose both the
* MESA and SGI extensions which should technically be mutually
* exclusive.
*/
if (glx_renderer->pf_glXSwapInterval)
{
drawable =
glx_display->dummy_glxwin ?
glx_display->dummy_glxwin : glx_display->dummy_xwin;
if (glx_context->current_drawable == drawable)
return;
_cogl_xlib_renderer_trap_errors (context->display->renderer, &old_state);
glx_renderer->glXMakeContextCurrent (xlib_renderer->xdpy,
drawable, drawable,
glx_display->glx_context);
}
else
{
drawable =
glx_onscreen->glxwin ? glx_onscreen->glxwin : xlib_onscreen->xwin;
if (glx_context->current_drawable == drawable)
return;
_cogl_xlib_renderer_trap_errors (context->display->renderer, &old_state);
COGL_NOTE (WINSYS,
"MakeContextCurrent dpy: %p, window: 0x%x (%s), context: %p",
xlib_renderer->xdpy,
(unsigned int) drawable,
xlib_onscreen->is_foreign_xwin ? "foreign" : "native",
glx_display->glx_context);
glx_renderer->glXMakeContextCurrent (xlib_renderer->xdpy,
drawable,
drawable,
glx_display->glx_context);
/* In case we are using GLX_SGI_swap_control for vblank syncing
* we need call glXSwapIntervalSGI here to make sure that it
* affects the current drawable.
*
* Note: we explicitly set to 0 when we aren't using the swap
* interval to synchronize since some drivers have a default
* swap interval of 1. Sadly some drivers even ignore requests
* to disable the swap interval.
*
* NB: glXSwapIntervalSGI applies to the context not the
* drawable which is why we can't just do this once when the
* framebuffer is allocated.
*
* FIXME: We should check for GLX_EXT_swap_control which allows
* per framebuffer swap intervals. GLX_MESA_swap_control also
* allows per-framebuffer swap intervals but the semantics tend
* to be more muddled since Mesa drivers tend to expose both the
* MESA and SGI extensions which should technically be mutually
* exclusive.
*/
if (glx_renderer->pf_glXSwapInterval)
{
if (onscreen->swap_throttled)
glx_renderer->pf_glXSwapInterval (1);
else
glx_renderer->pf_glXSwapInterval (0);
}
if (onscreen->swap_throttled)
glx_renderer->pf_glXSwapInterval (1);
else
glx_renderer->pf_glXSwapInterval (0);
}
XSync (xlib_renderer->xdpy, False);