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

Commit d17261e7 authored by ramindani's avatar ramindani
Browse files

[SF] Check mode in VSyncPredictor to complete the mode transition

Test: Checked the trace that minFramePeriod is correct after transition
BUG: 328167952
Change-Id: I09d79a5e9359b8b76aec422e921ae70fad2a79ec
parent 8c86ab3a
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -68,6 +68,13 @@ public:


    void setDisplayModePtr(ftl::NonNull<DisplayModePtr>) final EXCLUDES(mMutex);
    void setDisplayModePtr(ftl::NonNull<DisplayModePtr>) final EXCLUDES(mMutex);


    bool isCurrentMode(const ftl::NonNull<DisplayModePtr>& modePtr) const EXCLUDES(mMutex) {
        std::lock_guard lock(mMutex);
        return mDisplayModePtr->getId() == modePtr->getId() &&
                mDisplayModePtr->getVsyncRate().getPeriodNsecs() ==
                mRateMap.find(idealPeriod())->second.slope;
    }

    void setRenderRate(Fps, bool applyImmediately) final EXCLUDES(mMutex);
    void setRenderRate(Fps, bool applyImmediately) final EXCLUDES(mMutex);


    void onFrameBegin(TimePoint expectedPresentTime, TimePoint lastConfirmedPresentTime) final
    void onFrameBegin(TimePoint expectedPresentTime, TimePoint lastConfirmedPresentTime) final
+1 −2
Original line number Original line Diff line number Diff line
@@ -141,8 +141,7 @@ void VSyncReactor::onDisplayModeChanged(ftl::NonNull<DisplayModePtr> modePtr, bo
    std::lock_guard lock(mMutex);
    std::lock_guard lock(mMutex);
    mLastHwVsync.reset();
    mLastHwVsync.reset();


    if (!mSupportKernelIdleTimer &&
    if (!mSupportKernelIdleTimer && mTracker.isCurrentMode(modePtr) && !force) {
        modePtr->getVsyncRate().getPeriodNsecs() == mTracker.currentPeriod() && !force) {
        endPeriodTransition();
        endPeriodTransition();
        setIgnorePresentFencesInternal(false);
        setIgnorePresentFencesInternal(false);
        mMoreSamplesNeeded = false;
        mMoreSamplesNeeded = false;
+5 −0
Original line number Original line Diff line number Diff line
@@ -71,6 +71,11 @@ public:
     */
     */
    virtual Period minFramePeriod() const = 0;
    virtual Period minFramePeriod() const = 0;


    /**
     * Checks if the sourced mode is equal to the mode in the tracker.
     */
    virtual bool isCurrentMode(const ftl::NonNull<DisplayModePtr>& modePtr) const = 0;

    /* Inform the tracker that the samples it has are not accurate for prediction. */
    /* Inform the tracker that the samples it has are not accurate for prediction. */
    virtual void resetModel() = 0;
    virtual void resetModel() = 0;


+1 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ public:
    void onFrameBegin(TimePoint, TimePoint) final {}
    void onFrameBegin(TimePoint, TimePoint) final {}
    void onFrameMissed(TimePoint) final {}
    void onFrameMissed(TimePoint) final {}
    void dump(std::string&) const final {}
    void dump(std::string&) const final {}
    bool isCurrentMode(const ftl::NonNull<DisplayModePtr>&) const final { return false; };


protected:
protected:
    std::mutex mutable mMutex;
    std::mutex mutable mMutex;
+5 −2
Original line number Original line Diff line number Diff line
@@ -230,7 +230,8 @@ TEST_F(VSyncReactorTest, setPeriodCalledOnceConfirmedChange) {
TEST_F(VSyncReactorTest, changingPeriodBackAbortsConfirmationProcess) {
TEST_F(VSyncReactorTest, changingPeriodBackAbortsConfirmationProcess) {
    nsecs_t sampleTime = 0;
    nsecs_t sampleTime = 0;
    nsecs_t const newPeriod = 5000;
    nsecs_t const newPeriod = 5000;
    mReactor.onDisplayModeChanged(displayMode(newPeriod), false);
    auto modePtr = displayMode(newPeriod);
    mReactor.onDisplayModeChanged(modePtr, false);
    bool periodFlushed = true;
    bool periodFlushed = true;
    EXPECT_TRUE(mReactor.addHwVsyncTimestamp(sampleTime += period, std::nullopt, &periodFlushed));
    EXPECT_TRUE(mReactor.addHwVsyncTimestamp(sampleTime += period, std::nullopt, &periodFlushed));
    EXPECT_FALSE(periodFlushed);
    EXPECT_FALSE(periodFlushed);
@@ -238,7 +239,9 @@ TEST_F(VSyncReactorTest, changingPeriodBackAbortsConfirmationProcess) {
    EXPECT_TRUE(mReactor.addHwVsyncTimestamp(sampleTime += period, std::nullopt, &periodFlushed));
    EXPECT_TRUE(mReactor.addHwVsyncTimestamp(sampleTime += period, std::nullopt, &periodFlushed));
    EXPECT_FALSE(periodFlushed);
    EXPECT_FALSE(periodFlushed);


    mReactor.onDisplayModeChanged(displayMode(period), false);
    modePtr = displayMode(period);
    EXPECT_CALL(*mMockTracker, isCurrentMode(modePtr)).WillOnce(Return(true));
    mReactor.onDisplayModeChanged(modePtr, false);
    EXPECT_FALSE(mReactor.addHwVsyncTimestamp(sampleTime += period, std::nullopt, &periodFlushed));
    EXPECT_FALSE(mReactor.addHwVsyncTimestamp(sampleTime += period, std::nullopt, &periodFlushed));
    EXPECT_FALSE(periodFlushed);
    EXPECT_FALSE(periodFlushed);
}
}
Loading