diff options
Diffstat (limited to 'opengl/libs/EGL/egl_object.cpp')
-rw-r--r-- | opengl/libs/EGL/egl_object.cpp | 27 |
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); } // ---------------------------------------------------------------------------- |