Loading services/surfaceflinger/RefreshRateOverlay.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -168,9 +168,9 @@ bool RefreshRateOverlay::createLayer() { } } void RefreshRateOverlay::primeCache() { void RefreshRateOverlay::primeCache() { auto allRefreshRates = mFlinger.mRefreshRateConfigs->getAllRefreshRates(); auto& allRefreshRates = mFlinger.mRefreshRateConfigs->getAllRefreshRates(); if (allRefreshRates.size() == 1) { if (allRefreshRates.size() == 1) { auto fps = allRefreshRates.begin()->second.fps; auto fps = allRefreshRates.begin()->second->fps; half4 color = {LOW_FPS_COLOR, ALPHA}; half4 color = {LOW_FPS_COLOR, ALPHA}; mBufferCache.emplace(fps, SevenSegmentDrawer::drawNumber(fps, color)); mBufferCache.emplace(fps, SevenSegmentDrawer::drawNumber(fps, color)); return; return; Loading @@ -178,8 +178,8 @@ void RefreshRateOverlay::primeCache() { std::vector<uint32_t> supportedFps; std::vector<uint32_t> supportedFps; supportedFps.reserve(allRefreshRates.size()); supportedFps.reserve(allRefreshRates.size()); for (auto [ignored, refreshRate] : allRefreshRates) { for (auto& [ignored, refreshRate] : allRefreshRates) { supportedFps.push_back(refreshRate.fps); supportedFps.push_back(refreshRate->fps); } } std::sort(supportedFps.begin(), supportedFps.end()); std::sort(supportedFps.begin(), supportedFps.end()); Loading services/surfaceflinger/Scheduler/PhaseOffsets.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -71,10 +71,10 @@ std::unordered_map<float, PhaseOffsets::Offsets> PhaseOffsets::initializeOffsets std::unordered_map<float, Offsets> offsets; std::unordered_map<float, Offsets> offsets; for (const auto& [ignored, refreshRate] : refreshRateConfigs.getAllRefreshRates()) { for (const auto& [ignored, refreshRate] : refreshRateConfigs.getAllRefreshRates()) { if (refreshRate.fps > 65.0f) { if (refreshRate->fps > 65.0f) { offsets.emplace(refreshRate.fps, getHighFpsOffsets(refreshRate.vsyncPeriod)); offsets.emplace(refreshRate->fps, getHighFpsOffsets(refreshRate->vsyncPeriod)); } else { } else { offsets.emplace(refreshRate.fps, getDefaultOffsets(refreshRate.vsyncPeriod)); offsets.emplace(refreshRate->fps, getDefaultOffsets(refreshRate->vsyncPeriod)); } } } } return offsets; return offsets; Loading Loading @@ -238,7 +238,7 @@ static std::vector<float> getRefreshRatesFromConfigs( refreshRates.reserve(allRefreshRates.size()); refreshRates.reserve(allRefreshRates.size()); for (const auto& [ignored, refreshRate] : allRefreshRates) { for (const auto& [ignored, refreshRate] : allRefreshRates) { refreshRates.emplace_back(refreshRate.fps); refreshRates.emplace_back(refreshRate->fps); } } return refreshRates; return refreshRates; Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +14 −15 Original line number Original line Diff line number Diff line Loading @@ -286,12 +286,12 @@ const RefreshRate& RefreshRateConfigs::getCurrentRefreshRateByPolicyLocked() con mCurrentRefreshRate) != mAvailableRefreshRates.end()) { mCurrentRefreshRate) != mAvailableRefreshRates.end()) { return *mCurrentRefreshRate; return *mCurrentRefreshRate; } } return mRefreshRates.at(mDefaultConfig); return *mRefreshRates.at(mDefaultConfig); } } void RefreshRateConfigs::setCurrentConfigId(HwcConfigIndexType configId) { void RefreshRateConfigs::setCurrentConfigId(HwcConfigIndexType configId) { std::lock_guard lock(mLock); std::lock_guard lock(mLock); mCurrentRefreshRate = &mRefreshRates.at(configId); mCurrentRefreshRate = mRefreshRates.at(configId).get(); } } RefreshRateConfigs::RefreshRateConfigs(const std::vector<InputConfig>& configs, RefreshRateConfigs::RefreshRateConfigs(const std::vector<InputConfig>& configs, Loading Loading @@ -326,7 +326,7 @@ status_t RefreshRateConfigs::setPolicy(HwcConfigIndexType defaultConfigId, float if (mRefreshRates.count(defaultConfigId) == 0) { if (mRefreshRates.count(defaultConfigId) == 0) { return BAD_VALUE; return BAD_VALUE; } } const RefreshRate& refreshRate = mRefreshRates.at(defaultConfigId); const RefreshRate& refreshRate = *mRefreshRates.at(defaultConfigId); if (!refreshRate.inPolicy(minRefreshRate, maxRefreshRate)) { if (!refreshRate.inPolicy(minRefreshRate, maxRefreshRate)) { return BAD_VALUE; return BAD_VALUE; } } Loading Loading @@ -361,10 +361,10 @@ void RefreshRateConfigs::getSortedRefreshRateList( outRefreshRates->clear(); outRefreshRates->clear(); outRefreshRates->reserve(mRefreshRates.size()); outRefreshRates->reserve(mRefreshRates.size()); for (const auto& [type, refreshRate] : mRefreshRates) { for (const auto& [type, refreshRate] : mRefreshRates) { if (shouldAddRefreshRate(refreshRate)) { if (shouldAddRefreshRate(*refreshRate)) { ALOGV("getSortedRefreshRateList: config %d added to list policy", ALOGV("getSortedRefreshRateList: config %d added to list policy", refreshRate.configId.value()); refreshRate->configId.value()); outRefreshRates->push_back(&refreshRate); outRefreshRates->push_back(refreshRate.get()); } } } } Loading @@ -376,7 +376,7 @@ void RefreshRateConfigs::getSortedRefreshRateList( void RefreshRateConfigs::constructAvailableRefreshRates() { void RefreshRateConfigs::constructAvailableRefreshRates() { // Filter configs based on current policy and sort based on vsync period // Filter configs based on current policy and sort based on vsync period HwcConfigGroupType group = mRefreshRates.at(mDefaultConfig).configGroup; HwcConfigGroupType group = mRefreshRates.at(mDefaultConfig)->configGroup; ALOGV("constructAvailableRefreshRates: default %d group %d min %.2f max %.2f", ALOGV("constructAvailableRefreshRates: default %d group %d min %.2f max %.2f", mDefaultConfig.value(), group.value(), mMinRefreshRateFps, mMaxRefreshRateFps); mDefaultConfig.value(), group.value(), mMinRefreshRateFps, mMaxRefreshRateFps); getSortedRefreshRateList( getSortedRefreshRateList( Loading @@ -403,16 +403,15 @@ void RefreshRateConfigs::init(const std::vector<InputConfig>& configs, LOG_ALWAYS_FATAL_IF(configs.empty()); LOG_ALWAYS_FATAL_IF(configs.empty()); LOG_ALWAYS_FATAL_IF(currentHwcConfig.value() >= configs.size()); LOG_ALWAYS_FATAL_IF(currentHwcConfig.value() >= configs.size()); auto buildRefreshRate = [&](InputConfig config) -> RefreshRate { const float fps = 1e9f / config.vsyncPeriod; return RefreshRate(config.configId, config.vsyncPeriod, config.configGroup, base::StringPrintf("%2.ffps", fps), fps); }; for (const auto& config : configs) { for (const auto& config : configs) { mRefreshRates.emplace(config.configId, buildRefreshRate(config)); const float fps = 1e9f / config.vsyncPeriod; mRefreshRates.emplace(config.configId, std::make_unique<RefreshRate>(config.configId, config.vsyncPeriod, config.configGroup, base::StringPrintf("%2.ffps", fps), fps)); if (config.configId == currentHwcConfig) { if (config.configId == currentHwcConfig) { mCurrentRefreshRate = &mRefreshRates.at(config.configId); mCurrentRefreshRate = mRefreshRates.at(config.configId).get(); } } } } Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.h +5 −2 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,8 @@ public: configGroup(configGroup), configGroup(configGroup), name(std::move(name)), name(std::move(name)), fps(fps) {} fps(fps) {} RefreshRate(const RefreshRate&) = delete; // This config ID corresponds to the position of the config in the vector that is stored // This config ID corresponds to the position of the config in the vector that is stored // on the device. // on the device. const HwcConfigIndexType configId; const HwcConfigIndexType configId; Loading @@ -85,7 +87,8 @@ public: bool operator==(const RefreshRate& other) const { return !(*this != other); } bool operator==(const RefreshRate& other) const { return !(*this != other); } }; }; using AllRefreshRatesMapType = std::unordered_map<HwcConfigIndexType, const RefreshRate>; using AllRefreshRatesMapType = std::unordered_map<HwcConfigIndexType, std::unique_ptr<const RefreshRate>>; // Sets the current policy to choose refresh rates. Returns NO_ERROR if the requested policy is // Sets the current policy to choose refresh rates. Returns NO_ERROR if the requested policy is // valid, or a negative error value otherwise. policyChanged, if non-null, will be set to true // valid, or a negative error value otherwise. policyChanged, if non-null, will be set to true Loading Loading @@ -163,7 +166,7 @@ public: // Returns the refresh rate that corresponds to a HwcConfigIndexType. This won't change at // Returns the refresh rate that corresponds to a HwcConfigIndexType. This won't change at // runtime. // runtime. const RefreshRate& getRefreshRateFromConfigId(HwcConfigIndexType configId) const { const RefreshRate& getRefreshRateFromConfigId(HwcConfigIndexType configId) const { return mRefreshRates.at(configId); return *mRefreshRates.at(configId); }; }; // Stores the current configId the device operates at // Stores the current configId the device operates at Loading services/surfaceflinger/Scheduler/Scheduler.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -463,7 +463,7 @@ void Scheduler::chooseRefreshRateForContent() { return; return; } } mFeatures.configId = newConfigId; mFeatures.configId = newConfigId; auto newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); auto& newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); mSchedulerCallback.changeRefreshRate(newRefreshRate, ConfigEvent::Changed); mSchedulerCallback.changeRefreshRate(newRefreshRate, ConfigEvent::Changed); } } } } Loading Loading @@ -515,7 +515,7 @@ void Scheduler::kernelIdleTimerCallback(TimerState state) { // TODO(145561154): cleanup the kernel idle timer implementation and the refresh rate // TODO(145561154): cleanup the kernel idle timer implementation and the refresh rate // magic number // magic number const auto refreshRate = mRefreshRateConfigs.getCurrentRefreshRate(); const auto& refreshRate = mRefreshRateConfigs.getCurrentRefreshRate(); constexpr float FPS_THRESHOLD_FOR_KERNEL_TIMER = 65.0f; constexpr float FPS_THRESHOLD_FOR_KERNEL_TIMER = 65.0f; if (state == TimerState::Reset && refreshRate.fps > FPS_THRESHOLD_FOR_KERNEL_TIMER) { if (state == TimerState::Reset && refreshRate.fps > FPS_THRESHOLD_FOR_KERNEL_TIMER) { // If we're not in performance mode then the kernel timer shouldn't do // If we're not in performance mode then the kernel timer shouldn't do Loading Loading
services/surfaceflinger/RefreshRateOverlay.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -168,9 +168,9 @@ bool RefreshRateOverlay::createLayer() { } } void RefreshRateOverlay::primeCache() { void RefreshRateOverlay::primeCache() { auto allRefreshRates = mFlinger.mRefreshRateConfigs->getAllRefreshRates(); auto& allRefreshRates = mFlinger.mRefreshRateConfigs->getAllRefreshRates(); if (allRefreshRates.size() == 1) { if (allRefreshRates.size() == 1) { auto fps = allRefreshRates.begin()->second.fps; auto fps = allRefreshRates.begin()->second->fps; half4 color = {LOW_FPS_COLOR, ALPHA}; half4 color = {LOW_FPS_COLOR, ALPHA}; mBufferCache.emplace(fps, SevenSegmentDrawer::drawNumber(fps, color)); mBufferCache.emplace(fps, SevenSegmentDrawer::drawNumber(fps, color)); return; return; Loading @@ -178,8 +178,8 @@ void RefreshRateOverlay::primeCache() { std::vector<uint32_t> supportedFps; std::vector<uint32_t> supportedFps; supportedFps.reserve(allRefreshRates.size()); supportedFps.reserve(allRefreshRates.size()); for (auto [ignored, refreshRate] : allRefreshRates) { for (auto& [ignored, refreshRate] : allRefreshRates) { supportedFps.push_back(refreshRate.fps); supportedFps.push_back(refreshRate->fps); } } std::sort(supportedFps.begin(), supportedFps.end()); std::sort(supportedFps.begin(), supportedFps.end()); Loading
services/surfaceflinger/Scheduler/PhaseOffsets.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -71,10 +71,10 @@ std::unordered_map<float, PhaseOffsets::Offsets> PhaseOffsets::initializeOffsets std::unordered_map<float, Offsets> offsets; std::unordered_map<float, Offsets> offsets; for (const auto& [ignored, refreshRate] : refreshRateConfigs.getAllRefreshRates()) { for (const auto& [ignored, refreshRate] : refreshRateConfigs.getAllRefreshRates()) { if (refreshRate.fps > 65.0f) { if (refreshRate->fps > 65.0f) { offsets.emplace(refreshRate.fps, getHighFpsOffsets(refreshRate.vsyncPeriod)); offsets.emplace(refreshRate->fps, getHighFpsOffsets(refreshRate->vsyncPeriod)); } else { } else { offsets.emplace(refreshRate.fps, getDefaultOffsets(refreshRate.vsyncPeriod)); offsets.emplace(refreshRate->fps, getDefaultOffsets(refreshRate->vsyncPeriod)); } } } } return offsets; return offsets; Loading Loading @@ -238,7 +238,7 @@ static std::vector<float> getRefreshRatesFromConfigs( refreshRates.reserve(allRefreshRates.size()); refreshRates.reserve(allRefreshRates.size()); for (const auto& [ignored, refreshRate] : allRefreshRates) { for (const auto& [ignored, refreshRate] : allRefreshRates) { refreshRates.emplace_back(refreshRate.fps); refreshRates.emplace_back(refreshRate->fps); } } return refreshRates; return refreshRates; Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +14 −15 Original line number Original line Diff line number Diff line Loading @@ -286,12 +286,12 @@ const RefreshRate& RefreshRateConfigs::getCurrentRefreshRateByPolicyLocked() con mCurrentRefreshRate) != mAvailableRefreshRates.end()) { mCurrentRefreshRate) != mAvailableRefreshRates.end()) { return *mCurrentRefreshRate; return *mCurrentRefreshRate; } } return mRefreshRates.at(mDefaultConfig); return *mRefreshRates.at(mDefaultConfig); } } void RefreshRateConfigs::setCurrentConfigId(HwcConfigIndexType configId) { void RefreshRateConfigs::setCurrentConfigId(HwcConfigIndexType configId) { std::lock_guard lock(mLock); std::lock_guard lock(mLock); mCurrentRefreshRate = &mRefreshRates.at(configId); mCurrentRefreshRate = mRefreshRates.at(configId).get(); } } RefreshRateConfigs::RefreshRateConfigs(const std::vector<InputConfig>& configs, RefreshRateConfigs::RefreshRateConfigs(const std::vector<InputConfig>& configs, Loading Loading @@ -326,7 +326,7 @@ status_t RefreshRateConfigs::setPolicy(HwcConfigIndexType defaultConfigId, float if (mRefreshRates.count(defaultConfigId) == 0) { if (mRefreshRates.count(defaultConfigId) == 0) { return BAD_VALUE; return BAD_VALUE; } } const RefreshRate& refreshRate = mRefreshRates.at(defaultConfigId); const RefreshRate& refreshRate = *mRefreshRates.at(defaultConfigId); if (!refreshRate.inPolicy(minRefreshRate, maxRefreshRate)) { if (!refreshRate.inPolicy(minRefreshRate, maxRefreshRate)) { return BAD_VALUE; return BAD_VALUE; } } Loading Loading @@ -361,10 +361,10 @@ void RefreshRateConfigs::getSortedRefreshRateList( outRefreshRates->clear(); outRefreshRates->clear(); outRefreshRates->reserve(mRefreshRates.size()); outRefreshRates->reserve(mRefreshRates.size()); for (const auto& [type, refreshRate] : mRefreshRates) { for (const auto& [type, refreshRate] : mRefreshRates) { if (shouldAddRefreshRate(refreshRate)) { if (shouldAddRefreshRate(*refreshRate)) { ALOGV("getSortedRefreshRateList: config %d added to list policy", ALOGV("getSortedRefreshRateList: config %d added to list policy", refreshRate.configId.value()); refreshRate->configId.value()); outRefreshRates->push_back(&refreshRate); outRefreshRates->push_back(refreshRate.get()); } } } } Loading @@ -376,7 +376,7 @@ void RefreshRateConfigs::getSortedRefreshRateList( void RefreshRateConfigs::constructAvailableRefreshRates() { void RefreshRateConfigs::constructAvailableRefreshRates() { // Filter configs based on current policy and sort based on vsync period // Filter configs based on current policy and sort based on vsync period HwcConfigGroupType group = mRefreshRates.at(mDefaultConfig).configGroup; HwcConfigGroupType group = mRefreshRates.at(mDefaultConfig)->configGroup; ALOGV("constructAvailableRefreshRates: default %d group %d min %.2f max %.2f", ALOGV("constructAvailableRefreshRates: default %d group %d min %.2f max %.2f", mDefaultConfig.value(), group.value(), mMinRefreshRateFps, mMaxRefreshRateFps); mDefaultConfig.value(), group.value(), mMinRefreshRateFps, mMaxRefreshRateFps); getSortedRefreshRateList( getSortedRefreshRateList( Loading @@ -403,16 +403,15 @@ void RefreshRateConfigs::init(const std::vector<InputConfig>& configs, LOG_ALWAYS_FATAL_IF(configs.empty()); LOG_ALWAYS_FATAL_IF(configs.empty()); LOG_ALWAYS_FATAL_IF(currentHwcConfig.value() >= configs.size()); LOG_ALWAYS_FATAL_IF(currentHwcConfig.value() >= configs.size()); auto buildRefreshRate = [&](InputConfig config) -> RefreshRate { const float fps = 1e9f / config.vsyncPeriod; return RefreshRate(config.configId, config.vsyncPeriod, config.configGroup, base::StringPrintf("%2.ffps", fps), fps); }; for (const auto& config : configs) { for (const auto& config : configs) { mRefreshRates.emplace(config.configId, buildRefreshRate(config)); const float fps = 1e9f / config.vsyncPeriod; mRefreshRates.emplace(config.configId, std::make_unique<RefreshRate>(config.configId, config.vsyncPeriod, config.configGroup, base::StringPrintf("%2.ffps", fps), fps)); if (config.configId == currentHwcConfig) { if (config.configId == currentHwcConfig) { mCurrentRefreshRate = &mRefreshRates.at(config.configId); mCurrentRefreshRate = mRefreshRates.at(config.configId).get(); } } } } Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.h +5 −2 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,8 @@ public: configGroup(configGroup), configGroup(configGroup), name(std::move(name)), name(std::move(name)), fps(fps) {} fps(fps) {} RefreshRate(const RefreshRate&) = delete; // This config ID corresponds to the position of the config in the vector that is stored // This config ID corresponds to the position of the config in the vector that is stored // on the device. // on the device. const HwcConfigIndexType configId; const HwcConfigIndexType configId; Loading @@ -85,7 +87,8 @@ public: bool operator==(const RefreshRate& other) const { return !(*this != other); } bool operator==(const RefreshRate& other) const { return !(*this != other); } }; }; using AllRefreshRatesMapType = std::unordered_map<HwcConfigIndexType, const RefreshRate>; using AllRefreshRatesMapType = std::unordered_map<HwcConfigIndexType, std::unique_ptr<const RefreshRate>>; // Sets the current policy to choose refresh rates. Returns NO_ERROR if the requested policy is // Sets the current policy to choose refresh rates. Returns NO_ERROR if the requested policy is // valid, or a negative error value otherwise. policyChanged, if non-null, will be set to true // valid, or a negative error value otherwise. policyChanged, if non-null, will be set to true Loading Loading @@ -163,7 +166,7 @@ public: // Returns the refresh rate that corresponds to a HwcConfigIndexType. This won't change at // Returns the refresh rate that corresponds to a HwcConfigIndexType. This won't change at // runtime. // runtime. const RefreshRate& getRefreshRateFromConfigId(HwcConfigIndexType configId) const { const RefreshRate& getRefreshRateFromConfigId(HwcConfigIndexType configId) const { return mRefreshRates.at(configId); return *mRefreshRates.at(configId); }; }; // Stores the current configId the device operates at // Stores the current configId the device operates at Loading
services/surfaceflinger/Scheduler/Scheduler.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -463,7 +463,7 @@ void Scheduler::chooseRefreshRateForContent() { return; return; } } mFeatures.configId = newConfigId; mFeatures.configId = newConfigId; auto newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); auto& newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); mSchedulerCallback.changeRefreshRate(newRefreshRate, ConfigEvent::Changed); mSchedulerCallback.changeRefreshRate(newRefreshRate, ConfigEvent::Changed); } } } } Loading Loading @@ -515,7 +515,7 @@ void Scheduler::kernelIdleTimerCallback(TimerState state) { // TODO(145561154): cleanup the kernel idle timer implementation and the refresh rate // TODO(145561154): cleanup the kernel idle timer implementation and the refresh rate // magic number // magic number const auto refreshRate = mRefreshRateConfigs.getCurrentRefreshRate(); const auto& refreshRate = mRefreshRateConfigs.getCurrentRefreshRate(); constexpr float FPS_THRESHOLD_FOR_KERNEL_TIMER = 65.0f; constexpr float FPS_THRESHOLD_FOR_KERNEL_TIMER = 65.0f; if (state == TimerState::Reset && refreshRate.fps > FPS_THRESHOLD_FOR_KERNEL_TIMER) { if (state == TimerState::Reset && refreshRate.fps > FPS_THRESHOLD_FOR_KERNEL_TIMER) { // If we're not in performance mode then the kernel timer shouldn't do // If we're not in performance mode then the kernel timer shouldn't do Loading