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

Commit 0a879b6b authored by Vishnu Nair's avatar Vishnu Nair Committed by Automerger Merge Worker
Browse files

Merge "SF: Avoid promoting parent layer in binder thread" into sc-dev am: aff187c3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/15276211

Change-Id: I463456553ece9da19064633bd22e325d5fddf59a
parents f57a4d8a aff187c3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -796,6 +796,11 @@ public:
    // for symmetry with Vector::remove
    ssize_t removeChild(const sp<Layer>& layer);
    sp<Layer> getParent() const { return mCurrentParent.promote(); }

    // Should be called with the surfaceflinger statelock held
    bool isAtRoot() const { return mIsAtRoot; }
    void setIsAtRoot(bool isAtRoot) { mIsAtRoot = isAtRoot; }

    bool hasParent() const { return getParent() != nullptr; }
    Rect getScreenBounds(bool reduceTransparentRegion = true) const;
    bool setChildLayer(const sp<Layer>& childLayer, int32_t z);
@@ -1103,6 +1108,8 @@ private:

    // A list of regions on this layer that should have blurs.
    const std::vector<BlurRegion> getBlurRegions() const;

    bool mIsAtRoot = false;
};

std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate);
+1 −0
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ bool RefreshRateOverlay::createLayer() {
    Mutex::Autolock _l(mFlinger.mStateLock);
    mLayer = mClient->getLayerUser(mIBinder);
    mLayer->setFrameRate(Layer::FrameRate(Fps(0.0f), Layer::FrameRateCompatibility::NoVote));
    mLayer->setIsAtRoot(true);

    // setting Layer's Z requires resorting layersSortedByZ
    ssize_t idx = mFlinger.mDrawingState.layersSortedByZ.indexOf(mLayer);
+4 −1
Original line number Diff line number Diff line
@@ -4181,6 +4181,7 @@ uint32_t SurfaceFlinger::setClientStateLocked(
                : nullptr;
        if (layer->reparent(parentHandle)) {
            if (!hadParent) {
                layer->setIsAtRoot(false);
                mCurrentState.layersSortedByZ.remove(layer);
            }
            flags |= eTransactionNeeded | eTraversalNeeded;
@@ -4447,7 +4448,8 @@ void SurfaceFlinger::onHandleDestroyed(sp<Layer>& layer) {
    // with the idea that the parent holds a reference and will eventually
    // be cleaned up. However no one cleans up the top-level so we do so
    // here.
    if (layer->getParent() == nullptr) {
    if (layer->isAtRoot()) {
        layer->setIsAtRoot(false);
        mCurrentState.layersSortedByZ.remove(layer);
    }
    markLayerPendingRemovalLocked(layer);
@@ -6924,6 +6926,7 @@ sp<Layer> SurfaceFlinger::handleLayerCreatedLocked(const sp<IBinder>& handle, bo
    }

    if (parent == nullptr && allowAddRoot) {
        layer->setIsAtRoot(true);
        mCurrentState.layersSortedByZ.add(layer);
    } else if (parent == nullptr) {
        layer->onRemovedFromCurrentState();