diff options
author | Ram Indani <ramindani@google.com> | 2023-12-13 19:03:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-12-13 19:03:17 +0000 |
commit | a4cf4de2acb87e1ef98e93962e191be4a6abaf33 (patch) | |
tree | c2a9898849830142ae36c38cc1f65a5f53c34670 | |
parent | 8a867151ae352672e9388618cc8de2d7a7fb2943 (diff) | |
parent | 19919ff8ed414ef62bb5287f51b3e6a30640d9c6 (diff) | |
download | native-a4cf4de2acb87e1ef98e93962e191be4a6abaf33.tar.gz |
Merge "[SF] Update to use RefreshRateChangedDebugData.refreshPeriodNanos" into main
9 files changed, 20 insertions, 23 deletions
diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp index f7bfbce65b..64a8ae7fcd 100644 --- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp @@ -291,7 +291,7 @@ bool AidlComposer::isSupported(OptionalFeature feature) const { } } -bool AidlComposer::getDisplayConfigurationsSupported() const { +bool AidlComposer::isVrrSupported() const { return mComposerInterfaceVersion >= 3 && FlagManager::getInstance().vrr_config(); } diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h index 316cdee7ab..ea0e53a202 100644 --- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h @@ -66,7 +66,7 @@ public: ~AidlComposer() override; bool isSupported(OptionalFeature) const; - bool getDisplayConfigurationsSupported() const; + bool isVrrSupported() const; std::vector<aidl::android::hardware::graphics::composer3::Capability> getCapabilities() override; diff --git a/services/surfaceflinger/DisplayHardware/ComposerHal.h b/services/surfaceflinger/DisplayHardware/ComposerHal.h index 1a24222af3..bc067a0e5d 100644 --- a/services/surfaceflinger/DisplayHardware/ComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/ComposerHal.h @@ -105,7 +105,7 @@ public: }; virtual bool isSupported(OptionalFeature) const = 0; - virtual bool getDisplayConfigurationsSupported() const = 0; + virtual bool isVrrSupported() const = 0; virtual std::vector<aidl::android::hardware::graphics::composer3::Capability> getCapabilities() = 0; diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 6b67865bdb..2e8ecba8be 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -321,7 +321,7 @@ std::vector<HWComposer::HWCDisplayMode> HWComposer::getModes(PhysicalDisplayId d const auto hwcDisplayId = mDisplayData.at(displayId).hwcDisplay->getId(); - if (mComposer->getDisplayConfigurationsSupported()) { + if (mComposer->isVrrSupported()) { return getModesFromDisplayConfigurations(hwcDisplayId, maxFrameIntervalNs); } diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp index 5f1d5f8164..c4ff9cc6be 100644 --- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp @@ -276,8 +276,8 @@ bool HidlComposer::isSupported(OptionalFeature feature) const { } } -bool HidlComposer::getDisplayConfigurationsSupported() const { - // getDisplayConfigurations is not supported on the HIDL composer. +bool HidlComposer::isVrrSupported() const { + // VRR is not supported on the HIDL composer. return false; }; diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h index c768d2758d..d78bfb7c6b 100644 --- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h @@ -167,7 +167,7 @@ public: ~HidlComposer() override; bool isSupported(OptionalFeature) const; - bool getDisplayConfigurationsSupported() const; + bool isVrrSupported() const; std::vector<aidl::android::hardware::graphics::composer3::Capability> getCapabilities() override; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 9b417c6c96..1f8f2d6c94 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2160,19 +2160,16 @@ void SurfaceFlinger::onComposerHalVsyncIdle(hal::HWDisplayId) { void SurfaceFlinger::onRefreshRateChangedDebug(const RefreshRateChangedDebugData& data) { ATRACE_CALL(); if (const auto displayId = getHwComposer().toPhysicalDisplayId(data.display); displayId) { - const Fps fps = Fps::fromPeriodNsecs(data.vsyncPeriodNanos); - ATRACE_FORMAT("%s Fps %d", __func__, fps.getIntValue()); + const char* const whence = __func__; static_cast<void>(mScheduler->schedule([=]() FTL_FAKE_GUARD(mStateLock) { - { - { - const auto display = getDisplayDeviceLocked(*displayId); - FTL_FAKE_GUARD(kMainThreadContext, - display->updateRefreshRateOverlayRate(fps, - display->getActiveMode() - .fps, - /* setByHwc */ true)); - } - } + const Fps fps = Fps::fromPeriodNsecs(getHwComposer().getComposer()->isVrrSupported() + ? data.refreshPeriodNanos + : data.vsyncPeriodNanos); + ATRACE_FORMAT("%s Fps %d", whence, fps.getIntValue()); + const auto display = getDisplayDeviceLocked(*displayId); + FTL_FAKE_GUARD(kMainThreadContext, + display->updateRefreshRateOverlayRate(fps, display->getActiveMode().fps, + /* setByHwc */ true)); })); } } diff --git a/services/surfaceflinger/tests/unittests/HWComposerTest.cpp b/services/surfaceflinger/tests/unittests/HWComposerTest.cpp index d3ce4f2b90..c5e179fb4c 100644 --- a/services/surfaceflinger/tests/unittests/HWComposerTest.cpp +++ b/services/surfaceflinger/tests/unittests/HWComposerTest.cpp @@ -143,7 +143,7 @@ TEST_F(HWComposerTest, getModesWithLegacyDisplayConfigs) { const auto info = mHwc.onHotplug(kHwcDisplayId, hal::Connection::CONNECTED); ASSERT_TRUE(info); - EXPECT_CALL(*mHal, getDisplayConfigurationsSupported()).WillRepeatedly(Return(false)); + EXPECT_CALL(*mHal, isVrrSupported()).WillRepeatedly(Return(false)); { EXPECT_CALL(*mHal, getDisplayConfigs(kHwcDisplayId, _)) @@ -235,7 +235,7 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_OFF) { const auto info = mHwc.onHotplug(kHwcDisplayId, hal::Connection::CONNECTED); ASSERT_TRUE(info); - EXPECT_CALL(*mHal, getDisplayConfigurationsSupported()).WillRepeatedly(Return(false)); + EXPECT_CALL(*mHal, isVrrSupported()).WillRepeatedly(Return(false)); { EXPECT_CALL(*mHal, getDisplayConfigs(kHwcDisplayId, _)) @@ -324,7 +324,7 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) { const auto info = mHwc.onHotplug(kHwcDisplayId, hal::Connection::CONNECTED); ASSERT_TRUE(info); - EXPECT_CALL(*mHal, getDisplayConfigurationsSupported()).WillRepeatedly(Return(true)); + EXPECT_CALL(*mHal, isVrrSupported()).WillRepeatedly(Return(true)); { EXPECT_CALL(*mHal, getDisplayConfigurations(kHwcDisplayId, _, _)) diff --git a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h index d649679ac8..184dada32e 100644 --- a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h +++ b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h @@ -51,7 +51,7 @@ public: ~Composer() override; MOCK_METHOD(bool, isSupported, (OptionalFeature), (const, override)); - MOCK_METHOD(bool, getDisplayConfigurationsSupported, (), (const, override)); + MOCK_METHOD(bool, isVrrSupported, (), (const, override)); MOCK_METHOD0(getCapabilities, std::vector<aidl::android::hardware::graphics::composer3::Capability>()); MOCK_METHOD0(dumpDebugInfo, std::string()); |