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

Commit 28d46a54 authored by Dan Stoza's avatar Dan Stoza
Browse files

SF: Extract onMessageInvalidate

Extracts onMessageInvalidate from onMessageReceived to make it
easier to attribute profiling results to it. Also renames
handleMessageRefresh to onMessageRefresh for consistency.

Test: build, boot, atest libsurfaceflinger_unittest
Bug: 153112939
Change-Id: Ie490113ee676ed6043bc0501ce7cd560f1f4b237
parent c50b6044
Loading
Loading
Loading
Loading
+163 −160
Original line number Diff line number Diff line
@@ -1812,6 +1812,19 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    ATRACE_CALL();
    switch (what) {
        case MessageQueue::INVALIDATE: {
            onMessageInvalidate(expectedVSyncTime);
            break;
        }
        case MessageQueue::REFRESH: {
            onMessageRefresh();
            break;
        }
    }
}

void SurfaceFlinger::onMessageInvalidate(nsecs_t expectedVSyncTime) NO_THREAD_SAFETY_ANALYSIS {
    ATRACE_CALL();

    const nsecs_t frameStart = systemTime();
    // calculate the expected present time once and use the cached
    // value throughout this frame to make sure all layers are
@@ -1830,8 +1843,7 @@ void SurfaceFlinger::onMessageReceived(int32_t what,

    // Pending frames may trigger backpressure propagation.
    const TracedOrdinal<bool> framePending = {"PrevFramePending",
                                                      previousFramePending(
                                                              graceTimeForPresentFenceMs)};
                                              previousFramePending(graceTimeForPresentFenceMs)};

    // Frame missed counts for metrics tracking.
    // A frame is missed if the prior frame is still pending. If no longer pending,
@@ -1845,11 +1857,11 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    mScheduler->getDisplayStatInfo(&stats);
    const nsecs_t frameMissedSlop = stats.vsyncPeriod / 2;
    const nsecs_t previousPresentTime = previousFramePresentTime();
            const TracedOrdinal<bool> frameMissed =
                    {"PrevFrameMissed",
    const TracedOrdinal<bool> frameMissed = {"PrevFrameMissed",
                                             framePending ||
                                                     (previousPresentTime >= 0 &&
                              (lastExpectedPresentTime < previousPresentTime - frameMissedSlop))};
                                                      (lastExpectedPresentTime <
                                                       previousPresentTime - frameMissedSlop))};
    const TracedOrdinal<bool> hwcFrameMissed = {"PrevHwcFrameMissed",
                                                mHadDeviceComposition && frameMissed};
    const TracedOrdinal<bool> gpuFrameMissed = {"PrevGpuFrameMissed",
@@ -1877,7 +1889,7 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    if (mSetActiveConfigPending) {
        if (framePending) {
            mEventQueue->invalidate();
                    break;
            return;
        }

        // We received the present fence from the HWC, so we assume it successfully updated
@@ -1887,10 +1899,9 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    }

    if (framePending && mPropagateBackpressure) {
                if ((hwcFrameMissed && !gpuFrameMissed) ||
                    mPropagateBackpressureClientComposition) {
        if ((hwcFrameMissed && !gpuFrameMissed) || mPropagateBackpressureClientComposition) {
            signalLayerUpdate();
                    break;
            return;
        }
    }

@@ -1981,13 +1992,6 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
        }
        signalRefresh();
    }
            break;
        }
        case MessageQueue::REFRESH: {
            handleMessageRefresh();
            break;
        }
    }
}

bool SurfaceFlinger::handleMessageTransaction() {
@@ -2012,7 +2016,7 @@ bool SurfaceFlinger::handleMessageTransaction() {
    return runHandleTransaction;
}

void SurfaceFlinger::handleMessageRefresh() {
void SurfaceFlinger::onMessageRefresh() {
    ATRACE_CALL();

    mRefreshPending = false;
@@ -2110,7 +2114,6 @@ void SurfaceFlinger::handleMessageRefresh() {
    }
}


bool SurfaceFlinger::handleMessageInvalidate() {
    ATRACE_CALL();
    bool refreshNeeded = handlePageFlip();
+8 −2
Original line number Diff line number Diff line
@@ -580,14 +580,20 @@ private:
            const std::optional<scheduler::RefreshRateConfigs::Policy>& policy, bool overridePolicy)
            EXCLUDES(mStateLock);

    // Handle the INVALIDATE message queue event, latching new buffers and applying
    // incoming transactions
    void onMessageInvalidate(nsecs_t expectedVSyncTime);

    // Returns whether the transaction actually modified any state
    bool handleMessageTransaction();

    // Handle the REFRESH message queue event, sending the current frame down to RenderEngine and
    // the Composer HAL for presentation
    void onMessageRefresh();

    // Returns whether a new buffer has been latched (see handlePageFlip())
    bool handleMessageInvalidate();

    void handleMessageRefresh();

    void handleTransaction(uint32_t transactionFlags);
    void handleTransactionLocked(uint32_t transactionFlags) REQUIRES(mStateLock);