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

Commit f8975574 authored by Dominik Laskowski's avatar Dominik Laskowski Committed by Automerger Merge Worker
Browse files

Merge changes Ib114ffc1,Ib40794cc into udc-dev am: ec9e1890

parents d1262ccb ec9e1890
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -2146,7 +2146,14 @@ void SurfaceFlinger::setVsyncEnabled(PhysicalDisplayId id, bool enabled) {
    }));
}

auto SurfaceFlinger::getPreviousPresentFence(TimePoint frameTime, Period vsyncPeriod)
bool SurfaceFlinger::wouldPresentEarly(TimePoint frameTime, Period vsyncPeriod) const {
    const bool isThreeVsyncsAhead = mExpectedPresentTime - frameTime > 2 * vsyncPeriod;
    return isThreeVsyncsAhead ||
            getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime() !=
            Fence::SIGNAL_TIME_PENDING;
}

auto SurfaceFlinger::getPreviousPresentFence(TimePoint frameTime, Period vsyncPeriod) const
        -> const FenceTimePtr& {
    const bool isTwoVsyncsAhead = mExpectedPresentTime - frameTime > vsyncPeriod;
    const size_t i = static_cast<size_t>(isTwoVsyncsAhead);
@@ -2614,21 +2621,14 @@ void SurfaceFlinger::composite(TimePoint frameTime, VsyncId vsyncId)
        refreshArgs.devOptFlashDirtyRegionsDelay = std::chrono::milliseconds(mDebugFlashDelay);
    }

    const auto prevVsyncTime = mExpectedPresentTime - mScheduler->getVsyncSchedule()->period();
    const auto hwcMinWorkDuration = mVsyncConfiguration->getCurrentConfigs().hwcMinWorkDuration;

    const Period vsyncPeriod = mScheduler->getVsyncSchedule()->period();
    const bool threeVsyncsAhead = mExpectedPresentTime - frameTime > 2 * vsyncPeriod;

    // We should wait for the earliest present time if HWC doesn't support ExpectedPresentTime,
    // and the next vsync is not already taken by the previous frame.
    const bool waitForEarliestPresent =
            !getHwComposer().getComposer()->isSupported(
    if (!getHwComposer().getComposer()->isSupported(
                Hwc2::Composer::OptionalFeature::ExpectedPresentTime) &&
            (threeVsyncsAhead ||
             mPreviousPresentFences[0].fenceTime->getSignalTime() != Fence::SIGNAL_TIME_PENDING);
        wouldPresentEarly(frameTime, vsyncPeriod)) {
        const auto prevVsyncTime = mExpectedPresentTime - vsyncPeriod;
        const auto hwcMinWorkDuration = mVsyncConfiguration->getCurrentConfigs().hwcMinWorkDuration;

    if (waitForEarliestPresent) {
        refreshArgs.earliestPresentTime = prevVsyncTime - hwcMinWorkDuration;
    }

@@ -2662,9 +2662,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();
    }

+3 −1
Original line number Diff line number Diff line
@@ -998,7 +998,9 @@ private:

    using FenceTimePtr = std::shared_ptr<FenceTime>;

    const FenceTimePtr& getPreviousPresentFence(TimePoint frameTime, Period)
    bool wouldPresentEarly(TimePoint frameTime, Period) const REQUIRES(kMainThreadContext);

    const FenceTimePtr& getPreviousPresentFence(TimePoint frameTime, Period) const
            REQUIRES(kMainThreadContext);

    // Blocks the thread waiting for up to graceTimeMs in case the fence is about to signal.