Loading include/utils/RefBase.h +8 −1 Original line number Diff line number Diff line Loading @@ -121,6 +121,13 @@ protected: RefBase(); virtual ~RefBase(); // called when the last reference goes away. this is responsible for // calling the destructor. The default implementation just does // "delete this;". // Make sure to never acquire a strong reference from this function. The // same restrictions than for destructors apply. virtual void destroy() const; //! Flags for extendObjectLifetime() enum { OBJECT_LIFETIME_WEAK = 0x0001, Loading libs/utils/RefBase.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -345,6 +345,10 @@ void RefBase::incStrong(const void* id) const const_cast<RefBase*>(this)->onFirstRef(); } void RefBase::destroy() const { delete this; } void RefBase::decStrong(const void* id) const { weakref_impl* const refs = mRefs; Loading @@ -357,7 +361,7 @@ void RefBase::decStrong(const void* id) const if (c == 1) { const_cast<RefBase*>(this)->onLastStrongRef(id); if ((refs->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { delete this; destroy(); } } refs->decWeak(id); Loading Loading @@ -415,7 +419,8 @@ void RefBase::weakref_type::decWeak(const void* id) if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { if (impl->mStrong == INITIAL_STRONG_VALUE) delete impl->mBase; if (impl->mBase) impl->mBase->destroy(); else { // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); delete impl; Loading @@ -423,7 +428,8 @@ void RefBase::weakref_type::decWeak(const void* id) } else { impl->mBase->onLastWeakRef(id); if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) { delete impl->mBase; if (impl->mBase) impl->mBase->destroy(); } } } Loading services/surfaceflinger/Layer.cpp +4 −12 Original line number Diff line number Diff line Loading @@ -77,6 +77,10 @@ Layer::~Layer() } } void Layer::destroy() const { mFlinger->destroyLayer(this); } status_t Layer::setToken(const sp<UserClient>& userClient, SharedClient* sharedClient, int32_t token) { Loading Loading @@ -145,18 +149,6 @@ sp<LayerBaseClient::Surface> Layer::createSurface() const return sur; } status_t Layer::ditch() { // NOTE: Called from the main UI thread // the layer is not on screen anymore. free as much resources as possible mFreezeLock.clear(); Mutex::Autolock _l(mLock); mWidth = mHeight = 0; return NO_ERROR; } status_t Layer::setBuffers( uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) { Loading services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,6 @@ public: virtual bool isSecure() const { return mSecure; } virtual bool isProtected() const; virtual sp<Surface> createSurface() const; virtual status_t ditch(); virtual void onRemoved(); // only for debugging Loading @@ -93,6 +92,7 @@ public: return mFreezeLock; } protected: virtual void destroy() const; virtual void dump(String8& result, char* scratch, size_t size) const; private: Loading services/surfaceflinger/LayerBase.cpp +1 −4 Original line number Diff line number Diff line Loading @@ -616,10 +616,7 @@ LayerBaseClient::Surface::~Surface() */ // destroy client resources sp<LayerBaseClient> layer = getOwner(); if (layer != 0) { mFlinger->destroySurface(layer); } mFlinger->destroySurface(mOwner); } sp<LayerBaseClient> LayerBaseClient::Surface::getOwner() const { Loading Loading
include/utils/RefBase.h +8 −1 Original line number Diff line number Diff line Loading @@ -121,6 +121,13 @@ protected: RefBase(); virtual ~RefBase(); // called when the last reference goes away. this is responsible for // calling the destructor. The default implementation just does // "delete this;". // Make sure to never acquire a strong reference from this function. The // same restrictions than for destructors apply. virtual void destroy() const; //! Flags for extendObjectLifetime() enum { OBJECT_LIFETIME_WEAK = 0x0001, Loading
libs/utils/RefBase.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -345,6 +345,10 @@ void RefBase::incStrong(const void* id) const const_cast<RefBase*>(this)->onFirstRef(); } void RefBase::destroy() const { delete this; } void RefBase::decStrong(const void* id) const { weakref_impl* const refs = mRefs; Loading @@ -357,7 +361,7 @@ void RefBase::decStrong(const void* id) const if (c == 1) { const_cast<RefBase*>(this)->onLastStrongRef(id); if ((refs->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { delete this; destroy(); } } refs->decWeak(id); Loading Loading @@ -415,7 +419,8 @@ void RefBase::weakref_type::decWeak(const void* id) if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { if (impl->mStrong == INITIAL_STRONG_VALUE) delete impl->mBase; if (impl->mBase) impl->mBase->destroy(); else { // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); delete impl; Loading @@ -423,7 +428,8 @@ void RefBase::weakref_type::decWeak(const void* id) } else { impl->mBase->onLastWeakRef(id); if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) { delete impl->mBase; if (impl->mBase) impl->mBase->destroy(); } } } Loading
services/surfaceflinger/Layer.cpp +4 −12 Original line number Diff line number Diff line Loading @@ -77,6 +77,10 @@ Layer::~Layer() } } void Layer::destroy() const { mFlinger->destroyLayer(this); } status_t Layer::setToken(const sp<UserClient>& userClient, SharedClient* sharedClient, int32_t token) { Loading Loading @@ -145,18 +149,6 @@ sp<LayerBaseClient::Surface> Layer::createSurface() const return sur; } status_t Layer::ditch() { // NOTE: Called from the main UI thread // the layer is not on screen anymore. free as much resources as possible mFreezeLock.clear(); Mutex::Autolock _l(mLock); mWidth = mHeight = 0; return NO_ERROR; } status_t Layer::setBuffers( uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) { Loading
services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,6 @@ public: virtual bool isSecure() const { return mSecure; } virtual bool isProtected() const; virtual sp<Surface> createSurface() const; virtual status_t ditch(); virtual void onRemoved(); // only for debugging Loading @@ -93,6 +92,7 @@ public: return mFreezeLock; } protected: virtual void destroy() const; virtual void dump(String8& result, char* scratch, size_t size) const; private: Loading
services/surfaceflinger/LayerBase.cpp +1 −4 Original line number Diff line number Diff line Loading @@ -616,10 +616,7 @@ LayerBaseClient::Surface::~Surface() */ // destroy client resources sp<LayerBaseClient> layer = getOwner(); if (layer != 0) { mFlinger->destroySurface(layer); } mFlinger->destroySurface(mOwner); } sp<LayerBaseClient> LayerBaseClient::Surface::getOwner() const { Loading