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

Commit 62007522 authored by ramindani's avatar ramindani
Browse files

SF: Move isWithin into implementation

Update the comment for the freeze timeline at the vsync time.

BUG: 343603085
Test: atest VSyncPredictorTest
Flag: com.android.graphics.surfaceflinger.flags.vrr_bugfix_24q4

Change-Id: I78cbe386983d7f8cefaab1d3b0e94f0a034815af
parent f24d6b43
Loading
Loading
Loading
Loading
+17 −2
Original line number Original line Diff line number Diff line
@@ -400,8 +400,9 @@ void VSyncPredictor::setRenderRate(Fps renderRate, bool applyImmediately) {


    } else {
    } else {
        if (FlagManager::getInstance().vrr_bugfix_24q4()) {
        if (FlagManager::getInstance().vrr_bugfix_24q4()) {
            // We need to freeze the timeline at the committed vsync so that we don't
            // We need to freeze the timeline at the committed vsync, and
            // overshoot the deadline.
            // then use with threshold adjustments when required to avoid
            // marginal errors when checking the vsync on the timeline.
            mTimelines.back().freeze(mLastCommittedVsync);
            mTimelines.back().freeze(mLastCommittedVsync);
        } else {
        } else {
            mTimelines.back().freeze(
            mTimelines.back().freeze(
@@ -779,6 +780,20 @@ void VSyncPredictor::VsyncTimeline::shiftVsyncSequence(Duration phase) {
    }
    }
}
}


VSyncPredictor::VsyncTimeline::VsyncOnTimeline VSyncPredictor::VsyncTimeline::isWithin(
        TimePoint vsync) {
    const auto threshold = mIdealPeriod.ns() / 2;
    if (!mValidUntil || vsync.ns() < mValidUntil->ns() - threshold) {
        // if mValidUntil is absent then timeline is not frozen and
        // vsync should be unique to that timeline.
        return VsyncOnTimeline::Unique;
    }
    if (vsync.ns() > mValidUntil->ns() + threshold) {
        return VsyncOnTimeline::Outside;
    }
    return VsyncOnTimeline::Shared;
}

} // namespace android::scheduler
} // namespace android::scheduler


// TODO(b/129481165): remove the #pragma below and fix conversion issues
// TODO(b/129481165): remove the #pragma below and fix conversion issues
+1 −12
Original line number Original line Diff line number Diff line
@@ -111,18 +111,7 @@ private:
            Shared,  // Within timeline, shared with next timeline.
            Shared,  // Within timeline, shared with next timeline.
            Outside, // Outside of the timeline.
            Outside, // Outside of the timeline.
        };
        };
        VsyncOnTimeline isWithin(TimePoint vsync) {
        VsyncOnTimeline isWithin(TimePoint vsync);
            const auto threshold = mIdealPeriod.ns() / 2;
            if (!mValidUntil || vsync.ns() < mValidUntil->ns() - threshold) {
                // if mValidUntil is absent then timeline is not frozen and
                // vsync should be unique to that timeline.
                return VsyncOnTimeline::Unique;
            }
            if (vsync.ns() > mValidUntil->ns() + threshold) {
                return VsyncOnTimeline::Outside;
            }
            return VsyncOnTimeline::Shared;
        }


    private:
    private:
        nsecs_t snapToVsyncAlignedWithRenderRate(Model model, nsecs_t vsync);
        nsecs_t snapToVsyncAlignedWithRenderRate(Model model, nsecs_t vsync);