summaryrefslogtreecommitdiffstats
path: root/opengl/libs/EGL/egl_display.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-05-16 18:58:55 -0700
committerMathias Agopian <mathias@google.com>2011-05-16 19:03:33 -0700
commitf1e4e06319ef461997eefe45be716ad954defcb1 (patch)
tree5e42ec880e9320312b3feae7c37867284d16cb2a /opengl/libs/EGL/egl_display.cpp
parent7adf4ef0fad9973d9a07f2a73b2c4238c8e6bf7c (diff)
downloadframeworks_base-f1e4e06319ef461997eefe45be716ad954defcb1.zip
frameworks_base-f1e4e06319ef461997eefe45be716ad954defcb1.tar.gz
frameworks_base-f1e4e06319ef461997eefe45be716ad954defcb1.tar.bz2
eglTerminate() now actually frees up all active egl objects
as specified by the EGL specification, terminated objects's handles become invalid, the objects themselves are destroyed when they're not current to some thread. Change-Id: Id3a4a5736a5bbc3926a9ae8385d43772edb88eeb
Diffstat (limited to 'opengl/libs/EGL/egl_display.cpp')
-rw-r--r--opengl/libs/EGL/egl_display.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 272fa44..83aafa6 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -55,19 +55,15 @@ void egl_display_t::addObject(egl_object_t* object) {
objects.add(object);
}
-bool egl_display_t::getObject(egl_object_t* object) {
+void egl_display_t::removeObject(egl_object_t* object) {
Mutex::Autolock _l(lock);
- if (objects.indexOf(object) >= 0) {
- object->incRef();
- return true;
- }
- return false;
+ objects.remove(object);
}
-bool egl_display_t::removeObject(egl_object_t* object) {
+bool egl_display_t::getObject(egl_object_t* object) {
Mutex::Autolock _l(lock);
- if (object->decRef() == 1) {
- objects.remove(object);
+ if (objects.indexOf(object) >= 0) {
+ object->incRef();
return true;
}
return false;
@@ -255,7 +251,18 @@ EGLBoolean egl_display_t::terminate() {
}
}
- // TODO: all egl_object_t should be marked for termination
+ // Mark all objects remaining in the list as terminated, unless
+ // there are no reference to them, it which case, we're free to
+ // delete them.
+ size_t count = objects.size();
+ LOGW_IF(count, "eglTerminate() called w/ %d objects remaining", count);
+ for (size_t i=0 ; i<count ; i++) {
+ egl_object_t* o = objects.itemAt(i);
+ o->destroy();
+ }
+
+ // this marks all object handles are "terminated"
+ objects.clear();
refs--;
numTotalConfigs = 0;