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

Commit 73fe8151 authored by Rachel Lee's avatar Rachel Lee
Browse files

Return frame period from vsynctracker.

The period from the vsync tracker is based on historical actual device
period, rather than the "ideal" device config period.

Test: atest libsurfaceflinger_unittest
Bug: 226242194
Change-Id: I1aed71da363cef8d7f987d35bd083e6e8355d7a7
parent 7be8557f
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -167,18 +167,19 @@ impl::EventThread::ThrottleVsyncCallback Scheduler::makeThrottleVsyncCallback()
impl::EventThread::GetVsyncPeriodFunction Scheduler::makeGetVsyncPeriodFunction() const {
impl::EventThread::GetVsyncPeriodFunction Scheduler::makeGetVsyncPeriodFunction() const {
    return [this](uid_t uid) {
    return [this](uid_t uid) {
        const Fps refreshRate = holdRefreshRateConfigs()->getActiveMode()->getFps();
        const Fps refreshRate = holdRefreshRateConfigs()->getActiveMode()->getFps();
        const nsecs_t basePeriod = refreshRate.getPeriodNsecs();
        const auto currentPeriod =
                mVsyncSchedule->getTracker().currentPeriod() ?: refreshRate.getPeriodNsecs();


        const auto frameRate = getFrameRateOverride(uid);
        const auto frameRate = getFrameRateOverride(uid);
        if (!frameRate.has_value()) {
        if (!frameRate.has_value()) {
            return basePeriod;
            return currentPeriod;
        }
        }


        const auto divisor = RefreshRateConfigs::getFrameRateDivisor(refreshRate, *frameRate);
        const auto divisor = RefreshRateConfigs::getFrameRateDivisor(refreshRate, *frameRate);
        if (divisor <= 1) {
        if (divisor <= 1) {
            return basePeriod;
            return currentPeriod;
        }
        }
        return basePeriod * divisor;
        return currentPeriod * divisor;
    };
    };
}
}