diff options
author | 2022-10-28 06:08:35 +0000 | |
---|---|---|
committer | 2022-10-28 16:06:10 +0000 | |
commit | 989c51090b0b33192dd97653f61ce3944b580d22 (patch) | |
tree | 20c3e275b7b137ff700dc1478d6226e5dfccdbf8 | |
parent | bb26732f6fe79100bcf648461d9104a97967666f (diff) |
SF: Remove layer map from Client
Cleanup before layer refbase removal. We
can lookup the layer from the handle
instead of maintaining a map.
Bug: 238781169
Test: presubmit
Change-Id: Ie6543e4c344359be6a221c164d193656e9190cc8
-rw-r--r-- | services/surfaceflinger/Client.cpp | 35 | ||||
-rw-r--r-- | services/surfaceflinger/Client.h | 9 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 5 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 5 |
4 files changed, 3 insertions, 51 deletions
diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp index 7202bef606..bdbc79b8e1 100644 --- a/services/surfaceflinger/Client.cpp +++ b/services/surfaceflinger/Client.cpp @@ -25,6 +25,7 @@ #include "Client.h" #include "FrontEnd/LayerCreationArgs.h" +#include "FrontEnd/LayerHandle.h" #include "Layer.h" #include "SurfaceFlinger.h" @@ -47,36 +48,6 @@ status_t Client::initCheck() const { return NO_ERROR; } -void Client::attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer) -{ - Mutex::Autolock _l(mLock); - mLayers.add(handle, layer); -} - -void Client::detachLayer(const Layer* layer) -{ - Mutex::Autolock _l(mLock); - // we do a linear search here, because this doesn't happen often - const size_t count = mLayers.size(); - for (size_t i=0 ; i<count ; i++) { - if (mLayers.valueAt(i) == layer) { - mLayers.removeItemsAt(i, 1); - break; - } - } -} -sp<Layer> Client::getLayerUser(const sp<IBinder>& handle) const -{ - Mutex::Autolock _l(mLock); - sp<Layer> lbc; - wp<Layer> layer(mLayers.valueFor(handle)); - if (layer != 0) { - lbc = layer.promote(); - ALOGE_IF(lbc==0, "getLayerUser(name=%p) is dead", handle.get()); - } - return lbc; -} - binder::Status Client::createSurface(const std::string& name, int32_t flags, const sp<IBinder>& parent, const gui::LayerMetadata& metadata, gui::CreateSurfaceResult* outResult) { @@ -91,7 +62,7 @@ binder::Status Client::createSurface(const std::string& name, int32_t flags, binder::Status Client::clearLayerFrameStats(const sp<IBinder>& handle) { status_t status; - sp<Layer> layer = getLayerUser(handle); + sp<Layer> layer = LayerHandle::getLayer(handle); if (layer == nullptr) { status = NAME_NOT_FOUND; } else { @@ -103,7 +74,7 @@ binder::Status Client::clearLayerFrameStats(const sp<IBinder>& handle) { binder::Status Client::getLayerFrameStats(const sp<IBinder>& handle, gui::FrameStats* outStats) { status_t status; - sp<Layer> layer = getLayerUser(handle); + sp<Layer> layer = LayerHandle::getLayer(handle); if (layer == nullptr) { status = NAME_NOT_FOUND; } else { diff --git a/services/surfaceflinger/Client.h b/services/surfaceflinger/Client.h index 02079a3b3f..af410ea19c 100644 --- a/services/surfaceflinger/Client.h +++ b/services/surfaceflinger/Client.h @@ -38,12 +38,6 @@ public: status_t initCheck() const; - // protected by SurfaceFlinger::mStateLock - void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer); - void detachLayer(const Layer* layer); - - sp<Layer> getLayerUser(const sp<IBinder>& handle) const; - private: // ISurfaceComposerClient interface @@ -64,9 +58,6 @@ private: // constant sp<SurfaceFlinger> mFlinger; - // protected by mLock - DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers; - // thread-safe mutable Mutex mLock; }; diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 977709286b..97e47e8e68 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -240,11 +240,6 @@ Layer::~Layer() { mFlinger->mTimeStats->onDestroy(layerId); mFlinger->mFrameTracer->onDestroy(layerId); - sp<Client> c(mClientRef.promote()); - if (c != 0) { - c->detachLayer(this); - } - mFrameTracker.logAndResetStats(mName); mFlinger->onLayerDestroyed(this); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index cfebec70cb..e2ca129587 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3640,11 +3640,6 @@ status_t SurfaceFlinger::addClientLayer(const LayerCreationArgs& args, const sp< mCreatedLayers.emplace_back(layer, parent, args.addToRoot); } - // attach this layer to the client - if (args.client != nullptr) { - args.client->attachLayer(handle, layer); - } - setTransactionFlags(eTransactionNeeded); return NO_ERROR; } |