diff options
author | 2024-07-26 10:09:31 -0400 | |
---|---|---|
committer | 2024-08-14 15:38:33 -0400 | |
commit | fe749dc40253424290a50034ead1450af8bb73b0 (patch) | |
tree | 3a937f96bec9835ba1e61e858bf9b06fe51a0b20 | |
parent | 9d934309cc1dd4eb01b0cda17047f1b18cc8c9ed (diff) |
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
-rw-r--r-- | services/surfaceflinger/DisplayDevice.cpp | 13 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayDevice.h | 2 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 10 | ||||
-rw-r--r-- | services/surfaceflinger/Scheduler/Scheduler.cpp | 27 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 15 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 5 |
6 files changed, 21 insertions, 51 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 75b07a8854..402a3d2e2f 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -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; } diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h index 1b8a3a8f54..3e3f558cee 100644 --- a/services/surfaceflinger/DisplayDevice.h +++ b/services/surfaceflinger/DisplayDevice.h @@ -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 diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 1258509570..503741f20e 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -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, diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp index 6b3113512e..e4b708ad42 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.cpp +++ b/services/surfaceflinger/Scheduler/Scheduler.cpp @@ -876,22 +876,19 @@ 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); + std::scoped_lock lock(mDisplayLock); + ftl::FakeGuard guard(kMainThreadContext); - for (const auto& [id, display] : mDisplays) { - utils::Dumper::Section - section(dumper, - id == mPacesetterDisplayId - ? ftl::Concat("Pacesetter Display ", id.value).c_str() - : ftl::Concat("Follower Display ", id.value).c_str()); - - display.targeterPtr->dump(dumper); - dumper.eol(); - } + for (const auto& [id, display] : mDisplays) { + utils::Dumper::Section + section(dumper, + id == mPacesetterDisplayId + ? 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(); } } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 9633cc5c9d..0793e85a75 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -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 { diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 8b71f3be55..0a236bdf77 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -1068,11 +1068,6 @@ private: REQUIRES(mStateLock, kMainThreadContext); /* - * VSYNC - */ - nsecs_t getVsyncPeriodFromHWC() const REQUIRES(mStateLock); - - /* * Display identification */ sp<display::DisplayToken> getPhysicalDisplayTokenLocked(PhysicalDisplayId displayId) const |