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

Commit fe749dc4 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Remove DisplayDevice::getVsyncPeriodFromHWC

Inline the use in Layer::onCompositionPresented and rewire dumpsys uses.

Bug: 355424160
Flag: EXEMPT refactor
Test: adb shell dumpsys SurfaceFlinger --scheduler
Change-Id: I32f61d16a8bb3045d756a612f7c20ecb3c628771
parent 9d934309
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -201,19 +201,6 @@ bool DisplayDevice::isPoweredOn() const {
    return mPowerMode != hal::PowerMode::OFF;
}

nsecs_t DisplayDevice::getVsyncPeriodFromHWC() const {
    const auto physicalId = getPhysicalId();
    if (!mHwComposer.isConnected(physicalId)) {
        return 0;
    }

    if (const auto vsyncPeriodOpt = mHwComposer.getDisplayVsyncPeriod(physicalId).value_opt()) {
        return *vsyncPeriodOpt;
    }

    return refreshRateSelector().getActiveMode().modePtr->getVsyncRate().getPeriodNsecs();
}

ui::Dataspace DisplayDevice::getCompositionDataSpace() const {
    return mCompositionDisplay->getState().dataspace;
}
+0 −2
Original line number Diff line number Diff line
@@ -203,8 +203,6 @@ public:
    void updateHdrSdrRatioOverlayRatio(float currentHdrSdrRatio);
    bool isHdrSdrRatioOverlayEnabled() const { return mHdrSdrRatioOverlay != nullptr; }

    nsecs_t getVsyncPeriodFromHWC() const;

    Fps getAdjustedRefreshRate() const { return mAdjustedRefreshRate; }

    // Round the requested refresh rate to match a divisor of the pacesetter
+8 −2
Original line number Diff line number Diff line
@@ -4013,7 +4013,8 @@ void Layer::onCompositionPresented(const DisplayDevice* display,
    }

    if (display) {
        const Fps refreshRate = display->refreshRateSelector().getActiveMode().fps;
        const auto activeMode = display->refreshRateSelector().getActiveMode();
        const Fps refreshRate = activeMode.fps;
        const std::optional<Fps> renderRate =
                mFlinger->mScheduler->getFrameRateOverride(getOwnerUid());

@@ -4033,7 +4034,12 @@ void Layer::onCompositionPresented(const DisplayDevice* display,
                    mFlinger->getHwComposer().getPresentTimestamp(*displayId);

            const nsecs_t now = systemTime(CLOCK_MONOTONIC);
            const nsecs_t vsyncPeriod = display->getVsyncPeriodFromHWC();
            const nsecs_t vsyncPeriod =
                    mFlinger->getHwComposer()
                            .getDisplayVsyncPeriod(*displayId)
                            .value_opt()
                            .value_or(activeMode.modePtr->getVsyncRate().getPeriodNsecs());

            const nsecs_t actualPresentTime = now - ((now - presentTimestamp) % vsyncPeriod);

            mFlinger->mTimeStats->setPresentTime(layerId, mCurrentFrameNumber, actualPresentTime,
+12 −15
Original line number Diff line number Diff line
@@ -876,9 +876,6 @@ void Scheduler::dump(utils::Dumper& dumper) const {
    mRefreshRateStats->dump(dumper.out());
    dumper.eol();

    {
        utils::Dumper::Section section(dumper, "Frame Targeting"sv);

    std::scoped_lock lock(mDisplayLock);
    ftl::FakeGuard guard(kMainThreadContext);

@@ -889,11 +886,11 @@ void Scheduler::dump(utils::Dumper& dumper) const {
                                ? ftl::Concat("Pacesetter Display ", id.value).c_str()
                                : ftl::Concat("Follower Display ", id.value).c_str());

        display.selectorPtr->dump(dumper);
        display.targeterPtr->dump(dumper);
        dumper.eol();
    }
}
}

void Scheduler::dumpVsync(std::string& out) const {
    std::scoped_lock lock(mDisplayLock);
+1 −14
Original line number Diff line number Diff line
@@ -2187,14 +2187,6 @@ void SurfaceFlinger::scheduleSample() {
    static_cast<void>(mScheduler->schedule([this] { sample(); }));
}

nsecs_t SurfaceFlinger::getVsyncPeriodFromHWC() const {
    if (const auto display = getDefaultDisplayDeviceLocked()) {
        return display->getVsyncPeriodFromHWC();
    }

    return 0;
}

void SurfaceFlinger::onComposerHalVsync(hal::HWDisplayId hwcDisplayId, int64_t timestamp,
                                        std::optional<hal::VsyncPeriodNanos> vsyncPeriod) {
    if (FlagManager::getInstance().connected_display() && timestamp < 0 &&
@@ -5724,7 +5716,7 @@ void SurfaceFlinger::listLayers(std::string& result) const {
}

void SurfaceFlinger::dumpStats(const DumpArgs& args, std::string& result) const {
    StringAppendF(&result, "%" PRId64 "\n", getVsyncPeriodFromHWC());
    StringAppendF(&result, "%" PRId64 "\n", mScheduler->getPacesetterVsyncPeriod().ns());
    if (args.size() < 2) return;

    const auto name = String8(args[1]);
@@ -5784,11 +5776,6 @@ void SurfaceFlinger::dumpScheduler(std::string& result) const {
    // TODO(b/241285876): Move to DisplayModeController.
    dumper.dump("debugDisplayModeSetByBackdoor"sv, mDebugDisplayModeSetByBackdoor);
    dumper.eol();

    StringAppendF(&result,
                  "         present offset: %9" PRId64 " ns\t        VSYNC period: %9" PRId64
                  " ns\n\n",
                  dispSyncPresentTimeOffset, getVsyncPeriodFromHWC());
}

void SurfaceFlinger::dumpEvents(std::string& result) const {
Loading