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

Commit a31e51ca authored by Ram Indani's avatar Ram Indani Committed by Android (Google) Code Review
Browse files

Merge "[SF] Check mode in VSyncPredictor to complete the mode transition" into main

parents 4922fa5a d17261e7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -68,6 +68,13 @@ public:

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

    if (!mSupportKernelIdleTimer &&
        modePtr->getVsyncRate().getPeriodNsecs() == mTracker.currentPeriod() && !force) {
    if (!mSupportKernelIdleTimer && mTracker.isCurrentMode(modePtr) && !force) {
        endPeriodTransition();
        setIgnorePresentFencesInternal(false);
        mMoreSamplesNeeded = false;
+5 −0
Original line number Diff line number Diff line
@@ -71,6 +71,11 @@ public:
     */
    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. */
    virtual void resetModel() = 0;

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

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