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
diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp
index 7202bef..bdbc79b 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 @@
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::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::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 02079a3..af410ea 100644
--- a/services/surfaceflinger/Client.h
+++ b/services/surfaceflinger/Client.h
@@ -38,12 +38,6 @@
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 @@
// 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 9777092..97e47e8 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -240,11 +240,6 @@
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 cfebec7..e2ca129 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3640,11 +3640,6 @@
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;
}