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
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 75b07a8..402a3d2 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -201,19 +201,6 @@
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 1b8a3a8..3e3f558 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -203,8 +203,6 @@
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 1258509..503741f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -4013,7 +4013,8 @@
}
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 @@
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 6b31135..e4b708a 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -876,22 +876,19 @@
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());
- 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();
- }
+ display.selectorPtr->dump(dumper);
+ display.targeterPtr->dump(dumper);
+ dumper.eol();
}
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9633cc5..0793e85 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2187,14 +2187,6 @@
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::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 @@
// 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 8b71f3b..0a236bd 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1068,11 +1068,6 @@
REQUIRES(mStateLock, kMainThreadContext);
/*
- * VSYNC
- */
- nsecs_t getVsyncPeriodFromHWC() const REQUIRES(mStateLock);
-
- /*
* Display identification
*/
sp<display::DisplayToken> getPhysicalDisplayTokenLocked(PhysicalDisplayId displayId) const