summaryrefslogtreecommitdiffstats
path: root/opengl/libs/EGL/egl.cpp
diff options
context:
space:
mode:
authorJack Palevich <jackpal@google.com>2010-03-15 20:45:21 -0700
committerJack Palevich <jackpal@google.com>2010-03-15 21:21:51 -0700
commit0a41c3c706c7238f8de0382d1bb4f019194e9bc1 (patch)
tree2dad5635265355f7fe3d6adb5c6d7bc8134c42f2 /opengl/libs/EGL/egl.cpp
parent650e22ca3a97501e12f4befb80f2cd5b39ea78bc (diff)
downloadframeworks_base-0a41c3c706c7238f8de0382d1bb4f019194e9bc1.zip
frameworks_base-0a41c3c706c7238f8de0382d1bb4f019194e9bc1.tar.gz
frameworks_base-0a41c3c706c7238f8de0382d1bb4f019194e9bc1.tar.bz2
Implement eglInitialize / eglTerminate reference counting
Previously we imlpemented the standard semantics for eglInitialize / eglTerminate, which are that eglInitialize may be called any number of times, but the first call to eglTerminate will terminate the display. Now we follow reference-countins semantics, which means that eglTerminate will only terminate the display when the reference count returns to zero. This change allows EGL to be used by multiple independently written modules in the same process. (Otherwise there is no way for the independent modules to coordinate their use of the display.)
Diffstat (limited to 'opengl/libs/EGL/egl.cpp')
-rw-r--r--opengl/libs/EGL/egl.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index 145e25e..89b3e1f 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -650,6 +650,7 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
if (dp->refs > 0) {
if (major != NULL) *major = VERSION_MAJOR;
if (minor != NULL) *minor = VERSION_MINOR;
+ dp->refs++;
return EGL_TRUE;
}
@@ -755,8 +756,10 @@ EGLBoolean eglTerminate(EGLDisplay dpy)
}
// this is specific to Android, display termination is ref-counted.
- if (dp->refs > 1)
+ if (dp->refs > 1) {
+ dp->refs--;
return EGL_TRUE;
+ }
EGLBoolean res = EGL_FALSE;
for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {