Loading include/utils/RefBase.h +0 −14 Original line number Diff line number Diff line Loading @@ -117,20 +117,6 @@ public: typedef RefBase basetype; // used to override the RefBase destruction. class Destroyer { friend class RefBase; friend class weakref_type; public: virtual ~Destroyer(); private: virtual void destroy(RefBase const* base) = 0; }; // Make sure to never acquire a strong reference from this function. The // same restrictions than for destructors apply. void setDestroyer(Destroyer* destroyer); protected: RefBase(); virtual ~RefBase(); Loading libs/utils/RefBase.cpp +9 −35 Original line number Diff line number Diff line Loading @@ -49,11 +49,6 @@ namespace android { // --------------------------------------------------------------------------- RefBase::Destroyer::~Destroyer() { } // --------------------------------------------------------------------------- class RefBase::weakref_impl : public RefBase::weakref_type { public: Loading @@ -61,7 +56,7 @@ public: volatile int32_t mWeak; RefBase* const mBase; volatile int32_t mFlags; Destroyer* mDestroyer; #if !DEBUG_REFS Loading @@ -70,7 +65,6 @@ public: , mWeak(0) , mBase(base) , mFlags(0) , mDestroyer(0) { } Loading Loading @@ -363,13 +357,9 @@ 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) { if (refs->mDestroyer) { refs->mDestroyer->destroy(this); } else { delete this; } } } refs->decWeak(id); } Loading Loading @@ -400,9 +390,7 @@ int32_t RefBase::getStrongCount() const return mRefs->mStrong; } void RefBase::setDestroyer(RefBase::Destroyer* destroyer) { mRefs->mDestroyer = destroyer; } RefBase* RefBase::weakref_type::refBase() const { Loading @@ -426,31 +414,19 @@ void RefBase::weakref_type::decWeak(const void* id) if (c != 1) return; if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { if (impl->mStrong == INITIAL_STRONG_VALUE) { if (impl->mBase) { if (impl->mDestroyer) { impl->mDestroyer->destroy(impl->mBase); } else { if (impl->mStrong == INITIAL_STRONG_VALUE) delete impl->mBase; } } } else { else { // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); delete impl; } } else { impl->mBase->onLastWeakRef(id); if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) { if (impl->mBase) { if (impl->mDestroyer) { impl->mDestroyer->destroy(impl->mBase); } else { delete impl->mBase; } } } } } bool RefBase::weakref_type::attemptIncStrong(const void* id) { Loading Loading @@ -569,12 +545,10 @@ RefBase::RefBase() RefBase::~RefBase() { if ((mRefs->mFlags & OBJECT_LIFETIME_WEAK) == OBJECT_LIFETIME_WEAK) { if (mRefs->mWeak == 0) { delete mRefs; } } } void RefBase::extendObjectLifetime(int32_t mode) { Loading services/surfaceflinger/Layer.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ Layer::Layer(SurfaceFlinger* flinger, mBufferManager(mTextureManager), mWidth(0), mHeight(0), mNeedsScaling(false), mFixedSize(false) { setDestroyer(this); } Layer::~Layer() Loading @@ -78,10 +77,6 @@ Layer::~Layer() } } void Layer::destroy(RefBase const* base) { mFlinger->destroyLayer(static_cast<LayerBase const*>(base)); } status_t Layer::setToken(const sp<UserClient>& userClient, SharedClient* sharedClient, int32_t token) { Loading services/surfaceflinger/Layer.h +1 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class UserClient; // --------------------------------------------------------------------------- class Layer : public LayerBaseClient, private RefBase::Destroyer class Layer : public LayerBaseClient { public: Layer(SurfaceFlinger* flinger, DisplayID display, Loading Loading @@ -92,7 +92,6 @@ public: return mFreezeLock; } protected: virtual void destroy(RefBase const* base); virtual void dump(String8& result, char* scratch, size_t size) const; private: Loading services/surfaceflinger/SurfaceFlinger.cpp +0 −28 Original line number Diff line number Diff line Loading @@ -387,9 +387,6 @@ bool SurfaceFlinger::threadLoop() { waitForEvent(); // call Layer's destructor handleDestroyLayers(); // check for transactions if (UNLIKELY(mConsoleSignals)) { handleConsoleEvents(); Loading Loading @@ -583,31 +580,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) commitTransaction(); } void SurfaceFlinger::destroyLayer(LayerBase const* layer) { Mutex::Autolock _l(mDestroyedLayerLock); mDestroyedLayers.add(layer); signalEvent(); } void SurfaceFlinger::handleDestroyLayers() { Vector<LayerBase const *> destroyedLayers; { // scope for the lock Mutex::Autolock _l(mDestroyedLayerLock); destroyedLayers = mDestroyedLayers; mDestroyedLayers.clear(); } // call destructors without a lock held const size_t count = destroyedLayers.size(); for (size_t i=0 ; i<count ; i++) { //LOGD("destroying %s", destroyedLayers[i]->getName().string()); delete destroyedLayers[i]; } } sp<FreezeLock> SurfaceFlinger::getFreezeLock() const { return new FreezeLock(const_cast<SurfaceFlinger *>(this)); Loading Loading
include/utils/RefBase.h +0 −14 Original line number Diff line number Diff line Loading @@ -117,20 +117,6 @@ public: typedef RefBase basetype; // used to override the RefBase destruction. class Destroyer { friend class RefBase; friend class weakref_type; public: virtual ~Destroyer(); private: virtual void destroy(RefBase const* base) = 0; }; // Make sure to never acquire a strong reference from this function. The // same restrictions than for destructors apply. void setDestroyer(Destroyer* destroyer); protected: RefBase(); virtual ~RefBase(); Loading
libs/utils/RefBase.cpp +9 −35 Original line number Diff line number Diff line Loading @@ -49,11 +49,6 @@ namespace android { // --------------------------------------------------------------------------- RefBase::Destroyer::~Destroyer() { } // --------------------------------------------------------------------------- class RefBase::weakref_impl : public RefBase::weakref_type { public: Loading @@ -61,7 +56,7 @@ public: volatile int32_t mWeak; RefBase* const mBase; volatile int32_t mFlags; Destroyer* mDestroyer; #if !DEBUG_REFS Loading @@ -70,7 +65,6 @@ public: , mWeak(0) , mBase(base) , mFlags(0) , mDestroyer(0) { } Loading Loading @@ -363,13 +357,9 @@ 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) { if (refs->mDestroyer) { refs->mDestroyer->destroy(this); } else { delete this; } } } refs->decWeak(id); } Loading Loading @@ -400,9 +390,7 @@ int32_t RefBase::getStrongCount() const return mRefs->mStrong; } void RefBase::setDestroyer(RefBase::Destroyer* destroyer) { mRefs->mDestroyer = destroyer; } RefBase* RefBase::weakref_type::refBase() const { Loading @@ -426,31 +414,19 @@ void RefBase::weakref_type::decWeak(const void* id) if (c != 1) return; if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { if (impl->mStrong == INITIAL_STRONG_VALUE) { if (impl->mBase) { if (impl->mDestroyer) { impl->mDestroyer->destroy(impl->mBase); } else { if (impl->mStrong == INITIAL_STRONG_VALUE) delete impl->mBase; } } } else { else { // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); delete impl; } } else { impl->mBase->onLastWeakRef(id); if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) { if (impl->mBase) { if (impl->mDestroyer) { impl->mDestroyer->destroy(impl->mBase); } else { delete impl->mBase; } } } } } bool RefBase::weakref_type::attemptIncStrong(const void* id) { Loading Loading @@ -569,12 +545,10 @@ RefBase::RefBase() RefBase::~RefBase() { if ((mRefs->mFlags & OBJECT_LIFETIME_WEAK) == OBJECT_LIFETIME_WEAK) { if (mRefs->mWeak == 0) { delete mRefs; } } } void RefBase::extendObjectLifetime(int32_t mode) { Loading
services/surfaceflinger/Layer.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ Layer::Layer(SurfaceFlinger* flinger, mBufferManager(mTextureManager), mWidth(0), mHeight(0), mNeedsScaling(false), mFixedSize(false) { setDestroyer(this); } Layer::~Layer() Loading @@ -78,10 +77,6 @@ Layer::~Layer() } } void Layer::destroy(RefBase const* base) { mFlinger->destroyLayer(static_cast<LayerBase const*>(base)); } status_t Layer::setToken(const sp<UserClient>& userClient, SharedClient* sharedClient, int32_t token) { Loading
services/surfaceflinger/Layer.h +1 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class UserClient; // --------------------------------------------------------------------------- class Layer : public LayerBaseClient, private RefBase::Destroyer class Layer : public LayerBaseClient { public: Layer(SurfaceFlinger* flinger, DisplayID display, Loading Loading @@ -92,7 +92,6 @@ public: return mFreezeLock; } protected: virtual void destroy(RefBase const* base); virtual void dump(String8& result, char* scratch, size_t size) const; private: Loading
services/surfaceflinger/SurfaceFlinger.cpp +0 −28 Original line number Diff line number Diff line Loading @@ -387,9 +387,6 @@ bool SurfaceFlinger::threadLoop() { waitForEvent(); // call Layer's destructor handleDestroyLayers(); // check for transactions if (UNLIKELY(mConsoleSignals)) { handleConsoleEvents(); Loading Loading @@ -583,31 +580,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) commitTransaction(); } void SurfaceFlinger::destroyLayer(LayerBase const* layer) { Mutex::Autolock _l(mDestroyedLayerLock); mDestroyedLayers.add(layer); signalEvent(); } void SurfaceFlinger::handleDestroyLayers() { Vector<LayerBase const *> destroyedLayers; { // scope for the lock Mutex::Autolock _l(mDestroyedLayerLock); destroyedLayers = mDestroyedLayers; mDestroyedLayers.clear(); } // call destructors without a lock held const size_t count = destroyedLayers.size(); for (size_t i=0 ; i<count ; i++) { //LOGD("destroying %s", destroyedLayers[i]->getName().string()); delete destroyedLayers[i]; } } sp<FreezeLock> SurfaceFlinger::getFreezeLock() const { return new FreezeLock(const_cast<SurfaceFlinger *>(this)); Loading