Merge "Remove EGL Hibernation"
am: 5e86147abc
Change-Id: I7afcd579a1ba81733540b280186bb7e3644b1816
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index f0ba728..4f7c7e4 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -42,9 +42,6 @@
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 e335a6c..10523f5 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -212,8 +212,6 @@
*major = VERSION_MAJOR;
if (minor != NULL)
*minor = VERSION_MINOR;
-
- mHibernation.setDisplayValid(true);
}
{
@@ -262,8 +260,6 @@
res = EGL_TRUE;
}
- mHibernation.setDisplayValid(false);
-
// Reset the extension string since it will be regenerated if we get
// reinitialized.
mExtensionString.setTo("");
@@ -342,16 +338,12 @@
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);
}
}
}
@@ -376,63 +368,5 @@
}
// ----------------------------------------------------------------------------
-
-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 2d86295..e17558c 100644
--- a/opengl/libs/EGL/egl_display.h
+++ b/opengl/libs/EGL/egl_display.h
@@ -68,20 +68,6 @@
// 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 @@
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 @@
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 @@
// 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 @@
// other.mDpy = NULL;
// }
//
- egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {
- if (mDpy) {
- mDpy->enter();
- }
- }
+ egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {}
- ~egl_display_ptr() {
- if (mDpy) {
- mDpy->leave();
- }
- }
+ ~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 90f27d1..7fc5609 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -69,17 +69,12 @@
egl_connection_t const* cnx) :
egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx),
connected(true)
-{
- if (win) {
- getDisplay()->onWindowSurfaceCreated();
- }
-}
+{}
egl_surface_t::~egl_surface_t() {
ANativeWindow* const window = win.get();
if (window != NULL) {
disconnect();
- getDisplay()->onWindowSurfaceDestroyed();
}
}