Loading include/utils/RefBase.h +48 −14 Original line number Diff line number Diff line Loading @@ -31,13 +31,10 @@ template<typename T> class wp; // --------------------------------------------------------------------------- #define COMPARE(_op_) \ #define COMPARE_WEAK(_op_) \ inline bool operator _op_ (const sp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ inline bool operator _op_ (const wp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ inline bool operator _op_ (const T* o) const { \ return m_ptr _op_ o; \ } \ Loading @@ -46,12 +43,18 @@ inline bool operator _op_ (const sp<U>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template<typename U> \ inline bool operator _op_ (const wp<U>& o) const { \ inline bool operator _op_ (const U* o) const { \ return m_ptr _op_ o; \ } #define COMPARE(_op_) \ COMPARE_WEAK(_op_) \ inline bool operator _op_ (const wp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template<typename U> \ inline bool operator _op_ (const U* o) const { \ return m_ptr _op_ o; \ inline bool operator _op_ (const wp<U>& o) const { \ return m_ptr _op_ o.m_ptr; \ } // --------------------------------------------------------------------------- Loading Loading @@ -275,12 +278,42 @@ public: // Operators COMPARE(==) COMPARE(!=) COMPARE(>) COMPARE(<) COMPARE(<=) COMPARE(>=) COMPARE_WEAK(==) COMPARE_WEAK(!=) COMPARE_WEAK(>) COMPARE_WEAK(<) COMPARE_WEAK(<=) COMPARE_WEAK(>=) inline bool operator == (const wp<T>& o) const { return (m_ptr == o.m_ptr) && (m_refs == o.m_refs); } template<typename U> inline bool operator == (const wp<U>& o) const { return m_ptr == o.m_ptr; } inline bool operator > (const wp<T>& o) const { return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); } template<typename U> inline bool operator > (const wp<U>& o) const { return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); } inline bool operator < (const wp<T>& o) const { return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); } template<typename U> inline bool operator < (const wp<U>& o) const { return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); } inline bool operator != (const wp<T>& o) const { return m_refs != o.m_refs; } template<typename U> inline bool operator != (const wp<U>& o) const { return !operator == (o); } inline bool operator <= (const wp<T>& o) const { return !operator > (o); } template<typename U> inline bool operator <= (const wp<U>& o) const { return !operator > (o); } inline bool operator >= (const wp<T>& o) const { return !operator < (o); } template<typename U> inline bool operator >= (const wp<U>& o) const { return !operator < (o); } private: template<typename Y> friend class sp; Loading @@ -294,6 +327,7 @@ template <typename T> TextOutput& operator<<(TextOutput& to, const wp<T>& val); #undef COMPARE #undef COMPARE_WEAK // --------------------------------------------------------------------------- // No user serviceable parts below here. Loading services/surfaceflinger/Layer.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -120,7 +120,8 @@ void Layer::onRemoved() sp<LayerBaseClient::Surface> Layer::createSurface() const { return mSurface; sp<Surface> sur(new SurfaceLayer(mFlinger, const_cast<Layer *>(this))); return sur; } status_t Layer::ditch() Loading @@ -130,10 +131,6 @@ status_t Layer::ditch() // the layer is not on screen anymore. free as much resources as possible mFreezeLock.clear(); EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay()); mBufferManager.destroy(dpy); mSurface.clear(); Mutex::Autolock _l(mLock); mWidth = mHeight = 0; return NO_ERROR; Loading Loading @@ -178,7 +175,6 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED); mNeedsDithering = layerRedsize > displayRedSize; mSurface = new SurfaceLayer(mFlinger, this); return NO_ERROR; } Loading services/surfaceflinger/Layer.h +0 −1 Original line number Diff line number Diff line Loading @@ -211,7 +211,6 @@ private: ClientRef mUserClientRef; // constants sp<Surface> mSurface; PixelFormat mFormat; const GLExtensions& mGLExtensions; bool mNeedsBlending; Loading services/surfaceflinger/LayerBase.cpp +14 −6 Original line number Diff line number Diff line Loading @@ -527,7 +527,9 @@ int32_t LayerBaseClient::sIdentity = 1; LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, const sp<Client>& client) : LayerBase(flinger, display), mClientRef(client), : LayerBase(flinger, display), mHasSurface(false), mClientRef(client), mIdentity(uint32_t(android_atomic_inc(&sIdentity))) { } Loading @@ -544,14 +546,20 @@ sp<LayerBaseClient::Surface> LayerBaseClient::getSurface() { sp<Surface> s; Mutex::Autolock _l(mLock); s = mClientSurface.promote(); if (s == 0) { LOG_ALWAYS_FATAL_IF(mHasSurface, "LayerBaseClient::getSurface() has already been called"); mHasSurface = true; s = createSurface(); mClientSurface = s; } mClientSurfaceBinder = s->asBinder(); return s; } wp<IBinder> LayerBaseClient::getSurfaceBinder() const { return mClientSurfaceBinder; } sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const { return new Surface(mFlinger, mIdentity, Loading services/surfaceflinger/LayerBase.h +3 −1 Original line number Diff line number Diff line Loading @@ -285,6 +285,7 @@ public: virtual ~LayerBaseClient(); sp<Surface> getSurface(); wp<IBinder> getSurfaceBinder() const; virtual sp<Surface> createSurface() const; virtual sp<LayerBaseClient> getLayerBaseClient() const { return const_cast<LayerBaseClient*>(this); } Loading Loading @@ -330,7 +331,8 @@ protected: private: mutable Mutex mLock; mutable wp<Surface> mClientSurface; mutable bool mHasSurface; wp<IBinder> mClientSurfaceBinder; const wp<Client> mClientRef; // only read const uint32_t mIdentity; Loading Loading
include/utils/RefBase.h +48 −14 Original line number Diff line number Diff line Loading @@ -31,13 +31,10 @@ template<typename T> class wp; // --------------------------------------------------------------------------- #define COMPARE(_op_) \ #define COMPARE_WEAK(_op_) \ inline bool operator _op_ (const sp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ inline bool operator _op_ (const wp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ inline bool operator _op_ (const T* o) const { \ return m_ptr _op_ o; \ } \ Loading @@ -46,12 +43,18 @@ inline bool operator _op_ (const sp<U>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template<typename U> \ inline bool operator _op_ (const wp<U>& o) const { \ inline bool operator _op_ (const U* o) const { \ return m_ptr _op_ o; \ } #define COMPARE(_op_) \ COMPARE_WEAK(_op_) \ inline bool operator _op_ (const wp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template<typename U> \ inline bool operator _op_ (const U* o) const { \ return m_ptr _op_ o; \ inline bool operator _op_ (const wp<U>& o) const { \ return m_ptr _op_ o.m_ptr; \ } // --------------------------------------------------------------------------- Loading Loading @@ -275,12 +278,42 @@ public: // Operators COMPARE(==) COMPARE(!=) COMPARE(>) COMPARE(<) COMPARE(<=) COMPARE(>=) COMPARE_WEAK(==) COMPARE_WEAK(!=) COMPARE_WEAK(>) COMPARE_WEAK(<) COMPARE_WEAK(<=) COMPARE_WEAK(>=) inline bool operator == (const wp<T>& o) const { return (m_ptr == o.m_ptr) && (m_refs == o.m_refs); } template<typename U> inline bool operator == (const wp<U>& o) const { return m_ptr == o.m_ptr; } inline bool operator > (const wp<T>& o) const { return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); } template<typename U> inline bool operator > (const wp<U>& o) const { return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); } inline bool operator < (const wp<T>& o) const { return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); } template<typename U> inline bool operator < (const wp<U>& o) const { return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); } inline bool operator != (const wp<T>& o) const { return m_refs != o.m_refs; } template<typename U> inline bool operator != (const wp<U>& o) const { return !operator == (o); } inline bool operator <= (const wp<T>& o) const { return !operator > (o); } template<typename U> inline bool operator <= (const wp<U>& o) const { return !operator > (o); } inline bool operator >= (const wp<T>& o) const { return !operator < (o); } template<typename U> inline bool operator >= (const wp<U>& o) const { return !operator < (o); } private: template<typename Y> friend class sp; Loading @@ -294,6 +327,7 @@ template <typename T> TextOutput& operator<<(TextOutput& to, const wp<T>& val); #undef COMPARE #undef COMPARE_WEAK // --------------------------------------------------------------------------- // No user serviceable parts below here. Loading
services/surfaceflinger/Layer.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -120,7 +120,8 @@ void Layer::onRemoved() sp<LayerBaseClient::Surface> Layer::createSurface() const { return mSurface; sp<Surface> sur(new SurfaceLayer(mFlinger, const_cast<Layer *>(this))); return sur; } status_t Layer::ditch() Loading @@ -130,10 +131,6 @@ status_t Layer::ditch() // the layer is not on screen anymore. free as much resources as possible mFreezeLock.clear(); EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay()); mBufferManager.destroy(dpy); mSurface.clear(); Mutex::Autolock _l(mLock); mWidth = mHeight = 0; return NO_ERROR; Loading Loading @@ -178,7 +175,6 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED); mNeedsDithering = layerRedsize > displayRedSize; mSurface = new SurfaceLayer(mFlinger, this); return NO_ERROR; } Loading
services/surfaceflinger/Layer.h +0 −1 Original line number Diff line number Diff line Loading @@ -211,7 +211,6 @@ private: ClientRef mUserClientRef; // constants sp<Surface> mSurface; PixelFormat mFormat; const GLExtensions& mGLExtensions; bool mNeedsBlending; Loading
services/surfaceflinger/LayerBase.cpp +14 −6 Original line number Diff line number Diff line Loading @@ -527,7 +527,9 @@ int32_t LayerBaseClient::sIdentity = 1; LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, const sp<Client>& client) : LayerBase(flinger, display), mClientRef(client), : LayerBase(flinger, display), mHasSurface(false), mClientRef(client), mIdentity(uint32_t(android_atomic_inc(&sIdentity))) { } Loading @@ -544,14 +546,20 @@ sp<LayerBaseClient::Surface> LayerBaseClient::getSurface() { sp<Surface> s; Mutex::Autolock _l(mLock); s = mClientSurface.promote(); if (s == 0) { LOG_ALWAYS_FATAL_IF(mHasSurface, "LayerBaseClient::getSurface() has already been called"); mHasSurface = true; s = createSurface(); mClientSurface = s; } mClientSurfaceBinder = s->asBinder(); return s; } wp<IBinder> LayerBaseClient::getSurfaceBinder() const { return mClientSurfaceBinder; } sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const { return new Surface(mFlinger, mIdentity, Loading
services/surfaceflinger/LayerBase.h +3 −1 Original line number Diff line number Diff line Loading @@ -285,6 +285,7 @@ public: virtual ~LayerBaseClient(); sp<Surface> getSurface(); wp<IBinder> getSurfaceBinder() const; virtual sp<Surface> createSurface() const; virtual sp<LayerBaseClient> getLayerBaseClient() const { return const_cast<LayerBaseClient*>(this); } Loading Loading @@ -330,7 +331,8 @@ protected: private: mutable Mutex mLock; mutable wp<Surface> mClientSurface; mutable bool mHasSurface; wp<IBinder> mClientSurfaceBinder; const wp<Client> mClientRef; // only read const uint32_t mIdentity; Loading