free EGL resources associated to a thread when it terminates

destroyed but current-to-a-thread resources are only destroyed
when they're made not-current; however, we were not destroying
those when the thread itself terminated, causing these resources
to be leaked forever.

we now install a tls-key destructor that takes care of this
by calling eglReleaseThread upon thread termination.

Bug: 9209776
Change-Id: I88298a34e3a27488eb81eab76717715569c7d57c
diff --git a/opengl/libs/EGL/egl_tls.h b/opengl/libs/EGL/egl_tls.h
index 56c5dba..5af4f5b 100644
--- a/opengl/libs/EGL/egl_tls.h
+++ b/opengl/libs/EGL/egl_tls.h
@@ -30,8 +30,9 @@
 class DbgContext;
 
 class egl_tls_t {
+    enum { TLS_KEY_NOT_INITIALIZED = -1 };
     static pthread_key_t sKey;
-    static pthread_mutex_t sLockKey;
+    static pthread_once_t sOnceKey;
 
     EGLint      error;
     EGLContext  ctx;