From 7de41f1bf73cc7fe2a193293873a6f418a735369 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Wed, 24 Aug 2011 14:54:56 -0700 Subject: [PATCH] EGL: move disconnect to surface dtor This change moves the call to native_window_api_disconnect from eglDestroySurface to the egl_surface_t destructor. The egl_surface_t can outlive the external EGLSurface if eglDestroySurface is called while the surface is made current on a thread. Change-Id: I0df6117a5633c2a19935fe356579abdd76fc471f --- opengl/libs/EGL/eglApi.cpp | 7 ------- opengl/libs/EGL/egl_object.h | 11 +++++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 10cea22bbdd52..1f0016ab17319 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -454,13 +454,6 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) EGLBoolean result = s->cnx->egl.eglDestroySurface( dp->disp[s->impl].dpy, s->surface); if (result == EGL_TRUE) { - ANativeWindow* const window = s->win.get(); - if (window != NULL) { - native_window_set_buffers_format(window, 0); - if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) { - LOGE("EGLNativeWindowType %p disconnected failed", window); - } - } _s.terminate(); } return result; diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h index 3459a8a8de3ef..d2b737897af73 100644 --- a/opengl/libs/EGL/egl_object.h +++ b/opengl/libs/EGL/egl_object.h @@ -125,7 +125,15 @@ void egl_object_t::LocalRef::terminate() { class egl_surface_t: public egl_object_t { protected: - ~egl_surface_t() {} + ~egl_surface_t() { + ANativeWindow* const window = win.get(); + if (window != NULL) { + native_window_set_buffers_format(window, 0); + if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) { + LOGE("EGLNativeWindowType %p disconnected failed", window); + } + } + } public: typedef egl_object_t::LocalRef Ref; @@ -232,4 +240,3 @@ egl_sync_t* get_sync(EGLSyncKHR sync) { // ---------------------------------------------------------------------------- #endif // ANDROID_EGL_OBJECT_H -