summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2016-10-14 16:07:33 +0100
committerEmil Velikov <[email protected]>2016-10-14 16:07:33 +0100
commitebffa7b6af879d9475b2e9de9b7fa03e65fda6a8 (patch)
treea8fa8ed11741ce5fe7e752c93ff130496d4de298 /src/egl
parent6eacd69b6fc9b09f08cbb687369cf1c92947e0b2 (diff)
Revert "egl/dri2: rework dri2_make_current code flow"
This reverts commit 675719817e7bf7c5b9da22c02252aca77a41338d.
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index c8dfa072be9..8785e31cb6a 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1259,11 +1259,11 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
_EGLContext *old_ctx;
- _EGLDisplay *old_disp = NULL;
_EGLSurface *old_dsurf, *old_rsurf;
_EGLSurface *tmp_dsurf, *tmp_rsurf;
__DRIdrawable *ddraw, *rdraw;
__DRIcontext *cctx;
+ EGLBoolean unbind;
if (!dri2_dpy)
return _eglError(EGL_NOT_INITIALIZED, "eglMakeCurrent");
@@ -1274,55 +1274,55 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
return EGL_FALSE;
}
+ /* flush before context switch */
+ if (old_ctx)
+ dri2_drv->glFlush();
+
ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
if (old_ctx) {
__DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context;
-
- /* flush before context switch */
- dri2_drv->glFlush();
dri2_dpy->core->unbindContext(old_cctx);
-
- /* Keep track of the old dpy as we'll need it for resource cleanup */
- old_disp = old_ctx->Resource.Display;
}
- /* Bind if at least one of the primitives is valid ... */
- if (cctx || ddraw || rdraw) {
- if (dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
- /* undo the previous _eglBindContext */
- _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf);
- assert(&dri2_ctx->base == ctx &&
- tmp_dsurf == dsurf &&
- tmp_rsurf == rsurf);
-
- _eglPutSurface(dsurf);
- _eglPutSurface(rsurf);
- _eglPutContext(ctx);
+ unbind = (cctx == NULL && ddraw == NULL && rdraw == NULL);
- _eglPutSurface(old_dsurf);
- _eglPutSurface(old_rsurf);
- _eglPutContext(old_ctx);
+ if (unbind || dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
+ dri2_destroy_surface(drv, disp, old_dsurf);
+ dri2_destroy_surface(drv, disp, old_rsurf);
- /* dri2_dpy->core->bindContext failed. We cannot tell for sure why, but
- * setting the error to EGL_BAD_MATCH is surely better than leaving it
- * as EGL_SUCCESS.
- */
- return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
+ if (!unbind)
+ dri2_dpy->ref_count++;
+ if (old_ctx) {
+ EGLDisplay old_disp = _eglGetDisplayHandle(old_ctx->Resource.Display);
+ dri2_destroy_context(drv, disp, old_ctx);
+ dri2_display_release(old_disp);
}
- /* ... and refcount the dpy when successful. */
- dri2_dpy->ref_count++;
+ return EGL_TRUE;
+ } else {
+ /* undo the previous _eglBindContext */
+ _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf);
+ assert(&dri2_ctx->base == ctx &&
+ tmp_dsurf == dsurf &&
+ tmp_rsurf == rsurf);
+
+ _eglPutSurface(dsurf);
+ _eglPutSurface(rsurf);
+ _eglPutContext(ctx);
+
+ _eglPutSurface(old_dsurf);
+ _eglPutSurface(old_rsurf);
+ _eglPutContext(old_ctx);
+
+ /* dri2_dpy->core->bindContext failed. We cannot tell for sure why, but
+ * setting the error to EGL_BAD_MATCH is surely better than leaving it
+ * as EGL_SUCCESS.
+ */
+ return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
}
-
- dri2_destroy_surface(drv, disp, old_dsurf);
- dri2_destroy_surface(drv, disp, old_rsurf);
- dri2_destroy_context(drv, disp, old_ctx);
- dri2_display_release(old_disp);
-
- return EGL_TRUE;
}
__DRIdrawable *