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

Commit 5123e684 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Fix two queries for the past VSYNC's fence

...which did not consider the case of targeting two VSYNCs ahead.

Bug: 241285475
Test: libscheduler_test after Idf9f43b37f3479c94a478d154eaa46f43e0c6c9d
Change-Id: Ib114ffc1866aa32e6d493e06dcf5a27652d19a39
parent 42ccc934
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -2149,7 +2149,8 @@ void SurfaceFlinger::setVsyncEnabled(PhysicalDisplayId id, bool enabled) {
bool SurfaceFlinger::wouldPresentEarly(TimePoint frameTime, Period vsyncPeriod) const {
    const bool isThreeVsyncsAhead = mExpectedPresentTime - frameTime > 2 * vsyncPeriod;
    return isThreeVsyncsAhead ||
            mPreviousPresentFences[0].fenceTime->getSignalTime() != Fence::SIGNAL_TIME_PENDING;
            getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime() !=
            Fence::SIGNAL_TIME_PENDING;
}

auto SurfaceFlinger::getPreviousPresentFence(TimePoint frameTime, Period vsyncPeriod) const
@@ -2657,9 +2658,10 @@ void SurfaceFlinger::composite(TimePoint frameTime, VsyncId vsyncId)

    // Send a power hint hint after presentation is finished
    if (mPowerHintSessionEnabled) {
        mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(mPreviousPresentFences[0]
                                                                    .fenceTime->getSignalTime()),
                                          TimePoint::now());
        const nsecs_t pastPresentTime =
                getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime();

        mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(pastPresentTime), TimePoint::now());
        mPowerAdvisor->reportActualWorkDuration();
    }