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

Commit b5ef0a40 authored by Ady Abraham's avatar Ady Abraham Committed by Automerger Merge Worker
Browse files

Merge "SF: fix expected vsync time when changing work duration" into sc-dev am: 5ede32f2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/15329854

Change-Id: I3a43f2d7b49585e1eae38751cccea3eb06d2676a
parents c47c6feb 5ede32f2
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -84,10 +84,13 @@ ScheduleResult VSyncDispatchTimerQueueEntry::schedule(VSyncDispatch::ScheduleTim
                                                      VSyncTracker& tracker, nsecs_t now) {
                                                      VSyncTracker& tracker, nsecs_t now) {
    auto nextVsyncTime = tracker.nextAnticipatedVSyncTimeFrom(
    auto nextVsyncTime = tracker.nextAnticipatedVSyncTimeFrom(
            std::max(timing.earliestVsync, now + timing.workDuration + timing.readyDuration));
            std::max(timing.earliestVsync, now + timing.workDuration + timing.readyDuration));
    auto nextWakeupTime = nextVsyncTime - timing.workDuration - timing.readyDuration;


    bool const wouldSkipAVsyncTarget =
    bool const wouldSkipAVsyncTarget =
            mArmedInfo && (nextVsyncTime > (mArmedInfo->mActualVsyncTime + mMinVsyncDistance));
            mArmedInfo && (nextVsyncTime > (mArmedInfo->mActualVsyncTime + mMinVsyncDistance));
    if (wouldSkipAVsyncTarget) {
    bool const wouldSkipAWakeup =
            mArmedInfo && ((nextWakeupTime > (mArmedInfo->mActualWakeupTime + mMinVsyncDistance)));
    if (wouldSkipAVsyncTarget && wouldSkipAWakeup) {
        return getExpectedCallbackTime(nextVsyncTime, timing);
        return getExpectedCallbackTime(nextVsyncTime, timing);
    }
    }


@@ -97,9 +100,9 @@ ScheduleResult VSyncDispatchTimerQueueEntry::schedule(VSyncDispatch::ScheduleTim
    if (alreadyDispatchedForVsync) {
    if (alreadyDispatchedForVsync) {
        nextVsyncTime =
        nextVsyncTime =
                tracker.nextAnticipatedVSyncTimeFrom(*mLastDispatchTime + mMinVsyncDistance);
                tracker.nextAnticipatedVSyncTimeFrom(*mLastDispatchTime + mMinVsyncDistance);
        nextWakeupTime = nextVsyncTime - timing.workDuration - timing.readyDuration;
    }
    }


    auto const nextWakeupTime = nextVsyncTime - timing.workDuration - timing.readyDuration;
    auto const nextReadyTime = nextVsyncTime - timing.readyDuration;
    auto const nextReadyTime = nextVsyncTime - timing.readyDuration;
    mScheduleTiming = timing;
    mScheduleTiming = timing;
    mArmedInfo = {nextWakeupTime, nextVsyncTime, nextReadyTime};
    mArmedInfo = {nextWakeupTime, nextVsyncTime, nextReadyTime};
+21 −0
Original line number Original line Diff line number Diff line
@@ -942,6 +942,27 @@ TEST_F(VSyncDispatchTimerQueueTest, basicAlarmSettingFutureWithReadyDuration) {
    EXPECT_THAT(cb.mReadyTime[0], 970);
    EXPECT_THAT(cb.mReadyTime[0], 970);
}
}


TEST_F(VSyncDispatchTimerQueueTest, updatesVsyncTimeForCloseWakeupTime) {
    Sequence seq;
    EXPECT_CALL(mMockClock, alarmAt(_, 600)).InSequence(seq);

    CountingCallback cb(mDispatch);

    mDispatch.schedule(cb, {.workDuration = 400, .readyDuration = 0, .earliestVsync = 1000});
    mDispatch.schedule(cb, {.workDuration = 1400, .readyDuration = 0, .earliestVsync = 1000});

    advanceToNextCallback();

    advanceToNextCallback();

    ASSERT_THAT(cb.mCalls.size(), Eq(1));
    EXPECT_THAT(cb.mCalls[0], Eq(2000));
    ASSERT_THAT(cb.mWakeupTime.size(), Eq(1));
    EXPECT_THAT(cb.mWakeupTime[0], Eq(600));
    ASSERT_THAT(cb.mReadyTime.size(), Eq(1));
    EXPECT_THAT(cb.mReadyTime[0], Eq(2000));
}

class VSyncDispatchTimerQueueEntryTest : public testing::Test {
class VSyncDispatchTimerQueueEntryTest : public testing::Test {
protected:
protected:
    nsecs_t const mPeriod = 1000;
    nsecs_t const mPeriod = 1000;