summaryrefslogtreecommitdiffstats
path: root/opengl/libagl
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2013-03-07 09:56:26 -0800
committerJesse Hall <jessehall@google.com>2013-03-07 15:10:59 -0800
commit78141e3acc9913153883fa337a0f3a5eff7acc64 (patch)
treef7ca231a3a44bedbe4a1f9e5d775bc72506e69a3 /opengl/libagl
parent84b470d78f10b6fbfbf84edba749e5f7f315fc3a (diff)
downloadframeworks_native-78141e3acc9913153883fa337a0f3a5eff7acc64.zip
frameworks_native-78141e3acc9913153883fa337a0f3a5eff7acc64.tar.gz
frameworks_native-78141e3acc9913153883fa337a0f3a5eff7acc64.tar.bz2
Defer destroying surfaces until not current
Bug: 8320762 Change-Id: I1320cf87923bcc5b795a86a13193363a49e29653
Diffstat (limited to 'opengl/libagl')
-rw-r--r--opengl/libagl/egl.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 172ef95..bc1cf36 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -147,6 +147,7 @@ struct egl_surface_t
EGLDisplay dpy;
EGLConfig config;
EGLContext ctx;
+ bool zombie;
egl_surface_t(EGLDisplay dpy, EGLConfig config, int32_t depthFormat);
virtual ~egl_surface_t();
@@ -173,7 +174,7 @@ protected:
egl_surface_t::egl_surface_t(EGLDisplay dpy,
EGLConfig config,
int32_t depthFormat)
- : magic(MAGIC), dpy(dpy), config(config), ctx(0)
+ : magic(MAGIC), dpy(dpy), config(config), ctx(0), zombie(false)
{
depth.version = sizeof(GGLSurface);
depth.data = 0;
@@ -1580,11 +1581,12 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface eglSurface)
if (surface->dpy != dpy)
return setError(EGL_BAD_DISPLAY, EGL_FALSE);
if (surface->ctx) {
- // FIXME: this surface is current check what the spec says
+ // defer disconnect/delete until no longer current
+ surface->zombie = true;
+ } else {
surface->disconnect();
- surface->ctx = 0;
+ delete surface;
}
- delete surface;
}
return EGL_TRUE;
}
@@ -1736,6 +1738,9 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
if (c->draw) {
egl_surface_t* s = reinterpret_cast<egl_surface_t*>(c->draw);
s->disconnect();
+ s->ctx = EGL_NO_CONTEXT;
+ if (s->zombie)
+ delete s;
}
if (c->read) {
// FIXME: unlock/disconnect the read surface too
@@ -1777,8 +1782,10 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
egl_surface_t* r = (egl_surface_t*)c->read;
if (d) {
c->draw = 0;
- d->ctx = EGL_NO_CONTEXT;
d->disconnect();
+ d->ctx = EGL_NO_CONTEXT;
+ if (d->zombie)
+ delete d;
}
if (r) {
c->read = 0;