Merge "egl: handle failed eglMakeCurrent EGL_NO_CONTEXT" into oc-dev
am: 2153f5e317
Change-Id: I6c36e59dc595bd6a494561a49b98b0f2d479ecfe
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 10f4e66..ba3a5f9 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -829,19 +829,15 @@
egl_tls_t::setContext(EGL_NO_CONTEXT);
}
} else {
- // 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) {
+ // 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,13 +853,13 @@
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();
- _d2.acquire();
- } else {
- ALOGE("Could not restore original EGL context");
+ if (restore_result == EGL_TRUE) {
+ _c2.acquire();
+ _r2.acquire();
+ _d2.acquire();
+ } else {
+ ALOGE("Could not restore original EGL context");
+ }
}
// this will ALOGE the error
egl_connection_t* const cnx = &gEGLImpl;