summaryrefslogtreecommitdiff
path: root/opengl/libs/EGL/egl_object.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_object.cpp
parent7adf4ef0fad9973d9a07f2a73b2c4238c8e6bf7c (diff)
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_object.cpp')
-rw-r--r--opengl/libs/EGL/egl_object.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index d4df3415cbad..dbf9a010e0be 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -32,16 +32,33 @@ namespace android {
// ----------------------------------------------------------------------------
egl_object_t::egl_object_t(egl_display_t* disp) :
- display(disp), terminated(0), count(1) {
+ display(disp), count(1) {
+ // NOTE: this does an implicit incRef
display->addObject(this);
}
-bool egl_object_t::get() {
- return display->getObject(this);
+egl_object_t::~egl_object_t() {
+}
+
+void egl_object_t::terminate() {
+ // this marks the object as "terminated"
+ display->removeObject(this);
+ if (decRef() == 1) {
+ // shouldn't happen because this is called from LocalRef
+ LOGE("egl_object_t::terminate() removed the last reference!");
+ }
}
-bool egl_object_t::put() {
- return display->removeObject(this);
+void egl_object_t::destroy() {
+ if (decRef() == 1) {
+ delete this;
+ }
+}
+
+bool egl_object_t::get() {
+ // used by LocalRef, this does an incRef() atomically with
+ // checking that the object is valid.
+ return display->getObject(this);
}
// ----------------------------------------------------------------------------