Loading opengl/libs/Android.mk +0 −3 Original line number Original line Diff line number Diff line Loading @@ -42,9 +42,6 @@ LOCAL_CFLAGS += -DLOG_TAG=\"libEGL\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -fvisibility=hidden LOCAL_CFLAGS += -fvisibility=hidden ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true) LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION endif ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),) ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),) LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE) LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE) endif endif Loading opengl/libs/EGL/egl_display.cpp +0 −66 Original line number Original line Diff line number Diff line Loading @@ -215,8 +215,6 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { *major = VERSION_MAJOR; *major = VERSION_MAJOR; if (minor != NULL) if (minor != NULL) *minor = VERSION_MINOR; *minor = VERSION_MINOR; mHibernation.setDisplayValid(true); } } { { Loading Loading @@ -265,8 +263,6 @@ EGLBoolean egl_display_t::terminate() { res = EGL_TRUE; res = EGL_TRUE; } } mHibernation.setDisplayValid(false); // Reset the extension string since it will be regenerated if we get // Reset the extension string since it will be regenerated if we get // reinitialized. // reinitialized. mExtensionString.setTo(""); mExtensionString.setTo(""); Loading Loading @@ -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); disp.dpy, impl_draw, impl_read, impl_ctx); if (result == EGL_TRUE) { if (result == EGL_TRUE) { c->onMakeCurrent(draw, read); c->onMakeCurrent(draw, read); if (!cur_c) { mHibernation.incWakeCount(HibernationMachine::STRONG); } } } } else { } else { result = cur_c->cnx->egl.eglMakeCurrent( result = cur_c->cnx->egl.eglMakeCurrent( disp.dpy, impl_draw, impl_read, impl_ctx); disp.dpy, impl_draw, impl_read, impl_ctx); if (result == EGL_TRUE) { if (result == EGL_TRUE) { cur_c->onLooseCurrent(); cur_c->onLooseCurrent(); mHibernation.decWakeCount(HibernationMachine::STRONG); } } } } } } Loading @@ -378,64 +370,6 @@ bool egl_display_t::haveExtension(const char* name, size_t nameLen) const { return findExtension(mExtensionString.string(), name, nameLen); return findExtension(mExtensionString.string(), name, nameLen); } } // ---------------------------------------------------------------------------- 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 }; // namespace android // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- opengl/libs/EGL/egl_display.h +4 −75 Original line number Original line Diff line number Diff line Loading @@ -68,20 +68,6 @@ public: // add reference to this object. returns true if this is a valid object. // add reference to this object. returns true if this is a valid object. bool getObject(egl_object_t* object) const; 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 egl_display_t* get(EGLDisplay dpy); static EGLDisplay getFromNativeDisplay(EGLNativeDisplayType disp); static EGLDisplay getFromNativeDisplay(EGLNativeDisplayType disp); Loading Loading @@ -127,8 +113,6 @@ public: private: private: friend class egl_display_ptr; friend class egl_display_ptr; bool enter() { return mHibernation.incWakeCount(HibernationMachine::WEAK); } void leave() { return mHibernation.decWakeCount(HibernationMachine::WEAK); } uint32_t refs; uint32_t refs; bool eglIsInitialized; bool eglIsInitialized; Loading @@ -139,47 +123,6 @@ private: String8 mVersionString; String8 mVersionString; String8 mClientApiString; String8 mClientApiString; String8 mExtensionString; 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; }; }; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading @@ -190,13 +133,7 @@ private: // as the egl_display_ptr exists. // as the egl_display_ptr exists. class egl_display_ptr { class egl_display_ptr { public: public: explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) { explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) {} if (mDpy) { if (CC_UNLIKELY(!mDpy->enter())) { mDpy = NULL; } } } // We only really need a C++11 move constructor, not a copy constructor. // 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 // A move constructor would save an enter()/leave() pair on every EGL API Loading @@ -208,17 +145,9 @@ public: // other.mDpy = NULL; // other.mDpy = NULL; // } // } // // egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) { egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {} if (mDpy) { mDpy->enter(); } } ~egl_display_ptr() { ~egl_display_ptr() {} if (mDpy) { mDpy->leave(); } } const egl_display_t* operator->() const { return mDpy; } const egl_display_t* operator->() const { return mDpy; } egl_display_t* operator->() { return mDpy; } egl_display_t* operator->() { return mDpy; } Loading opengl/libs/EGL/egl_object.cpp +1 −6 Original line number Original line Diff line number Diff line Loading @@ -69,17 +69,12 @@ egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config, egl_connection_t const* cnx) : egl_connection_t const* cnx) : egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx), egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx), enableTimestamps(false), connected(true) enableTimestamps(false), connected(true) { {} if (win) { getDisplay()->onWindowSurfaceCreated(); } } egl_surface_t::~egl_surface_t() { egl_surface_t::~egl_surface_t() { ANativeWindow* const window = win.get(); ANativeWindow* const window = win.get(); if (window != NULL) { if (window != NULL) { disconnect(); disconnect(); getDisplay()->onWindowSurfaceDestroyed(); } } } } Loading Loading
opengl/libs/Android.mk +0 −3 Original line number Original line Diff line number Diff line Loading @@ -42,9 +42,6 @@ LOCAL_CFLAGS += -DLOG_TAG=\"libEGL\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -fvisibility=hidden LOCAL_CFLAGS += -fvisibility=hidden ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true) LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION endif ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),) ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),) LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE) LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE) endif endif Loading
opengl/libs/EGL/egl_display.cpp +0 −66 Original line number Original line Diff line number Diff line Loading @@ -215,8 +215,6 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { *major = VERSION_MAJOR; *major = VERSION_MAJOR; if (minor != NULL) if (minor != NULL) *minor = VERSION_MINOR; *minor = VERSION_MINOR; mHibernation.setDisplayValid(true); } } { { Loading Loading @@ -265,8 +263,6 @@ EGLBoolean egl_display_t::terminate() { res = EGL_TRUE; res = EGL_TRUE; } } mHibernation.setDisplayValid(false); // Reset the extension string since it will be regenerated if we get // Reset the extension string since it will be regenerated if we get // reinitialized. // reinitialized. mExtensionString.setTo(""); mExtensionString.setTo(""); Loading Loading @@ -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); disp.dpy, impl_draw, impl_read, impl_ctx); if (result == EGL_TRUE) { if (result == EGL_TRUE) { c->onMakeCurrent(draw, read); c->onMakeCurrent(draw, read); if (!cur_c) { mHibernation.incWakeCount(HibernationMachine::STRONG); } } } } else { } else { result = cur_c->cnx->egl.eglMakeCurrent( result = cur_c->cnx->egl.eglMakeCurrent( disp.dpy, impl_draw, impl_read, impl_ctx); disp.dpy, impl_draw, impl_read, impl_ctx); if (result == EGL_TRUE) { if (result == EGL_TRUE) { cur_c->onLooseCurrent(); cur_c->onLooseCurrent(); mHibernation.decWakeCount(HibernationMachine::STRONG); } } } } } } Loading @@ -378,64 +370,6 @@ bool egl_display_t::haveExtension(const char* name, size_t nameLen) const { return findExtension(mExtensionString.string(), name, nameLen); return findExtension(mExtensionString.string(), name, nameLen); } } // ---------------------------------------------------------------------------- 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 }; // namespace android // ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
opengl/libs/EGL/egl_display.h +4 −75 Original line number Original line Diff line number Diff line Loading @@ -68,20 +68,6 @@ public: // add reference to this object. returns true if this is a valid object. // add reference to this object. returns true if this is a valid object. bool getObject(egl_object_t* object) const; 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 egl_display_t* get(EGLDisplay dpy); static EGLDisplay getFromNativeDisplay(EGLNativeDisplayType disp); static EGLDisplay getFromNativeDisplay(EGLNativeDisplayType disp); Loading Loading @@ -127,8 +113,6 @@ public: private: private: friend class egl_display_ptr; friend class egl_display_ptr; bool enter() { return mHibernation.incWakeCount(HibernationMachine::WEAK); } void leave() { return mHibernation.decWakeCount(HibernationMachine::WEAK); } uint32_t refs; uint32_t refs; bool eglIsInitialized; bool eglIsInitialized; Loading @@ -139,47 +123,6 @@ private: String8 mVersionString; String8 mVersionString; String8 mClientApiString; String8 mClientApiString; String8 mExtensionString; 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; }; }; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading @@ -190,13 +133,7 @@ private: // as the egl_display_ptr exists. // as the egl_display_ptr exists. class egl_display_ptr { class egl_display_ptr { public: public: explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) { explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) {} if (mDpy) { if (CC_UNLIKELY(!mDpy->enter())) { mDpy = NULL; } } } // We only really need a C++11 move constructor, not a copy constructor. // 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 // A move constructor would save an enter()/leave() pair on every EGL API Loading @@ -208,17 +145,9 @@ public: // other.mDpy = NULL; // other.mDpy = NULL; // } // } // // egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) { egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {} if (mDpy) { mDpy->enter(); } } ~egl_display_ptr() { ~egl_display_ptr() {} if (mDpy) { mDpy->leave(); } } const egl_display_t* operator->() const { return mDpy; } const egl_display_t* operator->() const { return mDpy; } egl_display_t* operator->() { return mDpy; } egl_display_t* operator->() { return mDpy; } Loading
opengl/libs/EGL/egl_object.cpp +1 −6 Original line number Original line Diff line number Diff line Loading @@ -69,17 +69,12 @@ egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config, egl_connection_t const* cnx) : egl_connection_t const* cnx) : egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx), egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx), enableTimestamps(false), connected(true) enableTimestamps(false), connected(true) { {} if (win) { getDisplay()->onWindowSurfaceCreated(); } } egl_surface_t::~egl_surface_t() { egl_surface_t::~egl_surface_t() { ANativeWindow* const window = win.get(); ANativeWindow* const window = win.get(); if (window != NULL) { if (window != NULL) { disconnect(); disconnect(); getDisplay()->onWindowSurfaceDestroyed(); } } } } Loading