Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47e741bd authored by Mike Stroyan's avatar Mike Stroyan
Browse files

egl: handle failed eglMakeCurrent EGL_NO_CONTEXT

The recovery code for failed eglMakeCurrent didn't correctly
handle the case when the previous context was EGL_NO_CONTEXT.
Leave the original EGL context unrestored in that case.
The driver should be able to handle that case without help.

Bug: 38341617, 37244059
Change-Id: I38f3450005a4eec5f1a684ee7d66363e88f6d92f
Fixes: 38341617
Test: android.server.cts.ActivityManagerDisplayTests, Run Minions Rush app.
parent 1e4088fc
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -829,19 +829,15 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
            egl_tls_t::setContext(EGL_NO_CONTEXT);
        }
    } else {

        if (cur_c != NULL) {
            // Force return to current context for drivers that cannot handle errors
            EGLBoolean restore_result = EGL_FALSE;

            // get a reference to the old current objects
            ContextRef _c2(dp.get(), cur_c);
            SurfaceRef _d2(dp.get(), cur_c->draw);
            SurfaceRef _r2(dp.get(), cur_c->read);

        if (cur_c == NULL) {
            restore_result = dp->makeCurrent(c, cur_c,
                    EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT,
                    EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
        } else {
            c = cur_c;
            impl_ctx = c->context;
            impl_draw = EGL_NO_SURFACE;
@@ -857,7 +853,6 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
            restore_result = dp->makeCurrent(c, cur_c,
                    cur_c->draw, cur_c->read, cur_c->context,
                    impl_draw, impl_read, impl_ctx);
        }
            if (restore_result == EGL_TRUE) {
                _c2.acquire();
                _r2.acquire();
@@ -865,6 +860,7 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
            } else {
                ALOGE("Could not restore original EGL context");
            }
        }
        // this will ALOGE the error
        egl_connection_t* const cnx = &gEGLImpl;
        result = setError(cnx->egl.eglGetError(), (EGLBoolean)EGL_FALSE);