Mesa (staging/20.1): dri2: dri2_make_current() fold multiple if blocks
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 21 21:34:58 UTC 2020
Module: Mesa
Branch: staging/20.1
Commit: bf9c867181420f64ad9f15973414cf628dd67888
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf9c867181420f64ad9f15973414cf628dd67888
Author: Luigi Santivetti <luigi.santivetti at imgtec.com>
Date: Tue Jun 30 10:14:08 2020 +0100
dri2: dri2_make_current() fold multiple if blocks
dri2_make_current() has become long and convoluted. Address
this by folding together multiple if blocks checking for the
same variable.
Cc: mesa-stable
Signed-off-by: Luigi Santivetti <luigi.santivetti at imgtec.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5707>
(cherry picked from commit 6b12999ef7c5b754df0919cdc9e354d58abbc4fb)
---
.pick_status.json | 2 +-
src/egl/drivers/dri2/egl_dri2.c | 21 +++++++--------------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 48acd98575a..5833165c5b6 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -85,7 +85,7 @@
"description": "dri2: dri2_make_current() fold multiple if blocks",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2e51d28a8b9..fd27f1d7776 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1772,28 +1772,18 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
if (!dri2_dpy)
return _eglError(EGL_NOT_INITIALIZED, "eglMakeCurrent");
- /* make new bindings */
- if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf)) {
- /* _eglBindContext already sets the EGL error (in _eglCheckMakeCurrent) */
+ /* make new bindings, set the EGL error otherwise */
+ if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf))
return EGL_FALSE;
- }
if (old_ctx) {
+ __DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context;
old_disp = old_ctx->Resource.Display;
old_dri2_dpy = dri2_egl_display(old_disp);
- }
- /* flush before context switch */
- if (old_ctx)
+ /* flush before context switch */
dri2_gl_flush();
- 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;
-
if (old_dsurf)
dri2_surf_update_fence_fd(old_ctx, disp, old_dsurf);
@@ -1806,6 +1796,9 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
dri2_dpy->core->unbindContext(old_cctx);
}
+ 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;
unbind = (cctx == NULL && ddraw == NULL && rdraw == NULL);
if (!unbind && !dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
More information about the mesa-commit
mailing list