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

Commit 31be4b3f authored by Chavi Weingarten's avatar Chavi Weingarten Committed by android-build-merger
Browse files

Merge "Ensure currentState is copied to drawingState for offscreen layers"...

Merge "Ensure currentState is copied to drawingState for offscreen layers" into qt-dev am: 38c6856b
am: 792b759b

Change-Id: Ife785571c05fe0dbefe3bfb5dd7b081276c81a7c
parents 9e13a89d 792b759b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -130,7 +130,7 @@ Layer::~Layer() {
    }
    }


    mFrameTracker.logAndResetStats(mName);
    mFrameTracker.logAndResetStats(mName);
    mFlinger->onLayerDestroyed();
    mFlinger->onLayerDestroyed(this);
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
+30 −1
Original line number Original line Diff line number Diff line
@@ -2944,6 +2944,13 @@ void SurfaceFlinger::commitTransaction()
            if (l->isRemovedFromCurrentState()) {
            if (l->isRemovedFromCurrentState()) {
                latchAndReleaseBuffer(l);
                latchAndReleaseBuffer(l);
            }
            }

            // If the layer has been removed and has no parent, then it will not be reachable
            // when traversing layers on screen. Add the layer to the offscreenLayers set to
            // ensure we can copy its current to drawing state.
            if (!l->getParent()) {
                mOffscreenLayers.emplace(l.get());
            }
        }
        }
        mLayersPendingRemoval.clear();
        mLayersPendingRemoval.clear();
    }
    }
@@ -2957,7 +2964,17 @@ void SurfaceFlinger::commitTransaction()
        // clear the "changed" flags in current state
        // clear the "changed" flags in current state
        mCurrentState.colorMatrixChanged = false;
        mCurrentState.colorMatrixChanged = false;


        mDrawingState.traverseInZOrder([](Layer* layer) { layer->commitChildList(); });
        mDrawingState.traverseInZOrder([&](Layer* layer) {
            layer->commitChildList();

            // If the layer can be reached when traversing mDrawingState, then the layer is no
            // longer offscreen. Remove the layer from the offscreenLayer set.
            if (mOffscreenLayers.count(layer)) {
                mOffscreenLayers.erase(layer);
            }
        });

        commitOffscreenLayers();
    });
    });


    mTransactionPending = false;
    mTransactionPending = false;
@@ -2985,6 +3002,18 @@ void SurfaceFlinger::withTracingLock(std::function<void()> lockedOperation) {
    }
    }
}
}


void SurfaceFlinger::commitOffscreenLayers() {
    for (Layer* offscreenLayer : mOffscreenLayers) {
        offscreenLayer->traverseInZOrder(LayerVector::StateSet::Drawing, [](Layer* layer) {
            uint32_t trFlags = layer->getTransactionFlags(eTransactionNeeded);
            if (!trFlags) return;

            layer->doTransaction(0);
            layer->commitChildList();
        });
    }
}

void SurfaceFlinger::computeVisibleRegions(const sp<const DisplayDevice>& displayDevice,
void SurfaceFlinger::computeVisibleRegions(const sp<const DisplayDevice>& displayDevice,
                                           Region& outDirtyRegion, Region& outOpaqueRegion) {
                                           Region& outDirtyRegion, Region& outOpaqueRegion) {
    ATRACE_CALL();
    ATRACE_CALL();
+11 −1
Original line number Original line Diff line number Diff line
@@ -308,7 +308,10 @@ public:
        const sp<IGraphicBufferProducer>& bufferProducer) const;
        const sp<IGraphicBufferProducer>& bufferProducer) const;


    inline void onLayerCreated() { mNumLayers++; }
    inline void onLayerCreated() { mNumLayers++; }
    inline void onLayerDestroyed() { mNumLayers--; }
    inline void onLayerDestroyed(Layer* layer) {
        mNumLayers--;
        mOffscreenLayers.erase(layer);
    }


    TransactionCompletedThread& getTransactionCompletedThread() {
    TransactionCompletedThread& getTransactionCompletedThread() {
        return mTransactionCompletedThread;
        return mTransactionCompletedThread;
@@ -563,6 +566,7 @@ private:
    uint32_t setTransactionFlags(uint32_t flags, Scheduler::TransactionStart transactionStart);
    uint32_t setTransactionFlags(uint32_t flags, Scheduler::TransactionStart transactionStart);
    void latchAndReleaseBuffer(const sp<Layer>& layer);
    void latchAndReleaseBuffer(const sp<Layer>& layer);
    void commitTransaction() REQUIRES(mStateLock);
    void commitTransaction() REQUIRES(mStateLock);
    void commitOffscreenLayers();
    bool containsAnyInvalidClientState(const Vector<ComposerState>& states);
    bool containsAnyInvalidClientState(const Vector<ComposerState>& states);
    bool transactionIsReadyToBeApplied(int64_t desiredPresentTime,
    bool transactionIsReadyToBeApplied(int64_t desiredPresentTime,
                                       const Vector<ComposerState>& states);
                                       const Vector<ComposerState>& states);
@@ -1152,6 +1156,12 @@ private:


    // Flag used to set override allowed display configs from backdoor
    // Flag used to set override allowed display configs from backdoor
    bool mDebugDisplayConfigSetByBackdoor = false;
    bool mDebugDisplayConfigSetByBackdoor = false;

    // A set of layers that have no parent so they are not drawn on screen.
    // Should only be accessed by the main thread.
    // The Layer pointer is removed from the set when the destructor is called so there shouldn't
    // be any issues with a raw pointer referencing an invalid object.
    std::unordered_set<Layer*> mOffscreenLayers;
};
};


} // namespace android
} // namespace android