Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f968c0ce authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "SF: Remove layer map from Client"

parents 8954cb78 989c5109
Loading
Loading
Loading
Loading
+3 −32
Original line number Diff line number Diff line
@@ -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 {
+0 −9
Original line number Diff line number Diff line
@@ -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;
};
+0 −5
Original line number Diff line number Diff line
@@ -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);

+0 −5
Original line number Diff line number Diff line
@@ -3641,11 +3641,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;
}