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

Commit f7a09ed2 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Optimize layer history in scheduler

Register layers with LayerHistory by storing a weak pointer rather than
allocating a LayerHandle. Query layer visibility when needed instead of
synchronizing it to LayerInfo whenever Layer::isVisible is called. Store
active/inactive layers in contiguous memory instead of two hash maps for
cache efficiency, and minimal allocation and run time of operations like
clearing history. Remove redundant ref-counting, locking, and frequency-
period conversion in LayerInfo. Avoid sleeping in unit tests.

This is also prework for per-display layer history.

Bug: 130554049
Bug: 134772048
Test: go/wm-smoke with debug.sf.layer_history_trace
Test: C2/F2 test cases from spreadsheet
Test: LayerHistoryTest with new test cases
Change-Id: Ibfcfe46cd76ebd93b916d4a0c737a19e837d4ff1
parent b74b3767
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -107,11 +107,8 @@ bool BufferLayer::isOpaque(const Layer::State& s) const {
}

bool BufferLayer::isVisible() const {
    bool visible = !(isHiddenByPolicy()) && getAlpha() > 0.0f &&
    return !isHiddenByPolicy() && getAlpha() > 0.0f &&
            (mBufferInfo.mBuffer != nullptr || mSidebandStream != nullptr);
    mFlinger->mScheduler->setLayerVisibility(mSchedulerLayerHandle, visible);

    return visible;
}

bool BufferLayer::isFixedSize() const {
+2 −2
Original line number Diff line number Diff line
@@ -389,7 +389,7 @@ void BufferQueueLayer::onFrameAvailable(const BufferItem& item) {
    { // Autolock scope
        if (mFlinger->mUseSmart90ForVideo) {
            const nsecs_t presentTime = item.mIsAutoTimestamp ? 0 : item.mTimestamp;
            mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime,
            mFlinger->mScheduler->recordLayerHistory(this, presentTime,
                                                     item.mHdrMetadata.validTypes != 0);
        }

+2 −2
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, nsecs_t postTi

    if (mFlinger->mUseSmart90ForVideo) {
        const nsecs_t presentTime = (desiredPresentTime == -1) ? 0 : desiredPresentTime;
        mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime,
        mFlinger->mScheduler->recordLayerHistory(this, presentTime,
                                                 mCurrentState.hdrMetadata.validTypes != 0);
    }

+1 −2
Original line number Diff line number Diff line
@@ -118,10 +118,9 @@ Layer::Layer(const LayerCreationArgs& args)
    mFrameEventHistory.initializeCompositorTiming(compositorTiming);
    mFrameTracker.setDisplayRefreshPeriod(compositorTiming.interval);

    mSchedulerLayerHandle = mFlinger->mScheduler->registerLayer(mName.c_str(), mWindowType);
    mCallingPid = args.callingPid;
    mCallingUid = args.callingUid;
    mFlinger->onLayerCreated();
    mFlinger->onLayerCreated(this);
}

Layer::~Layer() {
+2 −3
Original line number Diff line number Diff line
@@ -221,6 +221,8 @@ public:
    explicit Layer(const LayerCreationArgs& args);
    virtual ~Layer();

    int getWindowType() const { return mWindowType; }

    void setPrimaryDisplayOnly() { mPrimaryDisplayOnly = true; }
    bool getPrimaryDisplayOnly() const { return mPrimaryDisplayOnly; }

@@ -886,9 +888,6 @@ protected:
    // Window types from WindowManager.LayoutParams
    const int mWindowType;

    // This is populated if the layer is registered with Scheduler for tracking purposes.
    std::unique_ptr<scheduler::LayerHistory::LayerHandle> mSchedulerLayerHandle;

private:
    /**
     * Returns an unsorted vector of all layers that are part of this tree.
Loading