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

Commit 2fa85014 authored by Matt Buckley's avatar Matt Buckley
Browse files

Refactor adpf cpu hints to use TimePoint and Duration

Replace nsecs_t in adpf cpu hint sessions in PowerAdvisor with new
TimePoints and Durations

Additionally, added TimePoint::now() to make getting current time
cleaner

Bug: b/244358432
Test: atest libsurfaceflinger_unittest
Change-Id: I8b4d6f3de8204aa34cd9d8687febfde580deea92
parent 44e612e8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ bool Display::chooseCompositionStrategy(
        return false;
    }

    const nsecs_t startTime = systemTime();
    const TimePoint startTime = TimePoint::now();

    // Get any composition changes requested by the HWC device, and apply them.
    std::optional<android::HWComposer::DeviceRequestedChanges> changes;
@@ -261,7 +261,7 @@ bool Display::chooseCompositionStrategy(
    }

    if (isPowerHintSessionEnabled()) {
        mPowerAdvisor->setHwcValidateTiming(mId, startTime, systemTime());
        mPowerAdvisor->setHwcValidateTiming(mId, startTime, TimePoint::now());
        mPowerAdvisor->setRequiresClientComposition(mId, requiresClientComposition);
    }

@@ -365,7 +365,7 @@ compositionengine::Output::FrameFences Display::presentAndGetFrameFences() {

    auto& hwc = getCompositionEngine().getHwComposer();

    const nsecs_t startTime = systemTime();
    const TimePoint startTime = TimePoint::now();

    if (isPowerHintSessionEnabled()) {
        if (!getCompositionEngine().getHwComposer().getComposer()->isSupported(
@@ -379,7 +379,7 @@ compositionengine::Output::FrameFences Display::presentAndGetFrameFences() {
                                   getState().previousPresentFence);

    if (isPowerHintSessionEnabled()) {
        mPowerAdvisor->setHwcPresentTiming(mId, startTime, systemTime());
        mPowerAdvisor->setHwcPresentTiming(mId, startTime, TimePoint::now());
    }

    fences.presentFence = hwc.getPresentFence(*halDisplayIdOpt);
+10 −11
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public:
    MOCK_METHOD(bool, usePowerHintSession, (), (override));
    MOCK_METHOD(bool, supportsPowerHintSession, (), (override));
    MOCK_METHOD(bool, isPowerHintSessionRunning, (), (override));
    MOCK_METHOD(void, setTargetWorkDuration, (int64_t targetDuration), (override));
    MOCK_METHOD(void, setTargetWorkDuration, (Duration targetDuration), (override));
    MOCK_METHOD(void, sendActualWorkDuration, (), (override));
    MOCK_METHOD(void, sendPredictedWorkDuration, (), (override));
    MOCK_METHOD(void, enablePowerHint, (bool enabled), (override));
@@ -46,25 +46,24 @@ public:
    MOCK_METHOD(void, setGpuFenceTime,
                (DisplayId displayId, std::unique_ptr<FenceTime>&& fenceTime), (override));
    MOCK_METHOD(void, setHwcValidateTiming,
                (DisplayId displayId, nsecs_t valiateStartTime, nsecs_t validateEndTime),
                (DisplayId displayId, TimePoint validateStartTime, TimePoint validateEndTime),
                (override));
    MOCK_METHOD(void, setHwcPresentTiming,
                (DisplayId displayId, nsecs_t presentStartTime, nsecs_t presentEndTime),
                (DisplayId displayId, TimePoint presentStartTime, TimePoint presentEndTime),
                (override));
    MOCK_METHOD(void, setSkippedValidate, (DisplayId displayId, bool skipped), (override));
    MOCK_METHOD(void, setRequiresClientComposition,
                (DisplayId displayId, bool requiresClientComposition), (override));
    MOCK_METHOD(void, setExpectedPresentTime, (nsecs_t expectedPresentTime), (override));
    MOCK_METHOD(void, setSfPresentTiming, (nsecs_t presentFenceTime, nsecs_t presentEndTime),
    MOCK_METHOD(void, setExpectedPresentTime, (TimePoint expectedPresentTime), (override));
    MOCK_METHOD(void, setSfPresentTiming, (TimePoint presentFenceTime, TimePoint presentEndTime),
                (override));
    MOCK_METHOD(void, setHwcPresentDelayedTime,
                (DisplayId displayId,
                 std::chrono::steady_clock::time_point earliestFrameStartTime));
    MOCK_METHOD(void, setFrameDelay, (nsecs_t frameDelayDuration), (override));
    MOCK_METHOD(void, setCommitStart, (nsecs_t commitStartTime), (override));
    MOCK_METHOD(void, setCompositeEnd, (nsecs_t compositeEndtime), (override));
                (DisplayId displayId, TimePoint earliestFrameStartTime));
    MOCK_METHOD(void, setFrameDelay, (Duration frameDelayDuration), (override));
    MOCK_METHOD(void, setCommitStart, (TimePoint commitStartTime), (override));
    MOCK_METHOD(void, setCompositeEnd, (TimePoint compositeEndTime), (override));
    MOCK_METHOD(void, setDisplays, (std::vector<DisplayId> & displayIds), (override));
    MOCK_METHOD(void, setTotalFrameTargetWorkDuration, (int64_t targetDuration), (override));
    MOCK_METHOD(void, setTotalFrameTargetWorkDuration, (Duration targetDuration), (override));
};

} // namespace mock
+88 −88

File changed.

Preview size limit exceeded, changes collapsed.

+70 −69

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ struct TimePoint : scheduler::SchedulerClock::time_point {

    static constexpr TimePoint fromNs(nsecs_t);

    static TimePoint now() { return scheduler::SchedulerClock::now(); };

    nsecs_t ns() const;
};

Loading