diff options
author | Chad Versace <chadversary@chromium.org> | 2018-04-07 13:01:15 -0700 |
---|---|---|
committer | Chad Versace <chadversary@chromium.org> | 2018-05-01 03:15:42 -0700 |
commit | 0d7eae584741b54e204a58b87fd84b791932056b (patch) | |
tree | a2fc0b969e23f09d09bb55d0bb908a80fbf29e84 /src | |
parent | 3e8d93e1ff3b72d9754a4aa55291669f8e442fe6 (diff) |
CHROMIUM: egl/dri2: In dri2_make_current, return early on failure
This pulls an 'else' block into the function's main body, making the
code easier to follow.
Without this change, the upcoming EGL_KHR_mutable_render_buffer patch
transforms dri2_make_current() into spaghetti.
BUG=b:77899911
TEST=No android-cts-7.1 regressions on Eve.
Change-Id: I26be2b7a8e78a162dcd867a44f62d6f48b9a8e4d
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 4e4dc3270cd..cd0925f1822 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1549,20 +1549,7 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, unbind = (cctx == NULL && ddraw == NULL && rdraw == NULL); - if (unbind || dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) { - dri2_destroy_surface(drv, disp, old_dsurf); - dri2_destroy_surface(drv, disp, old_rsurf); - - 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); - } - - return EGL_TRUE; - } else { + if (!unbind && !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 && @@ -1583,6 +1570,20 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, */ return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); } + + dri2_destroy_surface(drv, disp, old_dsurf); + dri2_destroy_surface(drv, disp, old_rsurf); + + 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); + } + + return EGL_TRUE; } __DRIdrawable * |