diff options
| author | 2016-10-13 18:09:05 +0000 | |
|---|---|---|
| committer | 2016-10-13 18:09:06 +0000 | |
| commit | 5586d34df6acfafeabdb6bb5cfa4865fc2546d64 (patch) | |
| tree | a62a7f4993d5b1d59c6a9efd9b8cf1fb959a24c1 | |
| parent | 236c475de47a41df4dfab4c2716818dce5c12ffa (diff) | |
| parent | e9cbb659a7c45481444e3d3cbb171fa3251d0cb8 (diff) | |
Merge "Remove EGL Hibernation" into nyc-mr1-dev-plus-aosp
| -rw-r--r-- | opengl/libs/Android.mk | 3 | ||||
| -rw-r--r-- | opengl/libs/EGL/egl_display.cpp | 66 | ||||
| -rw-r--r-- | opengl/libs/EGL/egl_display.h | 79 | ||||
| -rw-r--r-- | opengl/libs/EGL/egl_object.cpp | 7 |
4 files changed, 5 insertions, 150 deletions
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk index f0ba7280db..4f7c7e456f 100644 --- a/opengl/libs/Android.mk +++ b/opengl/libs/Android.mk @@ -42,9 +42,6 @@ LOCAL_CFLAGS += -DLOG_TAG=\"libEGL\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -fvisibility=hidden -ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true) - LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION -endif ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),) LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE) endif diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp index 1e39aae40d..a32f0378be 100644 --- a/opengl/libs/EGL/egl_display.cpp +++ b/opengl/libs/EGL/egl_display.cpp @@ -215,8 +215,6 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { *major = VERSION_MAJOR; if (minor != NULL) *minor = VERSION_MINOR; - - mHibernation.setDisplayValid(true); } { @@ -265,8 +263,6 @@ EGLBoolean egl_display_t::terminate() { res = EGL_TRUE; } - mHibernation.setDisplayValid(false); - // Reset the extension string since it will be regenerated if we get // reinitialized. mExtensionString.setTo(""); @@ -345,16 +341,12 @@ EGLBoolean egl_display_t::makeCurrent(egl_context_t* c, egl_context_t* cur_c, disp.dpy, impl_draw, impl_read, impl_ctx); if (result == EGL_TRUE) { c->onMakeCurrent(draw, read); - if (!cur_c) { - mHibernation.incWakeCount(HibernationMachine::STRONG); - } } } else { result = cur_c->cnx->egl.eglMakeCurrent( disp.dpy, impl_draw, impl_read, impl_ctx); if (result == EGL_TRUE) { cur_c->onLooseCurrent(); - mHibernation.decWakeCount(HibernationMachine::STRONG); } } } @@ -379,63 +371,5 @@ bool egl_display_t::haveExtension(const char* name, size_t nameLen) const { } // ---------------------------------------------------------------------------- - -bool egl_display_t::HibernationMachine::incWakeCount(WakeRefStrength strength) { - Mutex::Autolock _l(mLock); - ALOGE_IF(mWakeCount < 0 || mWakeCount == INT32_MAX, - "Invalid WakeCount (%d) on enter\n", mWakeCount); - - mWakeCount++; - if (strength == STRONG) - mAttemptHibernation = false; - - if (CC_UNLIKELY(mHibernating)) { - ALOGV("Awakening\n"); - egl_connection_t* const cnx = &gEGLImpl; - - // These conditions should be guaranteed before entering hibernation; - // we don't want to get into a state where we can't wake up. - ALOGD_IF(!mDpyValid || !cnx->egl.eglAwakenProcessIMG, - "Invalid hibernation state, unable to awaken\n"); - - if (!cnx->egl.eglAwakenProcessIMG()) { - ALOGE("Failed to awaken EGL implementation\n"); - return false; - } - mHibernating = false; - } - return true; -} - -void egl_display_t::HibernationMachine::decWakeCount(WakeRefStrength strength) { - Mutex::Autolock _l(mLock); - ALOGE_IF(mWakeCount <= 0, "Invalid WakeCount (%d) on leave\n", mWakeCount); - - mWakeCount--; - if (strength == STRONG) - mAttemptHibernation = true; - - if (mWakeCount == 0 && CC_UNLIKELY(mAttemptHibernation)) { - egl_connection_t* const cnx = &gEGLImpl; - mAttemptHibernation = false; - if (mAllowHibernation && mDpyValid && - cnx->egl.eglHibernateProcessIMG && - cnx->egl.eglAwakenProcessIMG) { - ALOGV("Hibernating\n"); - if (!cnx->egl.eglHibernateProcessIMG()) { - ALOGE("Failed to hibernate EGL implementation\n"); - return; - } - mHibernating = true; - } - } -} - -void egl_display_t::HibernationMachine::setDisplayValid(bool valid) { - Mutex::Autolock _l(mLock); - mDpyValid = valid; -} - -// ---------------------------------------------------------------------------- }; // namespace android // ---------------------------------------------------------------------------- diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h index 2d862951c1..e17558cbd0 100644 --- a/opengl/libs/EGL/egl_display.h +++ b/opengl/libs/EGL/egl_display.h @@ -68,20 +68,6 @@ public: // add reference to this object. returns true if this is a valid object. bool getObject(egl_object_t* object) const; - // These notifications allow the display to keep track of how many window - // surfaces exist, which it uses to decide whether to hibernate the - // underlying EGL implementation. They can be called by any thread without - // holding a lock, but must be called via egl_display_ptr to ensure - // proper hibernate/wakeup sequencing. If a surface destruction triggers - // hibernation, hibernation will be delayed at least until the calling - // thread's egl_display_ptr is destroyed. - void onWindowSurfaceCreated() { - mHibernation.incWakeCount(HibernationMachine::STRONG); - } - void onWindowSurfaceDestroyed() { - mHibernation.decWakeCount(HibernationMachine::STRONG); - } - static egl_display_t* get(EGLDisplay dpy); static EGLDisplay getFromNativeDisplay(EGLNativeDisplayType disp); @@ -127,8 +113,6 @@ public: private: friend class egl_display_ptr; - bool enter() { return mHibernation.incWakeCount(HibernationMachine::WEAK); } - void leave() { return mHibernation.decWakeCount(HibernationMachine::WEAK); } uint32_t refs; bool eglIsInitialized; @@ -139,47 +123,6 @@ private: String8 mVersionString; String8 mClientApiString; String8 mExtensionString; - - // HibernationMachine uses its own internal mutex to protect its own data. - // The owning egl_display_t's lock may be but is not required to be held - // when calling HibernationMachine methods. As a result, nothing in this - // class may call back up to egl_display_t directly or indirectly. - class HibernationMachine { - public: - // STRONG refs cancel (inc) or initiate (dec) a hibernation attempt - // the next time the wakecount reaches zero. WEAK refs don't affect - // whether a hibernation attempt will be made. Use STRONG refs only - // for infrequent/heavy changes that are likely to indicate the - // EGLDisplay is entering or leaving a long-term idle state. - enum WakeRefStrength { - WEAK = 0, - STRONG = 1, - }; - - HibernationMachine(): mWakeCount(0), mHibernating(false), - mAttemptHibernation(false), mDpyValid(false), -#if BOARD_ALLOW_EGL_HIBERNATION - mAllowHibernation(true) -#else - mAllowHibernation(false) -#endif - {} - ~HibernationMachine() {} - - bool incWakeCount(WakeRefStrength strenth); - void decWakeCount(WakeRefStrength strenth); - - void setDisplayValid(bool valid); - - private: - Mutex mLock; - int32_t mWakeCount; - bool mHibernating; - bool mAttemptHibernation; - bool mDpyValid; - const bool mAllowHibernation; - }; - HibernationMachine mHibernation; }; // ---------------------------------------------------------------------------- @@ -190,13 +133,7 @@ private: // as the egl_display_ptr exists. class egl_display_ptr { public: - explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) { - if (mDpy) { - if (CC_UNLIKELY(!mDpy->enter())) { - mDpy = NULL; - } - } - } + explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) {} // We only really need a C++11 move constructor, not a copy constructor. // A move constructor would save an enter()/leave() pair on every EGL API @@ -208,17 +145,9 @@ public: // other.mDpy = NULL; // } // - egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) { - if (mDpy) { - mDpy->enter(); - } - } - - ~egl_display_ptr() { - if (mDpy) { - mDpy->leave(); - } - } + egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {} + + ~egl_display_ptr() {} const egl_display_t* operator->() const { return mDpy; } egl_display_t* operator->() { return mDpy; } diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp index cfecf77021..6a76737f70 100644 --- a/opengl/libs/EGL/egl_object.cpp +++ b/opengl/libs/EGL/egl_object.cpp @@ -69,17 +69,12 @@ egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config, egl_connection_t const* cnx) : egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx), enableTimestamps(false), connected(true) -{ - if (win) { - getDisplay()->onWindowSurfaceCreated(); - } -} +{} egl_surface_t::~egl_surface_t() { ANativeWindow* const window = win.get(); if (window != NULL) { disconnect(); - getDisplay()->onWindowSurfaceDestroyed(); } } |