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

Commit a59aa786 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Use strong reference to parent Handle when creating layer"

parents 32a091b0 6e592063
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -6804,7 +6804,7 @@ void TransactionState::traverseStatesWithBuffers(
}

void SurfaceFlinger::setLayerCreatedState(const sp<IBinder>& handle, const wp<Layer>& layer,
                                          const wp<IBinder>& parent, const wp<Layer> parentLayer,
                                          const sp<IBinder>& parent, const wp<Layer> parentLayer,
                                          const wp<IBinder>& producer, bool addToRoot) {
    Mutex::Autolock lock(mCreatedLayersLock);
    mCreatedLayers[handle->localBinder()] =
@@ -6848,9 +6848,9 @@ sp<Layer> SurfaceFlinger::handleLayerCreatedLocked(const sp<IBinder>& handle) {
    sp<Layer> parent;
    bool allowAddRoot = state->addToRoot;
    if (state->initialParent != nullptr) {
        parent = fromHandle(state->initialParent.promote()).promote();
        parent = fromHandle(state->initialParent).promote();
        if (parent == nullptr) {
            ALOGE("Invalid parent %p", state->initialParent.unsafe_get());
            ALOGE("Invalid parent %p", state->initialParent.get());
            allowAddRoot = false;
        }
    } else if (state->initialParentLayer != nullptr) {
+3 −3
Original line number Diff line number Diff line
@@ -1347,7 +1347,7 @@ private:
            GUARDED_BY(mStateLock);
    mutable Mutex mCreatedLayersLock;
    struct LayerCreatedState {
        LayerCreatedState(const wp<Layer>& layer, const wp<IBinder>& parent,
        LayerCreatedState(const wp<Layer>& layer, const sp<IBinder>& parent,
                          const wp<Layer> parentLayer, const wp<IBinder>& producer, bool addToRoot)
              : layer(layer),
                initialParent(parent),
@@ -1357,7 +1357,7 @@ private:
        wp<Layer> layer;
        // Indicates the initial parent of the created layer, only used for creating layer in
        // SurfaceFlinger. If nullptr, it may add the created layer into the current root layers.
        wp<IBinder> initialParent;
        sp<IBinder> initialParent;
        wp<Layer> initialParentLayer;
        // Indicates the initial graphic buffer producer of the created layer, only used for
        // creating layer in SurfaceFlinger.
@@ -1372,7 +1372,7 @@ private:
    // thread.
    std::unordered_map<BBinder*, std::unique_ptr<LayerCreatedState>> mCreatedLayers;
    void setLayerCreatedState(const sp<IBinder>& handle, const wp<Layer>& layer,
                              const wp<IBinder>& parent, const wp<Layer> parentLayer,
                              const sp<IBinder>& parent, const wp<Layer> parentLayer,
                              const wp<IBinder>& producer, bool addToRoot);
    auto getLayerCreatedState(const sp<IBinder>& handle);
    sp<Layer> handleLayerCreatedLocked(const sp<IBinder>& handle) REQUIRES(mStateLock);