blob: 4ebab3eb671a9678b7188cf9fb4db543e715720c [file] [log] [blame]
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -08001/*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Ady Abraham2139f732019-11-13 18:56:40 -080016
Ady Abraham8a82ba62020-01-17 12:43:17 -080017// #define LOG_NDEBUG 0
18#define ATRACE_TAG ATRACE_TAG_GRAPHICS
19
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -080020#include "RefreshRateConfigs.h"
Ady Abraham8a82ba62020-01-17 12:43:17 -080021#include <android-base/stringprintf.h>
22#include <utils/Trace.h>
23#include <chrono>
24#include <cmath>
25
Ady Abraham5b8afb5a2020-03-06 14:57:26 -080026#undef LOG_TAG
27#define LOG_TAG "RefreshRateConfigs"
28
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -080029namespace android::scheduler {
Marin Shalamanov53fc11d2020-11-20 14:00:13 +010030namespace {
31std::string formatLayerInfo(const RefreshRateConfigs::LayerRequirement& layer, float weight) {
32 return base::StringPrintf("%s (type=%s, weight=%.2f seamlessness=%s) %.2fHz",
33 layer.name.c_str(),
34 RefreshRateConfigs::layerVoteTypeString(layer.vote).c_str(), weight,
35 toString(layer.seamlessness).c_str(), layer.desiredRefreshRate);
36}
37} // namespace
Ady Abraham2139f732019-11-13 18:56:40 -080038
39using AllRefreshRatesMapType = RefreshRateConfigs::AllRefreshRatesMapType;
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -080040using RefreshRate = RefreshRateConfigs::RefreshRate;
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -080041
Marin Shalamanov46084422020-10-13 12:33:42 +020042std::string RefreshRate::toString() const {
43 return base::StringPrintf("{id=%d, hwcId=%d, fps=%.2f, width=%d, height=%d group=%d}",
44 getConfigId().value(), hwcConfig->getId(), getFps(),
45 hwcConfig->getWidth(), hwcConfig->getHeight(), getConfigGroup());
46}
47
Ady Abrahama6b676e2020-05-27 14:29:09 -070048std::string RefreshRateConfigs::layerVoteTypeString(LayerVoteType vote) {
49 switch (vote) {
50 case LayerVoteType::NoVote:
51 return "NoVote";
52 case LayerVoteType::Min:
53 return "Min";
54 case LayerVoteType::Max:
55 return "Max";
56 case LayerVoteType::Heuristic:
57 return "Heuristic";
58 case LayerVoteType::ExplicitDefault:
59 return "ExplicitDefault";
60 case LayerVoteType::ExplicitExactOrMultiple:
61 return "ExplicitExactOrMultiple";
62 }
63}
64
Marin Shalamanovb6674e72020-11-06 13:05:57 +010065std::string RefreshRateConfigs::Policy::toString() const {
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +020066 return base::StringPrintf("default config ID: %d, allowGroupSwitching = %d"
67 ", primary range: [%.2f %.2f], app request range: [%.2f %.2f]",
68 defaultConfig.value(), allowGroupSwitching, primaryRange.min,
69 primaryRange.max, appRequestRange.min, appRequestRange.max);
70}
71
Ady Abraham8a82ba62020-01-17 12:43:17 -080072const RefreshRate& RefreshRateConfigs::getRefreshRateForContent(
73 const std::vector<LayerRequirement>& layers) const {
Ady Abraham2139f732019-11-13 18:56:40 -080074 std::lock_guard lock(mLock);
Ady Abrahamdec1a412020-01-24 10:23:50 -080075 int contentFramerate = 0;
76 int explicitContentFramerate = 0;
Ady Abraham8a82ba62020-01-17 12:43:17 -080077 for (const auto& layer : layers) {
Ady Abrahamdec1a412020-01-24 10:23:50 -080078 const auto desiredRefreshRateRound = round<int>(layer.desiredRefreshRate);
Ady Abraham71c437d2020-01-31 15:56:57 -080079 if (layer.vote == LayerVoteType::ExplicitDefault ||
80 layer.vote == LayerVoteType::ExplicitExactOrMultiple) {
Ady Abrahamdec1a412020-01-24 10:23:50 -080081 if (desiredRefreshRateRound > explicitContentFramerate) {
82 explicitContentFramerate = desiredRefreshRateRound;
Ady Abraham8a82ba62020-01-17 12:43:17 -080083 }
84 } else {
Ady Abrahamdec1a412020-01-24 10:23:50 -080085 if (desiredRefreshRateRound > contentFramerate) {
86 contentFramerate = desiredRefreshRateRound;
Ady Abraham8a82ba62020-01-17 12:43:17 -080087 }
88 }
89 }
90
Ady Abrahamdec1a412020-01-24 10:23:50 -080091 if (explicitContentFramerate != 0) {
Ady Abraham8a82ba62020-01-17 12:43:17 -080092 contentFramerate = explicitContentFramerate;
Ady Abrahamdec1a412020-01-24 10:23:50 -080093 } else if (contentFramerate == 0) {
Ady Abrahamabc27602020-04-08 17:20:29 -070094 contentFramerate = round<int>(mMaxSupportedRefreshRate->getFps());
Ady Abraham8a82ba62020-01-17 12:43:17 -080095 }
Ady Abraham8a82ba62020-01-17 12:43:17 -080096 ATRACE_INT("ContentFPS", contentFramerate);
97
Ady Abraham2139f732019-11-13 18:56:40 -080098 // Find the appropriate refresh rate with minimal error
Steven Thomasf734df42020-04-13 21:09:28 -070099 auto iter = min_element(mPrimaryRefreshRates.cbegin(), mPrimaryRefreshRates.cend(),
Ady Abraham2139f732019-11-13 18:56:40 -0800100 [contentFramerate](const auto& lhs, const auto& rhs) -> bool {
101 return std::abs(lhs->fps - contentFramerate) <
102 std::abs(rhs->fps - contentFramerate);
103 });
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800104
Ady Abraham2139f732019-11-13 18:56:40 -0800105 // Some content aligns better on higher refresh rate. For example for 45fps we should choose
106 // 90Hz config. However we should still prefer a lower refresh rate if the content doesn't
107 // align well with both
108 const RefreshRate* bestSoFar = *iter;
109 constexpr float MARGIN = 0.05f;
110 float ratio = (*iter)->fps / contentFramerate;
111 if (std::abs(std::round(ratio) - ratio) > MARGIN) {
Steven Thomasf734df42020-04-13 21:09:28 -0700112 while (iter != mPrimaryRefreshRates.cend()) {
Ady Abraham2139f732019-11-13 18:56:40 -0800113 ratio = (*iter)->fps / contentFramerate;
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800114
Ady Abraham2139f732019-11-13 18:56:40 -0800115 if (std::abs(std::round(ratio) - ratio) <= MARGIN) {
116 bestSoFar = *iter;
117 break;
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800118 }
Ady Abraham2139f732019-11-13 18:56:40 -0800119 ++iter;
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800120 }
121 }
122
Ady Abraham2139f732019-11-13 18:56:40 -0800123 return *bestSoFar;
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800124}
125
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800126std::pair<nsecs_t, nsecs_t> RefreshRateConfigs::getDisplayFrames(nsecs_t layerPeriod,
127 nsecs_t displayPeriod) const {
128 auto [displayFramesQuot, displayFramesRem] = std::div(layerPeriod, displayPeriod);
129 if (displayFramesRem <= MARGIN_FOR_PERIOD_CALCULATION ||
130 std::abs(displayFramesRem - displayPeriod) <= MARGIN_FOR_PERIOD_CALCULATION) {
131 displayFramesQuot++;
132 displayFramesRem = 0;
133 }
134
135 return {displayFramesQuot, displayFramesRem};
136}
137
Steven Thomasbb374322020-04-28 22:47:16 -0700138const RefreshRate& RefreshRateConfigs::getBestRefreshRate(
Ady Abrahamdfd62162020-06-10 16:11:56 -0700139 const std::vector<LayerRequirement>& layers, const GlobalSignals& globalSignals,
140 GlobalSignals* outSignalsConsidered) const {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800141 ATRACE_CALL();
Marin Shalamanov46084422020-10-13 12:33:42 +0200142 ALOGV("getBestRefreshRate %zu layers", layers.size());
Ady Abraham8a82ba62020-01-17 12:43:17 -0800143
Ady Abrahamdfd62162020-06-10 16:11:56 -0700144 if (outSignalsConsidered) *outSignalsConsidered = {};
145 const auto setTouchConsidered = [&] {
146 if (outSignalsConsidered) {
147 outSignalsConsidered->touch = true;
148 }
149 };
150
151 const auto setIdleConsidered = [&] {
152 if (outSignalsConsidered) {
153 outSignalsConsidered->idle = true;
154 }
155 };
156
Ady Abraham8a82ba62020-01-17 12:43:17 -0800157 std::lock_guard lock(mLock);
158
159 int noVoteLayers = 0;
160 int minVoteLayers = 0;
161 int maxVoteLayers = 0;
Ady Abraham71c437d2020-01-31 15:56:57 -0800162 int explicitDefaultVoteLayers = 0;
163 int explicitExactOrMultipleVoteLayers = 0;
Ady Abraham6fb599b2020-03-05 13:48:22 -0800164 float maxExplicitWeight = 0;
Marin Shalamanov46084422020-10-13 12:33:42 +0200165 int seamedLayers = 0;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800166 for (const auto& layer : layers) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800167 if (layer.vote == LayerVoteType::NoVote) {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800168 noVoteLayers++;
Ady Abraham6fb599b2020-03-05 13:48:22 -0800169 } else if (layer.vote == LayerVoteType::Min) {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800170 minVoteLayers++;
Ady Abraham6fb599b2020-03-05 13:48:22 -0800171 } else if (layer.vote == LayerVoteType::Max) {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800172 maxVoteLayers++;
Ady Abraham6fb599b2020-03-05 13:48:22 -0800173 } else if (layer.vote == LayerVoteType::ExplicitDefault) {
Ady Abraham71c437d2020-01-31 15:56:57 -0800174 explicitDefaultVoteLayers++;
Ady Abraham6fb599b2020-03-05 13:48:22 -0800175 maxExplicitWeight = std::max(maxExplicitWeight, layer.weight);
176 } else if (layer.vote == LayerVoteType::ExplicitExactOrMultiple) {
Ady Abraham71c437d2020-01-31 15:56:57 -0800177 explicitExactOrMultipleVoteLayers++;
Ady Abraham6fb599b2020-03-05 13:48:22 -0800178 maxExplicitWeight = std::max(maxExplicitWeight, layer.weight);
179 }
Marin Shalamanov46084422020-10-13 12:33:42 +0200180
Marin Shalamanov53fc11d2020-11-20 14:00:13 +0100181 if (layer.seamlessness == Seamlessness::SeamedAndSeamless) {
Marin Shalamanov46084422020-10-13 12:33:42 +0200182 seamedLayers++;
183 }
Ady Abraham6fb599b2020-03-05 13:48:22 -0800184 }
185
Alec Mouri11232a22020-05-14 18:06:25 -0700186 const bool hasExplicitVoteLayers =
187 explicitDefaultVoteLayers > 0 || explicitExactOrMultipleVoteLayers > 0;
188
Steven Thomasf734df42020-04-13 21:09:28 -0700189 // Consider the touch event if there are no Explicit* layers. Otherwise wait until after we've
190 // selected a refresh rate to see if we should apply touch boost.
Ady Abrahamdfd62162020-06-10 16:11:56 -0700191 if (globalSignals.touch && !hasExplicitVoteLayers) {
Ady Abrahama6b676e2020-05-27 14:29:09 -0700192 ALOGV("TouchBoost - choose %s", getMaxRefreshRateByPolicyLocked().getName().c_str());
Ady Abrahamdfd62162020-06-10 16:11:56 -0700193 setTouchConsidered();
Steven Thomasf734df42020-04-13 21:09:28 -0700194 return getMaxRefreshRateByPolicyLocked();
Ady Abraham8a82ba62020-01-17 12:43:17 -0800195 }
196
Alec Mouri11232a22020-05-14 18:06:25 -0700197 // If the primary range consists of a single refresh rate then we can only
198 // move out the of range if layers explicitly request a different refresh
199 // rate.
200 const Policy* policy = getCurrentPolicyLocked();
201 const bool primaryRangeIsSingleRate = policy->primaryRange.min == policy->primaryRange.max;
202
Ady Abrahamdfd62162020-06-10 16:11:56 -0700203 if (!globalSignals.touch && globalSignals.idle &&
204 !(primaryRangeIsSingleRate && hasExplicitVoteLayers)) {
Ady Abrahama6b676e2020-05-27 14:29:09 -0700205 ALOGV("Idle - choose %s", getMinRefreshRateByPolicyLocked().getName().c_str());
Ady Abrahamdfd62162020-06-10 16:11:56 -0700206 setIdleConsidered();
Steven Thomasbb374322020-04-28 22:47:16 -0700207 return getMinRefreshRateByPolicyLocked();
208 }
209
Steven Thomasdebafed2020-05-18 17:30:35 -0700210 if (layers.empty() || noVoteLayers == layers.size()) {
211 return getMaxRefreshRateByPolicyLocked();
Steven Thomasbb374322020-04-28 22:47:16 -0700212 }
213
Ady Abraham8a82ba62020-01-17 12:43:17 -0800214 // Only if all layers want Min we should return Min
215 if (noVoteLayers + minVoteLayers == layers.size()) {
Ady Abrahama6b676e2020-05-27 14:29:09 -0700216 ALOGV("all layers Min - choose %s", getMinRefreshRateByPolicyLocked().getName().c_str());
Steven Thomasf734df42020-04-13 21:09:28 -0700217 return getMinRefreshRateByPolicyLocked();
Ady Abraham8a82ba62020-01-17 12:43:17 -0800218 }
219
Ady Abraham8a82ba62020-01-17 12:43:17 -0800220 // Find the best refresh rate based on score
221 std::vector<std::pair<const RefreshRate*, float>> scores;
Steven Thomasf734df42020-04-13 21:09:28 -0700222 scores.reserve(mAppRequestRefreshRates.size());
Ady Abraham8a82ba62020-01-17 12:43:17 -0800223
Steven Thomasf734df42020-04-13 21:09:28 -0700224 for (const auto refreshRate : mAppRequestRefreshRates) {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800225 scores.emplace_back(refreshRate, 0.0f);
226 }
227
Marin Shalamanov46084422020-10-13 12:33:42 +0200228 const auto& defaultConfig = mRefreshRates.at(policy->defaultConfig);
229
Ady Abraham8a82ba62020-01-17 12:43:17 -0800230 for (const auto& layer : layers) {
Ady Abrahama6b676e2020-05-27 14:29:09 -0700231 ALOGV("Calculating score for %s (%s, weight %.2f)", layer.name.c_str(),
232 layerVoteTypeString(layer.vote).c_str(), layer.weight);
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800233 if (layer.vote == LayerVoteType::NoVote || layer.vote == LayerVoteType::Min) {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800234 continue;
235 }
236
Ady Abraham71c437d2020-01-31 15:56:57 -0800237 auto weight = layer.weight;
Ady Abraham71c437d2020-01-31 15:56:57 -0800238
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800239 for (auto i = 0u; i < scores.size(); i++) {
Marin Shalamanov53fc11d2020-11-20 14:00:13 +0100240 const bool isSeamlessSwitch =
241 scores[i].first->getConfigGroup() == mCurrentRefreshRate->getConfigGroup();
Marin Shalamanov46084422020-10-13 12:33:42 +0200242
Marin Shalamanov53fc11d2020-11-20 14:00:13 +0100243 if (layer.seamlessness == Seamlessness::OnlySeamless && !isSeamlessSwitch) {
244 ALOGV("%s ignores %s to avoid non-seamless switch. Current config = %s",
245 formatLayerInfo(layer, weight).c_str(), scores[i].first->toString().c_str(),
246 mCurrentRefreshRate->toString().c_str());
Marin Shalamanov46084422020-10-13 12:33:42 +0200247 continue;
248 }
249
Marin Shalamanov53fc11d2020-11-20 14:00:13 +0100250 if (layer.seamlessness == Seamlessness::SeamedAndSeamless && !isSeamlessSwitch &&
251 !layer.focused) {
252 ALOGV("%s ignores %s because it's not focused and the switch is going to be seamed."
253 " Current config = %s",
254 formatLayerInfo(layer, weight).c_str(), scores[i].first->toString().c_str(),
255 mCurrentRefreshRate->toString().c_str());
256 continue;
257 }
258
259 // Layers with default seamlessness vote for the current config group if
260 // there are layers with seamlessness=SeamedAndSeamless and for the default
261 // config group otherwise. In second case, if the current config group is different
262 // from the default, this means a layer with seamlessness=SeamedAndSeamless has just
263 // disappeared.
264 const bool isInPolicyForDefault = seamedLayers > 0
265 ? scores[i].first->getConfigGroup() == mCurrentRefreshRate->getConfigGroup()
266 : scores[i].first->getConfigGroup() == defaultConfig->getConfigGroup();
267
268 if (layer.seamlessness == Seamlessness::Default && !isInPolicyForDefault &&
269 !layer.focused) {
270 ALOGV("%s ignores %s. Current config = %s", formatLayerInfo(layer, weight).c_str(),
271 scores[i].first->toString().c_str(), mCurrentRefreshRate->toString().c_str());
Marin Shalamanov46084422020-10-13 12:33:42 +0200272 continue;
273 }
274
Steven Thomasf734df42020-04-13 21:09:28 -0700275 bool inPrimaryRange =
276 scores[i].first->inPolicy(policy->primaryRange.min, policy->primaryRange.max);
Alec Mouri11232a22020-05-14 18:06:25 -0700277 if ((primaryRangeIsSingleRate || !inPrimaryRange) &&
Ady Abraham20c029c2020-07-06 12:58:05 -0700278 !(layer.focused && layer.vote == LayerVoteType::ExplicitDefault)) {
279 // Only focused layers with ExplicitDefault frame rate settings are allowed to score
Ady Abrahamaae5ed52020-06-26 09:32:43 -0700280 // refresh rates outside the primary range.
Steven Thomasf734df42020-04-13 21:09:28 -0700281 continue;
282 }
283
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800284 // If the layer wants Max, give higher score to the higher refresh rate
285 if (layer.vote == LayerVoteType::Max) {
286 const auto ratio = scores[i].first->fps / scores.back().first->fps;
287 // use ratio^2 to get a lower score the more we get further from peak
288 const auto layerScore = ratio * ratio;
Marin Shalamanov53fc11d2020-11-20 14:00:13 +0100289 ALOGV("%s gives %s score of %.2f", formatLayerInfo(layer, weight).c_str(),
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800290 scores[i].first->name.c_str(), layerScore);
291 scores[i].second += weight * layerScore;
292 continue;
Ady Abraham71c437d2020-01-31 15:56:57 -0800293 }
Ady Abraham8a82ba62020-01-17 12:43:17 -0800294
Ady Abrahamabc27602020-04-08 17:20:29 -0700295 const auto displayPeriod = scores[i].first->hwcConfig->getVsyncPeriod();
Ady Abrahamdec1a412020-01-24 10:23:50 -0800296 const auto layerPeriod = round<nsecs_t>(1e9f / layer.desiredRefreshRate);
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800297 if (layer.vote == LayerVoteType::ExplicitDefault) {
298 const auto layerScore = [&]() {
Ady Abraham5b8afb5a2020-03-06 14:57:26 -0800299 // Find the actual rate the layer will render, assuming
300 // that layerPeriod is the minimal time to render a frame
301 auto actualLayerPeriod = displayPeriod;
302 int multiplier = 1;
303 while (layerPeriod > actualLayerPeriod + MARGIN_FOR_PERIOD_CALCULATION) {
304 multiplier++;
305 actualLayerPeriod = displayPeriod * multiplier;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800306 }
Ady Abraham5b8afb5a2020-03-06 14:57:26 -0800307 return std::min(1.0f,
308 static_cast<float>(layerPeriod) /
309 static_cast<float>(actualLayerPeriod));
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800310 }();
311
Marin Shalamanov53fc11d2020-11-20 14:00:13 +0100312 ALOGV("%s gives %s score of %.2f", formatLayerInfo(layer, weight).c_str(),
313 scores[i].first->name.c_str(), layerScore);
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800314 scores[i].second += weight * layerScore;
315 continue;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800316 }
317
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800318 if (layer.vote == LayerVoteType::ExplicitExactOrMultiple ||
319 layer.vote == LayerVoteType::Heuristic) {
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700320 const auto layerScore = [&] {
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800321 // Calculate how many display vsyncs we need to present a single frame for this
322 // layer
323 const auto [displayFramesQuot, displayFramesRem] =
324 getDisplayFrames(layerPeriod, displayPeriod);
325 static constexpr size_t MAX_FRAMES_TO_FIT =
326 10; // Stop calculating when score < 0.1
327 if (displayFramesRem == 0) {
328 // Layer desired refresh rate matches the display rate.
329 return 1.0f;
330 }
Ady Abraham8a82ba62020-01-17 12:43:17 -0800331
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800332 if (displayFramesQuot == 0) {
333 // Layer desired refresh rate is higher the display rate.
334 return (static_cast<float>(layerPeriod) /
335 static_cast<float>(displayPeriod)) *
336 (1.0f / (MAX_FRAMES_TO_FIT + 1));
337 }
338
339 // Layer desired refresh rate is lower the display rate. Check how well it fits
340 // the cadence
341 auto diff = std::abs(displayFramesRem - (displayPeriod - displayFramesRem));
342 int iter = 2;
343 while (diff > MARGIN_FOR_PERIOD_CALCULATION && iter < MAX_FRAMES_TO_FIT) {
344 diff = diff - (displayPeriod - diff);
345 iter++;
346 }
347
348 return 1.0f / iter;
349 }();
Marin Shalamanov46084422020-10-13 12:33:42 +0200350 // Slightly prefer seamless switches.
351 constexpr float kSeamedSwitchPenalty = 0.95f;
352 const float seamlessness = isSeamlessSwitch ? 1.0f : kSeamedSwitchPenalty;
Marin Shalamanov53fc11d2020-11-20 14:00:13 +0100353 ALOGV("%s gives %s score of %.2f", formatLayerInfo(layer, weight).c_str(),
Ady Abrahama6b676e2020-05-27 14:29:09 -0700354 scores[i].first->name.c_str(), layerScore);
Marin Shalamanov46084422020-10-13 12:33:42 +0200355 scores[i].second += weight * layerScore * seamlessness;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800356 continue;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800357 }
Ady Abraham8a82ba62020-01-17 12:43:17 -0800358 }
359 }
360
Ady Abraham34702102020-02-10 14:12:05 -0800361 // Now that we scored all the refresh rates we need to pick the one that got the highest score.
362 // In case of a tie we will pick the higher refresh rate if any of the layers wanted Max,
363 // or the lower otherwise.
364 const RefreshRate* bestRefreshRate = maxVoteLayers > 0
365 ? getBestRefreshRate(scores.rbegin(), scores.rend())
366 : getBestRefreshRate(scores.begin(), scores.end());
367
Alec Mouri11232a22020-05-14 18:06:25 -0700368 if (primaryRangeIsSingleRate) {
369 // If we never scored any layers, then choose the rate from the primary
370 // range instead of picking a random score from the app range.
371 if (std::all_of(scores.begin(), scores.end(),
372 [](std::pair<const RefreshRate*, float> p) { return p.second == 0; })) {
Ady Abrahama6b676e2020-05-27 14:29:09 -0700373 ALOGV("layers not scored - choose %s",
374 getMaxRefreshRateByPolicyLocked().getName().c_str());
Alec Mouri11232a22020-05-14 18:06:25 -0700375 return getMaxRefreshRateByPolicyLocked();
376 } else {
377 return *bestRefreshRate;
378 }
379 }
380
Steven Thomasf734df42020-04-13 21:09:28 -0700381 // Consider the touch event if there are no ExplicitDefault layers. ExplicitDefault are mostly
382 // interactive (as opposed to ExplicitExactOrMultiple) and therefore if those posted an explicit
383 // vote we should not change it if we get a touch event. Only apply touch boost if it will
384 // actually increase the refresh rate over the normal selection.
385 const RefreshRate& touchRefreshRate = getMaxRefreshRateByPolicyLocked();
Alec Mouri11232a22020-05-14 18:06:25 -0700386
Ady Abrahamdfd62162020-06-10 16:11:56 -0700387 if (globalSignals.touch && explicitDefaultVoteLayers == 0 &&
Steven Thomasf734df42020-04-13 21:09:28 -0700388 bestRefreshRate->fps < touchRefreshRate.fps) {
Ady Abrahamdfd62162020-06-10 16:11:56 -0700389 setTouchConsidered();
Ady Abrahama6b676e2020-05-27 14:29:09 -0700390 ALOGV("TouchBoost - choose %s", touchRefreshRate.getName().c_str());
Steven Thomasf734df42020-04-13 21:09:28 -0700391 return touchRefreshRate;
392 }
393
Ady Abrahamde7156e2020-02-28 17:29:39 -0800394 return *bestRefreshRate;
Ady Abraham34702102020-02-10 14:12:05 -0800395}
396
397template <typename Iter>
398const RefreshRate* RefreshRateConfigs::getBestRefreshRate(Iter begin, Iter end) const {
Ady Abraham5b8afb5a2020-03-06 14:57:26 -0800399 constexpr auto EPSILON = 0.001f;
Ady Abrahamde7156e2020-02-28 17:29:39 -0800400 const RefreshRate* bestRefreshRate = begin->first;
401 float max = begin->second;
Ady Abraham34702102020-02-10 14:12:05 -0800402 for (auto i = begin; i != end; ++i) {
403 const auto [refreshRate, score] = *i;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800404 ALOGV("%s scores %.2f", refreshRate->name.c_str(), score);
405
Ady Abrahamdec1a412020-01-24 10:23:50 -0800406 ATRACE_INT(refreshRate->name.c_str(), round<int>(score * 100));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800407
Ady Abraham5b8afb5a2020-03-06 14:57:26 -0800408 if (score > max * (1 + EPSILON)) {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800409 max = score;
410 bestRefreshRate = refreshRate;
411 }
412 }
413
Ady Abraham34702102020-02-10 14:12:05 -0800414 return bestRefreshRate;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800415}
416
Ady Abraham2139f732019-11-13 18:56:40 -0800417const AllRefreshRatesMapType& RefreshRateConfigs::getAllRefreshRates() const {
418 return mRefreshRates;
419}
420
421const RefreshRate& RefreshRateConfigs::getMinRefreshRateByPolicy() const {
422 std::lock_guard lock(mLock);
Steven Thomasf734df42020-04-13 21:09:28 -0700423 return getMinRefreshRateByPolicyLocked();
424}
425
426const RefreshRate& RefreshRateConfigs::getMinRefreshRateByPolicyLocked() const {
Marin Shalamanov46084422020-10-13 12:33:42 +0200427 for (auto refreshRate : mPrimaryRefreshRates) {
428 if (mCurrentRefreshRate->getConfigGroup() == refreshRate->getConfigGroup()) {
429 return *refreshRate;
430 }
431 }
432 ALOGE("Can't find min refresh rate by policy with the same config group"
433 " as the current config %s",
434 mCurrentRefreshRate->toString().c_str());
435 // Defaulting to the lowest refresh rate
Steven Thomasf734df42020-04-13 21:09:28 -0700436 return *mPrimaryRefreshRates.front();
Ady Abraham2139f732019-11-13 18:56:40 -0800437}
438
439const RefreshRate& RefreshRateConfigs::getMaxRefreshRateByPolicy() const {
440 std::lock_guard lock(mLock);
Steven Thomasf734df42020-04-13 21:09:28 -0700441 return getMaxRefreshRateByPolicyLocked();
442}
443
444const RefreshRate& RefreshRateConfigs::getMaxRefreshRateByPolicyLocked() const {
Marin Shalamanov46084422020-10-13 12:33:42 +0200445 for (auto it = mPrimaryRefreshRates.rbegin(); it != mPrimaryRefreshRates.rend(); it++) {
446 const auto& refreshRate = (**it);
447 if (mCurrentRefreshRate->getConfigGroup() == refreshRate.getConfigGroup()) {
448 return refreshRate;
449 }
450 }
451 ALOGE("Can't find max refresh rate by policy with the same config group"
452 " as the current config %s",
453 mCurrentRefreshRate->toString().c_str());
454 // Defaulting to the highest refresh rate
Steven Thomasf734df42020-04-13 21:09:28 -0700455 return *mPrimaryRefreshRates.back();
Ady Abraham2139f732019-11-13 18:56:40 -0800456}
457
458const RefreshRate& RefreshRateConfigs::getCurrentRefreshRate() const {
459 std::lock_guard lock(mLock);
460 return *mCurrentRefreshRate;
461}
462
Ana Krulec5d477912020-02-07 12:02:38 -0800463const RefreshRate& RefreshRateConfigs::getCurrentRefreshRateByPolicy() const {
464 std::lock_guard lock(mLock);
Ana Krulec3d367c82020-02-25 15:02:01 -0800465 return getCurrentRefreshRateByPolicyLocked();
466}
467
468const RefreshRate& RefreshRateConfigs::getCurrentRefreshRateByPolicyLocked() const {
Steven Thomasf734df42020-04-13 21:09:28 -0700469 if (std::find(mAppRequestRefreshRates.begin(), mAppRequestRefreshRates.end(),
470 mCurrentRefreshRate) != mAppRequestRefreshRates.end()) {
Ana Krulec5d477912020-02-07 12:02:38 -0800471 return *mCurrentRefreshRate;
472 }
Steven Thomasd4071902020-03-24 16:02:53 -0700473 return *mRefreshRates.at(getCurrentPolicyLocked()->defaultConfig);
Ana Krulec5d477912020-02-07 12:02:38 -0800474}
475
Ady Abraham2139f732019-11-13 18:56:40 -0800476void RefreshRateConfigs::setCurrentConfigId(HwcConfigIndexType configId) {
477 std::lock_guard lock(mLock);
Ady Abraham2e1dd892020-03-05 13:48:36 -0800478 mCurrentRefreshRate = mRefreshRates.at(configId).get();
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800479}
480
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800481RefreshRateConfigs::RefreshRateConfigs(
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800482 const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs,
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700483 HwcConfigIndexType currentConfigId)
484 : mKnownFrameRates(constructKnownFrameRates(configs)) {
Ady Abrahamabc27602020-04-08 17:20:29 -0700485 LOG_ALWAYS_FATAL_IF(configs.empty());
486 LOG_ALWAYS_FATAL_IF(currentConfigId.value() >= configs.size());
487
488 for (auto configId = HwcConfigIndexType(0); configId.value() < configs.size(); configId++) {
489 const auto& config = configs.at(static_cast<size_t>(configId.value()));
490 const float fps = 1e9f / config->getVsyncPeriod();
491 mRefreshRates.emplace(configId,
492 std::make_unique<RefreshRate>(configId, config,
Marin Shalamanov46084422020-10-13 12:33:42 +0200493 base::StringPrintf("%.2ffps", fps), fps,
Ady Abrahamabc27602020-04-08 17:20:29 -0700494 RefreshRate::ConstructorTag(0)));
495 if (configId == currentConfigId) {
496 mCurrentRefreshRate = mRefreshRates.at(configId).get();
497 }
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800498 }
Ady Abrahamabc27602020-04-08 17:20:29 -0700499
500 std::vector<const RefreshRate*> sortedConfigs;
501 getSortedRefreshRateList([](const RefreshRate&) { return true; }, &sortedConfigs);
502 mDisplayManagerPolicy.defaultConfig = currentConfigId;
503 mMinSupportedRefreshRate = sortedConfigs.front();
504 mMaxSupportedRefreshRate = sortedConfigs.back();
505 constructAvailableRefreshRates();
Ady Abrahamb4b1e0a2019-11-20 18:25:35 -0800506}
507
Steven Thomasd4071902020-03-24 16:02:53 -0700508bool RefreshRateConfigs::isPolicyValid(const Policy& policy) {
509 // defaultConfig must be a valid config, and within the given refresh rate range.
510 auto iter = mRefreshRates.find(policy.defaultConfig);
511 if (iter == mRefreshRates.end()) {
Marin Shalamanovb6674e72020-11-06 13:05:57 +0100512 ALOGE("Default config is not found.");
Steven Thomasd4071902020-03-24 16:02:53 -0700513 return false;
514 }
515 const RefreshRate& refreshRate = *iter->second;
Steven Thomasf734df42020-04-13 21:09:28 -0700516 if (!refreshRate.inPolicy(policy.primaryRange.min, policy.primaryRange.max)) {
Marin Shalamanovb6674e72020-11-06 13:05:57 +0100517 ALOGE("Default config is not in the primary range.");
Steven Thomasd4071902020-03-24 16:02:53 -0700518 return false;
519 }
Steven Thomasf734df42020-04-13 21:09:28 -0700520 return policy.appRequestRange.min <= policy.primaryRange.min &&
521 policy.appRequestRange.max >= policy.primaryRange.max;
Steven Thomasd4071902020-03-24 16:02:53 -0700522}
523
524status_t RefreshRateConfigs::setDisplayManagerPolicy(const Policy& policy) {
Ady Abraham2139f732019-11-13 18:56:40 -0800525 std::lock_guard lock(mLock);
Steven Thomasd4071902020-03-24 16:02:53 -0700526 if (!isPolicyValid(policy)) {
Marin Shalamanovb6674e72020-11-06 13:05:57 +0100527 ALOGE("Invalid refresh rate policy: %s", policy.toString().c_str());
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100528 return BAD_VALUE;
529 }
Steven Thomasd4071902020-03-24 16:02:53 -0700530 Policy previousPolicy = *getCurrentPolicyLocked();
531 mDisplayManagerPolicy = policy;
532 if (*getCurrentPolicyLocked() == previousPolicy) {
533 return CURRENT_POLICY_UNCHANGED;
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100534 }
Ady Abraham2139f732019-11-13 18:56:40 -0800535 constructAvailableRefreshRates();
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100536 return NO_ERROR;
537}
538
Steven Thomasd4071902020-03-24 16:02:53 -0700539status_t RefreshRateConfigs::setOverridePolicy(const std::optional<Policy>& policy) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100540 std::lock_guard lock(mLock);
Steven Thomasd4071902020-03-24 16:02:53 -0700541 if (policy && !isPolicyValid(*policy)) {
542 return BAD_VALUE;
543 }
544 Policy previousPolicy = *getCurrentPolicyLocked();
545 mOverridePolicy = policy;
546 if (*getCurrentPolicyLocked() == previousPolicy) {
547 return CURRENT_POLICY_UNCHANGED;
548 }
549 constructAvailableRefreshRates();
550 return NO_ERROR;
551}
552
553const RefreshRateConfigs::Policy* RefreshRateConfigs::getCurrentPolicyLocked() const {
554 return mOverridePolicy ? &mOverridePolicy.value() : &mDisplayManagerPolicy;
555}
556
557RefreshRateConfigs::Policy RefreshRateConfigs::getCurrentPolicy() const {
558 std::lock_guard lock(mLock);
559 return *getCurrentPolicyLocked();
560}
561
562RefreshRateConfigs::Policy RefreshRateConfigs::getDisplayManagerPolicy() const {
563 std::lock_guard lock(mLock);
564 return mDisplayManagerPolicy;
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100565}
566
567bool RefreshRateConfigs::isConfigAllowed(HwcConfigIndexType config) const {
568 std::lock_guard lock(mLock);
Steven Thomasf734df42020-04-13 21:09:28 -0700569 for (const RefreshRate* refreshRate : mAppRequestRefreshRates) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100570 if (refreshRate->configId == config) {
571 return true;
572 }
573 }
574 return false;
Ady Abraham2139f732019-11-13 18:56:40 -0800575}
576
577void RefreshRateConfigs::getSortedRefreshRateList(
578 const std::function<bool(const RefreshRate&)>& shouldAddRefreshRate,
579 std::vector<const RefreshRate*>* outRefreshRates) {
580 outRefreshRates->clear();
581 outRefreshRates->reserve(mRefreshRates.size());
582 for (const auto& [type, refreshRate] : mRefreshRates) {
Ady Abraham2e1dd892020-03-05 13:48:36 -0800583 if (shouldAddRefreshRate(*refreshRate)) {
Ady Abraham2139f732019-11-13 18:56:40 -0800584 ALOGV("getSortedRefreshRateList: config %d added to list policy",
Ady Abraham2e1dd892020-03-05 13:48:36 -0800585 refreshRate->configId.value());
586 outRefreshRates->push_back(refreshRate.get());
Ady Abraham2139f732019-11-13 18:56:40 -0800587 }
588 }
589
590 std::sort(outRefreshRates->begin(), outRefreshRates->end(),
591 [](const auto refreshRate1, const auto refreshRate2) {
Ady Abrahamabc27602020-04-08 17:20:29 -0700592 if (refreshRate1->hwcConfig->getVsyncPeriod() !=
593 refreshRate2->hwcConfig->getVsyncPeriod()) {
594 return refreshRate1->hwcConfig->getVsyncPeriod() >
595 refreshRate2->hwcConfig->getVsyncPeriod();
Steven Thomasd4071902020-03-24 16:02:53 -0700596 } else {
Ady Abrahamabc27602020-04-08 17:20:29 -0700597 return refreshRate1->hwcConfig->getConfigGroup() >
598 refreshRate2->hwcConfig->getConfigGroup();
Steven Thomasd4071902020-03-24 16:02:53 -0700599 }
Ady Abraham2139f732019-11-13 18:56:40 -0800600 });
601}
602
603void RefreshRateConfigs::constructAvailableRefreshRates() {
604 // Filter configs based on current policy and sort based on vsync period
Steven Thomasd4071902020-03-24 16:02:53 -0700605 const Policy* policy = getCurrentPolicyLocked();
Ady Abrahamabc27602020-04-08 17:20:29 -0700606 const auto& defaultConfig = mRefreshRates.at(policy->defaultConfig)->hwcConfig;
Steven Thomasf734df42020-04-13 21:09:28 -0700607 ALOGV("constructAvailableRefreshRates: default %d group %d primaryRange=[%.2f %.2f]"
608 " appRequestRange=[%.2f %.2f]",
609 policy->defaultConfig.value(), defaultConfig->getConfigGroup(), policy->primaryRange.min,
610 policy->primaryRange.max, policy->appRequestRange.min, policy->appRequestRange.max);
Ady Abrahamabc27602020-04-08 17:20:29 -0700611
Steven Thomasf734df42020-04-13 21:09:28 -0700612 auto filterRefreshRates = [&](float min, float max, const char* listName,
613 std::vector<const RefreshRate*>* outRefreshRates) {
614 getSortedRefreshRateList(
615 [&](const RefreshRate& refreshRate) REQUIRES(mLock) {
616 const auto& hwcConfig = refreshRate.hwcConfig;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800617
Steven Thomasf734df42020-04-13 21:09:28 -0700618 return hwcConfig->getHeight() == defaultConfig->getHeight() &&
619 hwcConfig->getWidth() == defaultConfig->getWidth() &&
620 hwcConfig->getDpiX() == defaultConfig->getDpiX() &&
621 hwcConfig->getDpiY() == defaultConfig->getDpiY() &&
622 (policy->allowGroupSwitching ||
623 hwcConfig->getConfigGroup() == defaultConfig->getConfigGroup()) &&
624 refreshRate.inPolicy(min, max);
625 },
626 outRefreshRates);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800627
Steven Thomasf734df42020-04-13 21:09:28 -0700628 LOG_ALWAYS_FATAL_IF(outRefreshRates->empty(),
629 "No matching configs for %s range: min=%.0f max=%.0f", listName, min,
630 max);
631 auto stringifyRefreshRates = [&]() -> std::string {
632 std::string str;
633 for (auto refreshRate : *outRefreshRates) {
634 base::StringAppendF(&str, "%s ", refreshRate->name.c_str());
635 }
636 return str;
637 };
638 ALOGV("%s refresh rates: %s", listName, stringifyRefreshRates().c_str());
639 };
640
641 filterRefreshRates(policy->primaryRange.min, policy->primaryRange.max, "primary",
642 &mPrimaryRefreshRates);
643 filterRefreshRates(policy->appRequestRange.min, policy->appRequestRange.max, "app request",
644 &mAppRequestRefreshRates);
Ady Abraham2139f732019-11-13 18:56:40 -0800645}
646
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700647std::vector<float> RefreshRateConfigs::constructKnownFrameRates(
648 const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) {
649 std::vector<float> knownFrameRates = {24.0f, 30.0f, 45.0f, 60.0f, 72.0f};
650 knownFrameRates.reserve(knownFrameRates.size() + configs.size());
651
652 // Add all supported refresh rates to the set
653 for (const auto& config : configs) {
654 const auto refreshRate = 1e9f / config->getVsyncPeriod();
655 knownFrameRates.emplace_back(refreshRate);
656 }
657
658 // Sort and remove duplicates
659 const auto frameRatesEqual = [](float a, float b) { return std::abs(a - b) <= 0.01f; };
660 std::sort(knownFrameRates.begin(), knownFrameRates.end());
661 knownFrameRates.erase(std::unique(knownFrameRates.begin(), knownFrameRates.end(),
662 frameRatesEqual),
663 knownFrameRates.end());
664 return knownFrameRates;
665}
666
667float RefreshRateConfigs::findClosestKnownFrameRate(float frameRate) const {
668 if (frameRate <= *mKnownFrameRates.begin()) {
669 return *mKnownFrameRates.begin();
670 }
671
672 if (frameRate >= *std::prev(mKnownFrameRates.end())) {
673 return *std::prev(mKnownFrameRates.end());
674 }
675
676 auto lowerBound = std::lower_bound(mKnownFrameRates.begin(), mKnownFrameRates.end(), frameRate);
677
678 const auto distance1 = std::abs(frameRate - *lowerBound);
679 const auto distance2 = std::abs(frameRate - *std::prev(lowerBound));
680 return distance1 < distance2 ? *lowerBound : *std::prev(lowerBound);
681}
682
Ana Krulecb9afd792020-06-11 13:16:15 -0700683RefreshRateConfigs::KernelIdleTimerAction RefreshRateConfigs::getIdleTimerAction() const {
684 std::lock_guard lock(mLock);
685 const auto& deviceMin = getMinRefreshRate();
686 const auto& minByPolicy = getMinRefreshRateByPolicyLocked();
687 const auto& maxByPolicy = getMaxRefreshRateByPolicyLocked();
688
689 // Kernel idle timer will set the refresh rate to the device min. If DisplayManager says that
690 // the min allowed refresh rate is higher than the device min, we do not want to enable the
691 // timer.
692 if (deviceMin < minByPolicy) {
693 return RefreshRateConfigs::KernelIdleTimerAction::TurnOff;
694 }
695 if (minByPolicy == maxByPolicy) {
696 // Do not sent the call to toggle off kernel idle timer if the device min and policy min and
697 // max are all the same. This saves us extra unnecessary calls to sysprop.
698 if (deviceMin == minByPolicy) {
699 return RefreshRateConfigs::KernelIdleTimerAction::NoChange;
700 }
701 return RefreshRateConfigs::KernelIdleTimerAction::TurnOff;
702 }
703 // Turn on the timer in all other cases.
704 return RefreshRateConfigs::KernelIdleTimerAction::TurnOn;
705}
706
Ady Abraham0bb6a472020-10-12 10:22:13 -0700707void RefreshRateConfigs::setPreferredRefreshRateForUid(uid_t uid, float refreshRateHz) {
708 if (refreshRateHz > 0 && refreshRateHz < 1) {
709 return;
710 }
711
712 std::lock_guard lock(mLock);
713 if (refreshRateHz != 0) {
714 mPreferredRefreshRateForUid[uid] = refreshRateHz;
715 } else {
716 mPreferredRefreshRateForUid.erase(uid);
717 }
718}
719
720int RefreshRateConfigs::getRefreshRateDividerForUid(uid_t uid) const {
721 constexpr float kThreshold = 0.1f;
722 std::lock_guard lock(mLock);
723
724 const auto iter = mPreferredRefreshRateForUid.find(uid);
725 if (iter == mPreferredRefreshRateForUid.end()) {
726 return 1;
727 }
728
729 const auto refreshRateHz = iter->second;
730 const auto numPeriods = mCurrentRefreshRate->getFps() / refreshRateHz;
731 const auto numPeriodsRounded = std::round(numPeriods);
732 if (std::abs(numPeriods - numPeriodsRounded) > kThreshold) {
733 return 1;
734 }
735
736 return static_cast<int>(numPeriods);
737}
738
Marin Shalamanovba421a82020-11-10 21:49:26 +0100739void RefreshRateConfigs::dump(std::string& result) const {
740 std::lock_guard lock(mLock);
741 base::StringAppendF(&result, "DesiredDisplayConfigSpecs (DisplayManager): %s\n\n",
742 mDisplayManagerPolicy.toString().c_str());
743 scheduler::RefreshRateConfigs::Policy currentPolicy = *getCurrentPolicyLocked();
744 if (mOverridePolicy && currentPolicy != mDisplayManagerPolicy) {
745 base::StringAppendF(&result, "DesiredDisplayConfigSpecs (Override): %s\n\n",
746 currentPolicy.toString().c_str());
747 }
748
749 auto config = mCurrentRefreshRate->hwcConfig;
750 base::StringAppendF(&result, "Current config: %s\n", mCurrentRefreshRate->toString().c_str());
751
752 result.append("Refresh rates:\n");
753 for (const auto& [id, refreshRate] : mRefreshRates) {
754 config = refreshRate->hwcConfig;
755 base::StringAppendF(&result, "\t%s\n", refreshRate->toString().c_str());
756 }
757
758 result.append("\n");
759}
760
Ady Abraham2139f732019-11-13 18:56:40 -0800761} // namespace android::scheduler