blob: 3159352db9ab1075f6aed6a6cd41fe82d6711c9a [file] [log] [blame]
Ana Krulecb43429d2019-01-09 14:28:51 -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 */
16
17#pragma once
18
Dominik Laskowski98041832019-08-01 18:35:59 -070019#include <android-base/stringprintf.h>
20
Ana Krulecb43429d2019-01-09 14:28:51 -080021#include <algorithm>
22#include <numeric>
Steven Thomasd4071902020-03-24 16:02:53 -070023#include <optional>
Dominik Laskowski98041832019-08-01 18:35:59 -070024#include <type_traits>
Ana Krulecb43429d2019-01-09 14:28:51 -080025
Ana Krulec4593b692019-01-11 22:07:25 -080026#include "DisplayHardware/HWComposer.h"
Ady Abraham2139f732019-11-13 18:56:40 -080027#include "HwcStrongTypes.h"
Ana Krulec4593b692019-01-11 22:07:25 -080028#include "Scheduler/SchedulerUtils.h"
Ady Abraham2139f732019-11-13 18:56:40 -080029#include "Scheduler/StrongTyping.h"
Ana Krulec4593b692019-01-11 22:07:25 -080030
Dominik Laskowski98041832019-08-01 18:35:59 -070031namespace android::scheduler {
Ady Abrahamabc27602020-04-08 17:20:29 -070032
Ady Abraham4ccdcb42020-02-11 17:34:34 -080033using namespace std::chrono_literals;
Dominik Laskowski98041832019-08-01 18:35:59 -070034
35enum class RefreshRateConfigEvent : unsigned { None = 0b0, Changed = 0b1 };
36
37inline RefreshRateConfigEvent operator|(RefreshRateConfigEvent lhs, RefreshRateConfigEvent rhs) {
38 using T = std::underlying_type_t<RefreshRateConfigEvent>;
39 return static_cast<RefreshRateConfigEvent>(static_cast<T>(lhs) | static_cast<T>(rhs));
40}
Ana Krulecb43429d2019-01-09 14:28:51 -080041
42/**
Ady Abraham1902d072019-03-01 17:18:59 -080043 * This class is used to encapsulate configuration for refresh rates. It holds information
Ana Krulecb43429d2019-01-09 14:28:51 -080044 * about available refresh rates on the device, and the mapping between the numbers and human
45 * readable names.
46 */
47class RefreshRateConfigs {
48public:
Ady Abraham4ccdcb42020-02-11 17:34:34 -080049 // Margin used when matching refresh rates to the content desired ones.
50 static constexpr nsecs_t MARGIN_FOR_PERIOD_CALCULATION =
51 std::chrono::nanoseconds(800us).count();
52
Ady Abrahamabc27602020-04-08 17:20:29 -070053 class RefreshRate {
54 private:
55 // Effectively making the constructor private while allowing
56 // std::make_unique to create the object
57 struct ConstructorTag {
58 explicit ConstructorTag(int) {}
59 };
Ana Krulec72f0d6e2020-01-06 15:24:47 -080060
Ady Abrahamabc27602020-04-08 17:20:29 -070061 public:
62 RefreshRate(HwcConfigIndexType configId,
63 std::shared_ptr<const HWC2::Display::Config> config, std::string name,
64 float fps, ConstructorTag)
65 : configId(configId), hwcConfig(config), name(std::move(name)), fps(fps) {}
Ady Abraham2e1dd892020-03-05 13:48:36 -080066
67 RefreshRate(const RefreshRate&) = delete;
Ady Abrahamabc27602020-04-08 17:20:29 -070068
69 HwcConfigIndexType getConfigId() const { return configId; }
70 nsecs_t getVsyncPeriod() const { return hwcConfig->getVsyncPeriod(); }
71 int32_t getConfigGroup() const { return hwcConfig->getConfigGroup(); }
72 const std::string& getName() const { return name; }
73 float getFps() const { return fps; }
Ady Abraham2139f732019-11-13 18:56:40 -080074
Ana Krulec72f0d6e2020-01-06 15:24:47 -080075 // Checks whether the fps of this RefreshRate struct is within a given min and max refresh
76 // rate passed in. FPS_EPSILON is applied to the boundaries for approximation.
77 bool inPolicy(float minRefreshRate, float maxRefreshRate) const {
78 return (fps >= (minRefreshRate - FPS_EPSILON) && fps <= (maxRefreshRate + FPS_EPSILON));
79 }
80
Ady Abraham2139f732019-11-13 18:56:40 -080081 bool operator!=(const RefreshRate& other) const {
Ady Abrahamabc27602020-04-08 17:20:29 -070082 return configId != other.configId || hwcConfig != other.hwcConfig;
Ady Abraham2139f732019-11-13 18:56:40 -080083 }
84
Ana Krulecb9afd792020-06-11 13:16:15 -070085 bool operator<(const RefreshRate& other) const { return getFps() < other.getFps(); }
86
Ady Abraham2139f732019-11-13 18:56:40 -080087 bool operator==(const RefreshRate& other) const { return !(*this != other); }
Ady Abrahamabc27602020-04-08 17:20:29 -070088
Marin Shalamanov46084422020-10-13 12:33:42 +020089 std::string toString() const;
90
Ady Abrahamabc27602020-04-08 17:20:29 -070091 private:
92 friend RefreshRateConfigs;
Ady Abrahamb1b9d412020-06-01 19:53:52 -070093 friend class RefreshRateConfigsTest;
Ady Abrahamabc27602020-04-08 17:20:29 -070094
95 // The tolerance within which we consider FPS approximately equals.
96 static constexpr float FPS_EPSILON = 0.001f;
97
98 // This config ID corresponds to the position of the config in the vector that is stored
99 // on the device.
100 const HwcConfigIndexType configId;
101 // The config itself
102 std::shared_ptr<const HWC2::Display::Config> hwcConfig;
103 // Human readable name of the refresh rate.
104 const std::string name;
105 // Refresh rate in frames per second
106 const float fps = 0;
Ana Krulecb43429d2019-01-09 14:28:51 -0800107 };
108
Ady Abraham2e1dd892020-03-05 13:48:36 -0800109 using AllRefreshRatesMapType =
110 std::unordered_map<HwcConfigIndexType, std::unique_ptr<const RefreshRate>>;
Ady Abraham2139f732019-11-13 18:56:40 -0800111
Steven Thomasd4071902020-03-24 16:02:53 -0700112 struct Policy {
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200113 private:
114 static constexpr int kAllowGroupSwitchingDefault = false;
115
116 public:
Steven Thomasf734df42020-04-13 21:09:28 -0700117 struct Range {
118 float min = 0;
119 float max = std::numeric_limits<float>::max();
120
121 bool operator==(const Range& other) const {
122 return min == other.min && max == other.max;
123 }
124
125 bool operator!=(const Range& other) const { return !(*this == other); }
126 };
127
Steven Thomasd4071902020-03-24 16:02:53 -0700128 // The default config, used to ensure we only initiate display config switches within the
129 // same config group as defaultConfigId's group.
130 HwcConfigIndexType defaultConfig;
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200131 // Whether or not we switch config groups to get the best frame rate.
132 bool allowGroupSwitching = kAllowGroupSwitchingDefault;
Steven Thomasf734df42020-04-13 21:09:28 -0700133 // The primary refresh rate range represents display manager's general guidance on the
134 // display configs we'll consider when switching refresh rates. Unless we get an explicit
135 // signal from an app, we should stay within this range.
136 Range primaryRange;
137 // The app request refresh rate range allows us to consider more display configs when
138 // switching refresh rates. Although we should generally stay within the primary range,
139 // specific considerations, such as layer frame rate settings specified via the
140 // setFrameRate() api, may cause us to go outside the primary range. We never go outside the
141 // app request range. The app request range will be greater than or equal to the primary
142 // refresh rate range, never smaller.
143 Range appRequestRange;
Steven Thomasd4071902020-03-24 16:02:53 -0700144
Steven Thomasf734df42020-04-13 21:09:28 -0700145 Policy() = default;
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200146
Steven Thomasf734df42020-04-13 21:09:28 -0700147 Policy(HwcConfigIndexType defaultConfig, const Range& range)
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200148 : Policy(defaultConfig, kAllowGroupSwitchingDefault, range, range) {}
149
150 Policy(HwcConfigIndexType defaultConfig, bool allowGroupSwitching, const Range& range)
151 : Policy(defaultConfig, allowGroupSwitching, range, range) {}
152
Steven Thomasf734df42020-04-13 21:09:28 -0700153 Policy(HwcConfigIndexType defaultConfig, const Range& primaryRange,
154 const Range& appRequestRange)
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200155 : Policy(defaultConfig, kAllowGroupSwitchingDefault, primaryRange, appRequestRange) {}
156
157 Policy(HwcConfigIndexType defaultConfig, bool allowGroupSwitching,
158 const Range& primaryRange, const Range& appRequestRange)
Steven Thomasf734df42020-04-13 21:09:28 -0700159 : defaultConfig(defaultConfig),
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200160 allowGroupSwitching(allowGroupSwitching),
Steven Thomasf734df42020-04-13 21:09:28 -0700161 primaryRange(primaryRange),
162 appRequestRange(appRequestRange) {}
163
Steven Thomasd4071902020-03-24 16:02:53 -0700164 bool operator==(const Policy& other) const {
Steven Thomasf734df42020-04-13 21:09:28 -0700165 return defaultConfig == other.defaultConfig && primaryRange == other.primaryRange &&
166 appRequestRange == other.appRequestRange &&
Steven Thomasd4071902020-03-24 16:02:53 -0700167 allowGroupSwitching == other.allowGroupSwitching;
168 }
169
170 bool operator!=(const Policy& other) const { return !(*this == other); }
Marin Shalamanovb6674e72020-11-06 13:05:57 +0100171 std::string toString() const;
Steven Thomasd4071902020-03-24 16:02:53 -0700172 };
173
174 // Return code set*Policy() to indicate the current policy is unchanged.
175 static constexpr int CURRENT_POLICY_UNCHANGED = 1;
176
177 // We maintain the display manager policy and the override policy separately. The override
178 // policy is used by CTS tests to get a consistent device state for testing. While the override
179 // policy is set, it takes precedence over the display manager policy. Once the override policy
180 // is cleared, we revert to using the display manager policy.
181
182 // Sets the display manager policy to choose refresh rates. The return value will be:
183 // - A negative value if the policy is invalid or another error occurred.
184 // - NO_ERROR if the policy was successfully updated, and the current policy is different from
185 // what it was before the call.
186 // - CURRENT_POLICY_UNCHANGED if the policy was successfully updated, but the current policy
187 // is the same as it was before the call.
188 status_t setDisplayManagerPolicy(const Policy& policy) EXCLUDES(mLock);
189 // Sets the override policy. See setDisplayManagerPolicy() for the meaning of the return value.
190 status_t setOverridePolicy(const std::optional<Policy>& policy) EXCLUDES(mLock);
191 // Gets the current policy, which will be the override policy if active, and the display manager
192 // policy otherwise.
193 Policy getCurrentPolicy() const EXCLUDES(mLock);
194 // Gets the display manager policy, regardless of whether an override policy is active.
195 Policy getDisplayManagerPolicy() const EXCLUDES(mLock);
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100196
197 // Returns true if config is allowed by the current policy.
198 bool isConfigAllowed(HwcConfigIndexType config) const EXCLUDES(mLock);
Ady Abraham2139f732019-11-13 18:56:40 -0800199
Ady Abraham8a82ba62020-01-17 12:43:17 -0800200 // Describes the different options the layer voted for refresh rate
201 enum class LayerVoteType {
Ady Abraham71c437d2020-01-31 15:56:57 -0800202 NoVote, // Doesn't care about the refresh rate
203 Min, // Minimal refresh rate available
204 Max, // Maximal refresh rate available
205 Heuristic, // Specific refresh rate that was calculated by platform using a heuristic
206 ExplicitDefault, // Specific refresh rate that was provided by the app with Default
207 // compatibility
208 ExplicitExactOrMultiple // Specific refresh rate that was provided by the app with
209 // ExactOrMultiple compatibility
Ady Abraham8a82ba62020-01-17 12:43:17 -0800210 };
211
212 // Captures the layer requirements for a refresh rate. This will be used to determine the
213 // display refresh rate.
214 struct LayerRequirement {
Ady Abrahamaae5ed52020-06-26 09:32:43 -0700215 // Layer's name. Used for debugging purposes.
216 std::string name;
217 // Layer vote type.
218 LayerVoteType vote = LayerVoteType::NoVote;
219 // Layer's desired refresh rate, if applicable.
220 float desiredRefreshRate = 0.0f;
Marin Shalamanov46084422020-10-13 12:33:42 +0200221 // If a seamless mode switch is required.
222 bool shouldBeSeamless = true;
Ady Abrahamaae5ed52020-06-26 09:32:43 -0700223 // Layer's weight in the range of [0, 1]. The higher the weight the more impact this layer
224 // would have on choosing the refresh rate.
225 float weight = 0.0f;
226 // Whether layer is in focus or not based on WindowManager's state
227 bool focused = false;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800228
229 bool operator==(const LayerRequirement& other) const {
230 return name == other.name && vote == other.vote &&
Ady Abrahamaae5ed52020-06-26 09:32:43 -0700231 desiredRefreshRate == other.desiredRefreshRate && weight == other.weight &&
232 focused == other.focused;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800233 }
234
235 bool operator!=(const LayerRequirement& other) const { return !(*this == other); }
236 };
237
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800238 // Returns the refresh rate that fits best to the given layers.
Ady Abraham8a82ba62020-01-17 12:43:17 -0800239 const RefreshRate& getRefreshRateForContent(const std::vector<LayerRequirement>& layers) const
240 EXCLUDES(mLock);
241
Ady Abrahamdfd62162020-06-10 16:11:56 -0700242 // Global state describing signals that affect refresh rate choice.
243 struct GlobalSignals {
244 // Whether the user touched the screen recently. Used to apply touch boost.
245 bool touch = false;
246 // True if the system hasn't seen any buffers posted to layers recently.
247 bool idle = false;
248 };
249
Steven Thomasbb374322020-04-28 22:47:16 -0700250 // Returns the refresh rate that fits best to the given layers.
251 // layers - The layer requirements to consider.
Ady Abrahamdfd62162020-06-10 16:11:56 -0700252 // globalSignals - global state of touch and idle
253 // outSignalsConsidered - An output param that tells the caller whether the refresh rate was
254 // chosen based on touch boost and/or idle timer.
Steven Thomasbb374322020-04-28 22:47:16 -0700255 const RefreshRate& getBestRefreshRate(const std::vector<LayerRequirement>& layers,
Ady Abrahamdfd62162020-06-10 16:11:56 -0700256 const GlobalSignals& globalSignals,
257 GlobalSignals* outSignalsConsidered = nullptr) const
Ady Abraham6fb599b2020-03-05 13:48:22 -0800258 EXCLUDES(mLock);
Ana Krulecb43429d2019-01-09 14:28:51 -0800259
Ady Abraham2139f732019-11-13 18:56:40 -0800260 // Returns all the refresh rates supported by the device. This won't change at runtime.
261 const AllRefreshRatesMapType& getAllRefreshRates() const EXCLUDES(mLock);
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700262
Ady Abraham2139f732019-11-13 18:56:40 -0800263 // Returns the lowest refresh rate supported by the device. This won't change at runtime.
264 const RefreshRate& getMinRefreshRate() const { return *mMinSupportedRefreshRate; }
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700265
Steven Thomasf734df42020-04-13 21:09:28 -0700266 // Returns the lowest refresh rate according to the current policy. May change at runtime. Only
267 // uses the primary range, not the app request range.
Ady Abraham2139f732019-11-13 18:56:40 -0800268 const RefreshRate& getMinRefreshRateByPolicy() const EXCLUDES(mLock);
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700269
Ady Abraham2139f732019-11-13 18:56:40 -0800270 // Returns the highest refresh rate supported by the device. This won't change at runtime.
271 const RefreshRate& getMaxRefreshRate() const { return *mMaxSupportedRefreshRate; }
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700272
Steven Thomasf734df42020-04-13 21:09:28 -0700273 // Returns the highest refresh rate according to the current policy. May change at runtime. Only
274 // uses the primary range, not the app request range.
Ady Abraham2139f732019-11-13 18:56:40 -0800275 const RefreshRate& getMaxRefreshRateByPolicy() const EXCLUDES(mLock);
276
277 // Returns the current refresh rate
278 const RefreshRate& getCurrentRefreshRate() const EXCLUDES(mLock);
279
Ana Krulec5d477912020-02-07 12:02:38 -0800280 // Returns the current refresh rate, if allowed. Otherwise the default that is allowed by
281 // the policy.
282 const RefreshRate& getCurrentRefreshRateByPolicy() const;
283
Ady Abraham2139f732019-11-13 18:56:40 -0800284 // Returns the refresh rate that corresponds to a HwcConfigIndexType. This won't change at
285 // runtime.
286 const RefreshRate& getRefreshRateFromConfigId(HwcConfigIndexType configId) const {
Ady Abraham2e1dd892020-03-05 13:48:36 -0800287 return *mRefreshRates.at(configId);
Ady Abraham2139f732019-11-13 18:56:40 -0800288 };
289
290 // Stores the current configId the device operates at
291 void setCurrentConfigId(HwcConfigIndexType configId) EXCLUDES(mLock);
Dominik Laskowski22488f62019-03-28 09:53:04 -0700292
Ady Abrahama6b676e2020-05-27 14:29:09 -0700293 // Returns a string that represents the layer vote type
294 static std::string layerVoteTypeString(LayerVoteType vote);
295
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700296 // Returns a known frame rate that is the closest to frameRate
297 float findClosestKnownFrameRate(float frameRate) const;
298
Ana Krulec3f6a2062020-01-23 15:48:01 -0800299 RefreshRateConfigs(const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs,
Ady Abraham2139f732019-11-13 18:56:40 -0800300 HwcConfigIndexType currentConfigId);
Ana Krulec4593b692019-01-11 22:07:25 -0800301
Dominik Laskowski983f2b52020-06-25 16:54:06 -0700302 // Returns whether switching configs (refresh rate or resolution) is possible.
303 // TODO(b/158780872): Consider HAL support, and skip frame rate detection if the configs only
304 // differ in resolution.
305 bool canSwitch() const { return mRefreshRates.size() > 1; }
306
Ana Krulecb9afd792020-06-11 13:16:15 -0700307 // Class to enumerate options around toggling the kernel timer on and off. We have an option
308 // for no change to avoid extra calls to kernel.
309 enum class KernelIdleTimerAction {
310 NoChange, // Do not change the idle timer.
311 TurnOff, // Turn off the idle timer.
312 TurnOn // Turn on the idle timer.
313 };
314 // Checks whether kernel idle timer should be active depending the policy decisions around
315 // refresh rates.
316 KernelIdleTimerAction getIdleTimerAction() const;
317
Ady Abraham0bb6a472020-10-12 10:22:13 -0700318 // Stores the preferred refresh rate that an app should run at.
319 // refreshRate == 0 means no preference.
320 void setPreferredRefreshRateForUid(uid_t, float refreshRateHz) EXCLUDES(mLock);
321
322 // Returns a divider for the current refresh rate
323 int getRefreshRateDividerForUid(uid_t) const EXCLUDES(mLock);
324
Marin Shalamanovba421a82020-11-10 21:49:26 +0100325 void dump(std::string& result) const EXCLUDES(mLock);
326
Dominik Laskowski22488f62019-03-28 09:53:04 -0700327private:
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700328 friend class RefreshRateConfigsTest;
329
Ady Abraham2139f732019-11-13 18:56:40 -0800330 void constructAvailableRefreshRates() REQUIRES(mLock);
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700331 static std::vector<float> constructKnownFrameRates(
332 const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs);
Ady Abraham2139f732019-11-13 18:56:40 -0800333
334 void getSortedRefreshRateList(
335 const std::function<bool(const RefreshRate&)>& shouldAddRefreshRate,
336 std::vector<const RefreshRate*>* outRefreshRates);
337
Ady Abraham34702102020-02-10 14:12:05 -0800338 // Returns the refresh rate with the highest score in the collection specified from begin
339 // to end. If there are more than one with the same highest refresh rate, the first one is
340 // returned.
341 template <typename Iter>
342 const RefreshRate* getBestRefreshRate(Iter begin, Iter end) const;
343
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800344 // Returns number of display frames and remainder when dividing the layer refresh period by
345 // display refresh period.
346 std::pair<nsecs_t, nsecs_t> getDisplayFrames(nsecs_t layerPeriod, nsecs_t displayPeriod) const;
347
Steven Thomasf734df42020-04-13 21:09:28 -0700348 // Returns the lowest refresh rate according to the current policy. May change at runtime. Only
349 // uses the primary range, not the app request range.
350 const RefreshRate& getMinRefreshRateByPolicyLocked() const REQUIRES(mLock);
351
352 // Returns the highest refresh rate according to the current policy. May change at runtime. Only
353 // uses the primary range, not the app request range.
354 const RefreshRate& getMaxRefreshRateByPolicyLocked() const REQUIRES(mLock);
355
Ana Krulec3d367c82020-02-25 15:02:01 -0800356 // Returns the current refresh rate, if allowed. Otherwise the default that is allowed by
357 // the policy.
358 const RefreshRate& getCurrentRefreshRateByPolicyLocked() const REQUIRES(mLock);
359
Steven Thomasd4071902020-03-24 16:02:53 -0700360 const Policy* getCurrentPolicyLocked() const REQUIRES(mLock);
361 bool isPolicyValid(const Policy& policy);
362
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700363 // The list of refresh rates, indexed by display config ID. This must not change after this
364 // object is initialized.
Ady Abraham2139f732019-11-13 18:56:40 -0800365 AllRefreshRatesMapType mRefreshRates;
366
Steven Thomasf734df42020-04-13 21:09:28 -0700367 // The list of refresh rates in the primary range of the current policy, ordered by vsyncPeriod
368 // (the first element is the lowest refresh rate).
369 std::vector<const RefreshRate*> mPrimaryRefreshRates GUARDED_BY(mLock);
370
371 // The list of refresh rates in the app request range of the current policy, ordered by
372 // vsyncPeriod (the first element is the lowest refresh rate).
373 std::vector<const RefreshRate*> mAppRequestRefreshRates GUARDED_BY(mLock);
Ady Abraham2139f732019-11-13 18:56:40 -0800374
375 // The current config. This will change at runtime. This is set by SurfaceFlinger on
376 // the main thread, and read by the Scheduler (and other objects) on other threads.
377 const RefreshRate* mCurrentRefreshRate GUARDED_BY(mLock);
378
Steven Thomasd4071902020-03-24 16:02:53 -0700379 // The policy values will change at runtime. They're set by SurfaceFlinger on the main thread,
380 // and read by the Scheduler (and other objects) on other threads.
381 Policy mDisplayManagerPolicy GUARDED_BY(mLock);
382 std::optional<Policy> mOverridePolicy GUARDED_BY(mLock);
Ady Abraham2139f732019-11-13 18:56:40 -0800383
Ady Abraham0bb6a472020-10-12 10:22:13 -0700384 std::unordered_map<uid_t, float> mPreferredRefreshRateForUid GUARDED_BY(mLock);
385
Ady Abraham2139f732019-11-13 18:56:40 -0800386 // The min and max refresh rates supported by the device.
387 // This will not change at runtime.
388 const RefreshRate* mMinSupportedRefreshRate;
389 const RefreshRate* mMaxSupportedRefreshRate;
390
Ady Abraham2139f732019-11-13 18:56:40 -0800391 mutable std::mutex mLock;
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700392
393 // A sorted list of known frame rates that a Heuristic layer will choose
394 // from based on the closest value.
395 const std::vector<float> mKnownFrameRates;
Ana Krulecb43429d2019-01-09 14:28:51 -0800396};
397
Dominik Laskowski98041832019-08-01 18:35:59 -0700398} // namespace android::scheduler