Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.h +11 −8 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ public: int configId; // Human readable name of the refresh rate. std::string name; // Refresh rate in frames per second, rounded to the nearest integer. uint32_t fps = 0; }; // TODO(b/122916473): Get this information from configs prepared by vendors, instead of Loading @@ -63,7 +65,7 @@ private: void init(const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) { // This is the rate that HWC encapsulates right now when the device is in DOZE mode. mRefreshRates.push_back( RefreshRate{RefreshRateType::POWER_SAVING, SCREEN_OFF_CONFIG_ID, "ScreenOff"}); RefreshRate{RefreshRateType::POWER_SAVING, SCREEN_OFF_CONFIG_ID, "ScreenOff", 0}); if (configs.size() < 1) { ALOGE("Device does not have valid configs. Config size is 0."); Loading @@ -86,10 +88,11 @@ private: nsecs_t vsyncPeriod = configIdToVsyncPeriod[0].second; if (vsyncPeriod != 0) { const float fps = 1e9 / vsyncPeriod; mRefreshRates.push_back(RefreshRate{RefreshRateType::DEFAULT, configIdToVsyncPeriod[0].first, base::StringPrintf("%2.ffps", fps)}); mRefreshRates.push_back( RefreshRate{RefreshRateType::DEFAULT, configIdToVsyncPeriod[0].first, base::StringPrintf("%2.ffps", fps), static_cast<uint32_t>(fps)}); } if (configs.size() < 2) { return; } Loading @@ -99,9 +102,9 @@ private: vsyncPeriod = configIdToVsyncPeriod[1].second; if (vsyncPeriod != 0) { const float fps = 1e9 / vsyncPeriod; mRefreshRates.push_back(RefreshRate{RefreshRateType::PERFORMANCE, configIdToVsyncPeriod[1].first, base::StringPrintf("%2.ffps", fps)}); mRefreshRates.push_back( RefreshRate{RefreshRateType::PERFORMANCE, configIdToVsyncPeriod[1].first, base::StringPrintf("%2.ffps", fps), static_cast<uint32_t>(fps)}); } } Loading services/surfaceflinger/Scheduler/RefreshRateStats.h +15 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "Scheduler/RefreshRateConfigs.h" #include "Scheduler/SchedulerUtils.h" #include "TimeStats/TimeStats.h" #include "android-base/stringprintf.h" #include "utils/Timers.h" Loading @@ -41,8 +42,10 @@ class RefreshRateStats { public: explicit RefreshRateStats( const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs, const std::shared_ptr<TimeStats>& timeStats) : mRefreshRateConfigs(std::make_unique<RefreshRateConfigs>(configs)), mTimeStats(timeStats), mPreviousRecordedTime(systemTime()) {} ~RefreshRateStats() = default; Loading Loading @@ -116,10 +119,16 @@ private: // this method was called. void flushTimeForMode(int mode) { nsecs_t currentTime = systemTime(); int64_t timeElapsedMs = ns2ms(currentTime - mPreviousRecordedTime); nsecs_t timeElapsed = currentTime - mPreviousRecordedTime; int64_t timeElapsedMs = ns2ms(timeElapsed); mPreviousRecordedTime = currentTime; mConfigModesTotalTime[mode] += timeElapsedMs; for (const auto& config : mRefreshRateConfigs->getRefreshRates()) { if (config.configId == mode) { mTimeStats->recordRefreshRate(config.fps, timeElapsed); } } } // Formats the time in milliseconds into easy to read format. Loading @@ -136,6 +145,9 @@ private: // Keeps information about refresh rate configs that device has. std::unique_ptr<RefreshRateConfigs> mRefreshRateConfigs; // Aggregate refresh rate statistics for telemetry. std::shared_ptr<TimeStats> mTimeStats; int64_t mCurrentConfigMode = 0; int32_t mCurrentPowerMode = HWC_POWER_MODE_OFF; Loading services/surfaceflinger/SurfaceFlinger.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -742,8 +742,10 @@ void SurfaceFlinger::init() { mVsyncModulator.setPhaseOffsets(early, gl, late); setRefreshRateTo(90.f /* fps */); }); mRefreshRateStats = std::make_unique<scheduler::RefreshRateStats>( getHwComposer().getConfigs(*display->getId())); mRefreshRateStats = std::make_unique<scheduler::RefreshRateStats>(getHwComposer().getConfigs( *display->getId()), mTimeStats); } ALOGV("Done initializing"); Loading services/surfaceflinger/SurfaceFlinger.h +1 −1 Original line number Diff line number Diff line Loading @@ -1000,7 +1000,7 @@ private: std::unique_ptr<SurfaceInterceptor> mInterceptor{mFactory.createSurfaceInterceptor(this)}; SurfaceTracing mTracing; LayerStats mLayerStats; std::unique_ptr<TimeStats> mTimeStats; std::shared_ptr<TimeStats> mTimeStats; bool mUseHwcVirtualDisplays = false; std::atomic<uint32_t> mFrameMissedCount{0}; Loading services/surfaceflinger/SurfaceFlingerFactory.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -128,8 +128,8 @@ sp<SurfaceFlinger> createSurfaceFlinger() { return new ColorLayer(args); } std::unique_ptr<TimeStats> createTimeStats() override { return std::make_unique<TimeStats>(); std::shared_ptr<TimeStats> createTimeStats() override { return std::make_shared<android::impl::TimeStats>(); } }; static Factory factory; Loading Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.h +11 −8 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ public: int configId; // Human readable name of the refresh rate. std::string name; // Refresh rate in frames per second, rounded to the nearest integer. uint32_t fps = 0; }; // TODO(b/122916473): Get this information from configs prepared by vendors, instead of Loading @@ -63,7 +65,7 @@ private: void init(const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) { // This is the rate that HWC encapsulates right now when the device is in DOZE mode. mRefreshRates.push_back( RefreshRate{RefreshRateType::POWER_SAVING, SCREEN_OFF_CONFIG_ID, "ScreenOff"}); RefreshRate{RefreshRateType::POWER_SAVING, SCREEN_OFF_CONFIG_ID, "ScreenOff", 0}); if (configs.size() < 1) { ALOGE("Device does not have valid configs. Config size is 0."); Loading @@ -86,10 +88,11 @@ private: nsecs_t vsyncPeriod = configIdToVsyncPeriod[0].second; if (vsyncPeriod != 0) { const float fps = 1e9 / vsyncPeriod; mRefreshRates.push_back(RefreshRate{RefreshRateType::DEFAULT, configIdToVsyncPeriod[0].first, base::StringPrintf("%2.ffps", fps)}); mRefreshRates.push_back( RefreshRate{RefreshRateType::DEFAULT, configIdToVsyncPeriod[0].first, base::StringPrintf("%2.ffps", fps), static_cast<uint32_t>(fps)}); } if (configs.size() < 2) { return; } Loading @@ -99,9 +102,9 @@ private: vsyncPeriod = configIdToVsyncPeriod[1].second; if (vsyncPeriod != 0) { const float fps = 1e9 / vsyncPeriod; mRefreshRates.push_back(RefreshRate{RefreshRateType::PERFORMANCE, configIdToVsyncPeriod[1].first, base::StringPrintf("%2.ffps", fps)}); mRefreshRates.push_back( RefreshRate{RefreshRateType::PERFORMANCE, configIdToVsyncPeriod[1].first, base::StringPrintf("%2.ffps", fps), static_cast<uint32_t>(fps)}); } } Loading
services/surfaceflinger/Scheduler/RefreshRateStats.h +15 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "Scheduler/RefreshRateConfigs.h" #include "Scheduler/SchedulerUtils.h" #include "TimeStats/TimeStats.h" #include "android-base/stringprintf.h" #include "utils/Timers.h" Loading @@ -41,8 +42,10 @@ class RefreshRateStats { public: explicit RefreshRateStats( const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs, const std::shared_ptr<TimeStats>& timeStats) : mRefreshRateConfigs(std::make_unique<RefreshRateConfigs>(configs)), mTimeStats(timeStats), mPreviousRecordedTime(systemTime()) {} ~RefreshRateStats() = default; Loading Loading @@ -116,10 +119,16 @@ private: // this method was called. void flushTimeForMode(int mode) { nsecs_t currentTime = systemTime(); int64_t timeElapsedMs = ns2ms(currentTime - mPreviousRecordedTime); nsecs_t timeElapsed = currentTime - mPreviousRecordedTime; int64_t timeElapsedMs = ns2ms(timeElapsed); mPreviousRecordedTime = currentTime; mConfigModesTotalTime[mode] += timeElapsedMs; for (const auto& config : mRefreshRateConfigs->getRefreshRates()) { if (config.configId == mode) { mTimeStats->recordRefreshRate(config.fps, timeElapsed); } } } // Formats the time in milliseconds into easy to read format. Loading @@ -136,6 +145,9 @@ private: // Keeps information about refresh rate configs that device has. std::unique_ptr<RefreshRateConfigs> mRefreshRateConfigs; // Aggregate refresh rate statistics for telemetry. std::shared_ptr<TimeStats> mTimeStats; int64_t mCurrentConfigMode = 0; int32_t mCurrentPowerMode = HWC_POWER_MODE_OFF; Loading
services/surfaceflinger/SurfaceFlinger.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -742,8 +742,10 @@ void SurfaceFlinger::init() { mVsyncModulator.setPhaseOffsets(early, gl, late); setRefreshRateTo(90.f /* fps */); }); mRefreshRateStats = std::make_unique<scheduler::RefreshRateStats>( getHwComposer().getConfigs(*display->getId())); mRefreshRateStats = std::make_unique<scheduler::RefreshRateStats>(getHwComposer().getConfigs( *display->getId()), mTimeStats); } ALOGV("Done initializing"); Loading
services/surfaceflinger/SurfaceFlinger.h +1 −1 Original line number Diff line number Diff line Loading @@ -1000,7 +1000,7 @@ private: std::unique_ptr<SurfaceInterceptor> mInterceptor{mFactory.createSurfaceInterceptor(this)}; SurfaceTracing mTracing; LayerStats mLayerStats; std::unique_ptr<TimeStats> mTimeStats; std::shared_ptr<TimeStats> mTimeStats; bool mUseHwcVirtualDisplays = false; std::atomic<uint32_t> mFrameMissedCount{0}; Loading
services/surfaceflinger/SurfaceFlingerFactory.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -128,8 +128,8 @@ sp<SurfaceFlinger> createSurfaceFlinger() { return new ColorLayer(args); } std::unique_ptr<TimeStats> createTimeStats() override { return std::make_unique<TimeStats>(); std::shared_ptr<TimeStats> createTimeStats() override { return std::make_shared<android::impl::TimeStats>(); } }; static Factory factory; Loading