Internal change

PiperOrigin-RevId: 486792117
This commit is contained in:
Camillo Lugaresi 2022-11-07 16:17:13 -08:00 committed by Copybara-Service
parent 6f38a7a21f
commit 1a151d9ffb

View File

@ -38,20 +38,18 @@ static pthread_key_t egl_release_thread_key;
static pthread_once_t egl_release_key_once = PTHREAD_ONCE_INIT; static pthread_once_t egl_release_key_once = PTHREAD_ONCE_INIT;
static void EglThreadExitCallback(void* key_value) { static void EglThreadExitCallback(void* key_value) {
#if defined(__ANDROID__) EGLDisplay current_display = eglGetCurrentDisplay();
eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, if (current_display != EGL_NO_DISPLAY) {
EGL_NO_CONTEXT); // Some implementations have chosen to allow EGL_NO_DISPLAY as a valid
#else // display parameter for eglMakeCurrent. This behavior is not portable to
// Some implementations have chosen to allow EGL_NO_DISPLAY as a valid display // all EGL implementations, and should be considered as an undocumented
// parameter for eglMakeCurrent. This behavior is not portable to all EGL // vendor extension.
// implementations, and should be considered as an undocumented vendor // https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglMakeCurrent.xhtml
// extension. // Instead, to release the current context, we pass the current display.
// https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglMakeCurrent.xhtml // If the current display is already EGL_NO_DISPLAY, no context is current.
// eglMakeCurrent(current_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
// NOTE: crashes on some Android devices (occurs with libGLES_meow.so). EGL_NO_CONTEXT);
eglMakeCurrent(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_NO_SURFACE, }
EGL_NO_SURFACE, EGL_NO_CONTEXT);
#endif
eglReleaseThread(); eglReleaseThread();
} }