blob: a7847bc2406618dbbff741a47a60d2d0636cbf59 [file] [log] [blame]
Ady Abraham8a82ba62020-01-17 12:43:17 -08001/*
2 * Copyright 2020 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 Laskowskif6b4ba62021-11-09 12:46:10 -080019#include <chrono>
20#include <deque>
21#include <optional>
22#include <string>
23#include <unordered_map>
24
Ady Abrahambdda8f02021-04-01 16:06:11 -070025#include <ui/Transform.h>
Ady Abraham8a82ba62020-01-17 12:43:17 -080026#include <utils/Timers.h>
27
Rachel Leece6e0042023-06-27 11:22:54 -070028#include <scheduler/Fps.h>
Dominik Laskowskif6b4ba62021-11-09 12:46:10 -080029#include <scheduler/Seamlessness.h>
Ady Abraham8a82ba62020-01-17 12:43:17 -080030
Vishnu Nair3fbe3262023-09-29 17:07:00 -070031#include "FrameRateCompatibility.h"
Ady Abraham8a82ba62020-01-17 12:43:17 -080032#include "LayerHistory.h"
Dominik Laskowskid82e0f02022-10-26 15:23:04 -040033#include "RefreshRateSelector.h"
Ady Abraham8a82ba62020-01-17 12:43:17 -080034
35namespace android {
36
37class Layer;
38
39namespace scheduler {
40
41using namespace std::chrono_literals;
Vishnu Nairef68d6d2023-02-28 06:18:27 +000042struct LayerProps;
Ady Abraham8a82ba62020-01-17 12:43:17 -080043// Maximum period between presents for a layer to be considered active.
44constexpr std::chrono::nanoseconds MAX_ACTIVE_LAYER_PERIOD_NS = 1200ms;
45
46// Earliest present time for a layer to be considered active.
47constexpr nsecs_t getActiveLayerThreshold(nsecs_t now) {
48 return now - MAX_ACTIVE_LAYER_PERIOD_NS.count();
49}
50
51// Stores history of present times and refresh rates for a layer.
Marin Shalamanov1bc43ee2020-11-20 16:56:52 +010052class LayerInfo {
Ady Abraham5def7332020-05-29 16:13:47 -070053 using LayerUpdateType = LayerHistory::LayerUpdateType;
54
Ady Abraham8a82ba62020-01-17 12:43:17 -080055 // Layer is considered frequent if the earliest value in the window of most recent present times
56 // is within a threshold. If a layer is infrequent, its average refresh rate is disregarded in
57 // favor of a low refresh rate.
Ady Abraham86ac5c52023-01-11 15:24:03 -080058 static constexpr size_t kFrequentLayerWindowSize = 4;
Dominik Laskowski6eab42d2021-09-13 14:34:13 -070059 static constexpr Fps kMinFpsForFrequentLayer = 10_Hz;
Marin Shalamanov2045d5b2020-12-28 18:11:41 +010060 static constexpr auto kMaxPeriodForFrequentLayerNs =
61 std::chrono::nanoseconds(kMinFpsForFrequentLayer.getPeriodNsecs()) + 1ms;
Arthur Hungc70bee22023-06-02 01:35:52 +000062 static constexpr size_t kNumSmallDirtyThreshold = 2;
Ady Abraham8a82ba62020-01-17 12:43:17 -080063
Marin Shalamanov1bc43ee2020-11-20 16:56:52 +010064 friend class LayerHistoryTest;
Vishnu Nair47b7bb42023-09-29 16:27:33 -070065 friend class LayerHistoryIntegrationTest;
Marin Shalamanov2045d5b2020-12-28 18:11:41 +010066 friend class LayerInfoTest;
Ady Abraham8a82ba62020-01-17 12:43:17 -080067
68public:
Marin Shalamanov46084422020-10-13 12:33:42 +020069 // Holds information about the layer vote
70 struct LayerVote {
71 LayerHistory::LayerVoteType type = LayerHistory::LayerVoteType::Heuristic;
Dominik Laskowski6eab42d2021-09-13 14:34:13 -070072 Fps fps;
Marin Shalamanov53fc11d2020-11-20 14:00:13 +010073 Seamlessness seamlessness = Seamlessness::Default;
Rachel Leece6e0042023-06-27 11:22:54 -070074 FrameRateCategory category = FrameRateCategory::Default;
Rachel Lee67afbea2023-09-28 15:35:07 -070075 bool categorySmoothSwitchOnly = false;
Rachel Leece6e0042023-06-27 11:22:54 -070076
77 // Returns true if the layer explicitly should contribute to frame rate scoring.
Rachel Leed0694bc2023-09-12 14:57:58 -070078 bool isNoVote() const { return RefreshRateSelector::isNoVote(type); }
Marin Shalamanov46084422020-10-13 12:33:42 +020079 };
80
Rachel Leece6e0042023-06-27 11:22:54 -070081 using RefreshRateVotes = ftl::SmallVector<LayerInfo::LayerVote, 2>;
82
Rachel Lee58cc90d2023-09-05 18:50:20 -070083 enum class FrameRateSelectionStrategy {
Rachel Lee70f7b692023-11-22 11:24:02 -080084 Propagate,
Rachel Lee58cc90d2023-09-05 18:50:20 -070085 OverrideChildren,
Rachel Lee70f7b692023-11-22 11:24:02 -080086 Self,
Rachel Lee58cc90d2023-09-05 18:50:20 -070087
Rachel Lee70f7b692023-11-22 11:24:02 -080088 ftl_last = Self
Rachel Lee58cc90d2023-09-05 18:50:20 -070089 };
90
Rachel Leece6e0042023-06-27 11:22:54 -070091 // Encapsulates the frame rate specifications of the layer. This information will be used
Ady Abrahambdda8f02021-04-01 16:06:11 -070092 // when the display refresh rate is determined.
93 struct FrameRate {
94 using Seamlessness = scheduler::Seamlessness;
95
Rachel Leece6e0042023-06-27 11:22:54 -070096 // Information related to a specific desired frame rate vote.
97 struct FrameRateVote {
98 Fps rate;
99 FrameRateCompatibility type = FrameRateCompatibility::Default;
100 Seamlessness seamlessness = Seamlessness::Default;
101
102 bool operator==(const FrameRateVote& other) const {
103 return isApproxEqual(rate, other.rate) && type == other.type &&
104 seamlessness == other.seamlessness;
105 }
106
107 FrameRateVote() = default;
108
109 FrameRateVote(Fps rate, FrameRateCompatibility type,
110 Seamlessness seamlessness = Seamlessness::OnlySeamless)
111 : rate(rate), type(type), seamlessness(getSeamlessness(rate, seamlessness)) {}
112 } vote;
113
114 FrameRateCategory category = FrameRateCategory::Default;
Rachel Lee67afbea2023-09-28 15:35:07 -0700115 bool categorySmoothSwitchOnly = false;
Ady Abrahambdda8f02021-04-01 16:06:11 -0700116
Dominik Laskowski6eab42d2021-09-13 14:34:13 -0700117 FrameRate() = default;
118
Ady Abrahambdda8f02021-04-01 16:06:11 -0700119 FrameRate(Fps rate, FrameRateCompatibility type,
Rachel Leece6e0042023-06-27 11:22:54 -0700120 Seamlessness seamlessness = Seamlessness::OnlySeamless,
121 FrameRateCategory category = FrameRateCategory::Default)
122 : vote(FrameRateVote(rate, type, seamlessness)), category(category) {}
Ady Abrahambdda8f02021-04-01 16:06:11 -0700123
124 bool operator==(const FrameRate& other) const {
Rachel Leece6e0042023-06-27 11:22:54 -0700125 return vote == other.vote && category == other.category;
Ady Abrahambdda8f02021-04-01 16:06:11 -0700126 }
127
128 bool operator!=(const FrameRate& other) const { return !(*this == other); }
129
130 // Convert an ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* value to a
131 // Layer::FrameRateCompatibility. Logs fatal if the compatibility value is invalid.
132 static FrameRateCompatibility convertCompatibility(int8_t compatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700133
134 // Convert an ANATIVEWINDOW_CHANGE_FRAME_RATE_* value to a scheduler::Seamlessness.
Rachel Lee58cc90d2023-09-05 18:50:20 -0700135 // Logs fatal if the strategy value is invalid.
Ady Abrahambdda8f02021-04-01 16:06:11 -0700136 static scheduler::Seamlessness convertChangeFrameRateStrategy(int8_t strategy);
137
Rachel Leece6e0042023-06-27 11:22:54 -0700138 // Convert an ANATIVEWINDOW_FRAME_RATE_CATEGORY_* value to a FrameRateCategory.
Rachel Lee58cc90d2023-09-05 18:50:20 -0700139 // Logs fatal if the category value is invalid.
Rachel Leece6e0042023-06-27 11:22:54 -0700140 static FrameRateCategory convertCategory(int8_t category);
141
142 // True if the FrameRate has explicit frame rate specifications.
143 bool isValid() const;
144
145 // Returns true if the FrameRate explicitly instructs to not contribute to frame rate
146 // selection.
147 bool isNoVote() const;
148
Rachel Lee8f2eea42024-04-19 15:15:48 -0700149 // Returns true if the FrameRate has a valid valueless (0 Hz) frame rate type.
150 bool isValuelessType() const;
151
Rachel Lee45681982024-03-14 18:40:15 -0700152 // Checks whether the given FrameRate's vote specifications is valid for MRR devices
153 // given the current flagging.
154 bool isVoteValidForMrr(bool isVrrDevice) const;
155
Ady Abrahambdda8f02021-04-01 16:06:11 -0700156 private:
157 static Seamlessness getSeamlessness(Fps rate, Seamlessness seamlessness) {
158 if (!rate.isValid()) {
159 // Refresh rate of 0 is a special value which should reset the vote to
160 // its default value.
161 return Seamlessness::Default;
162 }
163 return seamlessness;
164 }
165 };
166
Rachel Lee58cc90d2023-09-05 18:50:20 -0700167 // Convert an ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_* value to FrameRateSelectionStrategy.
168 // Logs fatal if the strategy value is invalid.
169 static FrameRateSelectionStrategy convertFrameRateSelectionStrategy(int8_t strategy);
170
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700171 static void setTraceEnabled(bool enabled) { sTraceEnabled = enabled; }
172
Ady Abrahambdda8f02021-04-01 16:06:11 -0700173 LayerInfo(const std::string& name, uid_t ownerUid, LayerHistory::LayerVoteType defaultVote);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800174
Marin Shalamanov1bc43ee2020-11-20 16:56:52 +0100175 LayerInfo(const LayerInfo&) = delete;
176 LayerInfo& operator=(const LayerInfo&) = delete;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800177
178 // Records the last requested present time. It also stores information about when
179 // the layer was last updated. If the present time is farther in the future than the
180 // updated time, the updated time is the present time.
Ady Abraham5def7332020-05-29 16:13:47 -0700181 void setLastPresentTime(nsecs_t lastPresentTime, nsecs_t now, LayerUpdateType updateType,
Vishnu Nairef68d6d2023-02-28 06:18:27 +0000182 bool pendingModeChange, const LayerProps& props);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800183
Ady Abraham8a82ba62020-01-17 12:43:17 -0800184 // Sets an explicit layer vote. This usually comes directly from the application via
Andy Yu8c2703d2023-11-03 11:22:46 -0700185 // ANativeWindow_setFrameRate API. This is also used by Game Default Frame Rate and
186 // Game Mode Intervention Frame Rate.
Marin Shalamanov46084422020-10-13 12:33:42 +0200187 void setLayerVote(LayerVote vote) { mLayerVote = vote; }
Ady Abraham8a82ba62020-01-17 12:43:17 -0800188
189 // Sets the default layer vote. This will be the layer vote after calling to resetLayerVote().
190 // This is used for layers that called to setLayerVote() and then removed the vote, so that the
191 // layer can go back to whatever vote it had before the app voted for it.
192 void setDefaultLayerVote(LayerHistory::LayerVoteType type) { mDefaultVote = type; }
193
Vishnu Nair41376b62023-11-08 05:08:58 -0800194 void setProperties(const LayerProps&);
195
Ady Abraham8a82ba62020-01-17 12:43:17 -0800196 // Resets the layer vote to its default.
Rachel Leece6e0042023-06-27 11:22:54 -0700197 void resetLayerVote() {
198 mLayerVote = {mDefaultVote, Fps(), Seamlessness::Default, FrameRateCategory::Default};
199 }
Ady Abraham8a82ba62020-01-17 12:43:17 -0800200
Ady Abrahambdda8f02021-04-01 16:06:11 -0700201 std::string getName() const { return mName; }
202
203 uid_t getOwnerUid() const { return mOwnerUid; }
204
Rachel Leece6e0042023-06-27 11:22:54 -0700205 RefreshRateVotes getRefreshRateVote(const RefreshRateSelector&, nsecs_t now);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800206
207 // Return the last updated time. If the present time is farther in the future than the
208 // updated time, the updated time is the present time.
209 nsecs_t getLastUpdatedTime() const { return mLastUpdatedTime; }
210
Vishnu Nairef68d6d2023-02-28 06:18:27 +0000211 FrameRate getSetFrameRateVote() const;
212 bool isVisible() const;
213 int32_t getFrameRateSelectionPriority() const;
Alec Mouri89f5d4e2023-10-20 17:12:49 +0000214 bool isFrontBuffered() const;
Vishnu Nairef68d6d2023-02-28 06:18:27 +0000215 FloatRect getBounds() const;
216 ui::Transform getTransform() const;
Ady Abrahambdda8f02021-04-01 16:06:11 -0700217
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700218 // Returns a C string for tracing a vote
219 const char* getTraceTag(LayerHistory::LayerVoteType type) const;
220
Nathaniel Nifong1303d912021-10-06 09:41:24 -0400221 // Return the framerate of this layer.
222 Fps getFps(nsecs_t now) const;
223
Ady Abraham983e5682020-05-28 16:49:18 -0700224 void onLayerInactive(nsecs_t now) {
Ady Abrahamdfb63ba2020-05-27 20:05:05 +0000225 // Mark mFrameTimeValidSince to now to ignore all previous frame times.
226 // We are not deleting the old frame to keep track of whether we should treat the first
227 // buffer as Max as we don't know anything about this layer or Min as this layer is
228 // posting infrequent updates.
Ady Abraham983e5682020-05-28 16:49:18 -0700229 const auto timePoint = std::chrono::nanoseconds(now);
230 mFrameTimeValidSince = std::chrono::time_point<std::chrono::steady_clock>(timePoint);
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700231 mLastRefreshRate = {};
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700232 mRefreshRateHistory.clear();
ramindani63db24e2023-04-03 10:56:05 -0700233 mIsFrequencyConclusive = true;
Ady Abrahama61edcb2020-01-30 18:32:03 -0800234 }
Ady Abraham8a82ba62020-01-17 12:43:17 -0800235
Ady Abraham983e5682020-05-28 16:49:18 -0700236 void clearHistory(nsecs_t now) {
237 onLayerInactive(now);
238 mFrameTimes.clear();
239 }
240
Ady Abraham8a82ba62020-01-17 12:43:17 -0800241private:
Ady Abrahama61edcb2020-01-30 18:32:03 -0800242 // Used to store the layer timestamps
243 struct FrameTimeData {
Marin Shalamanov2045d5b2020-12-28 18:11:41 +0100244 nsecs_t presentTime; // desiredPresentTime, if provided
Ady Abrahama61edcb2020-01-30 18:32:03 -0800245 nsecs_t queueTime; // buffer queue time
Marin Shalamanova7fe3042021-01-29 21:02:08 +0100246 bool pendingModeChange;
Arthur Hungc70bee22023-06-02 01:35:52 +0000247 bool isSmallDirty;
Ady Abrahama61edcb2020-01-30 18:32:03 -0800248 };
249
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700250 // Holds information about the calculated and reported refresh rate
251 struct RefreshRateHeuristicData {
252 // Rate calculated on the layer
Dominik Laskowski6eab42d2021-09-13 14:34:13 -0700253 Fps calculated;
Marin Shalamanov1bc43ee2020-11-20 16:56:52 +0100254 // Last reported rate for LayerInfo::getRefreshRate()
Dominik Laskowski6eab42d2021-09-13 14:34:13 -0700255 Fps reported;
Marin Shalamanov1bc43ee2020-11-20 16:56:52 +0100256 // Whether the last reported rate for LayerInfo::getRefreshRate()
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700257 // was due to animation or infrequent updates
Ady Abraham86ac5c52023-01-11 15:24:03 -0800258 bool animating = false;
259 // Whether the last reported rate for LayerInfo::getRefreshRate()
260 // was due to infrequent updates
261 bool infrequent = false;
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700262 };
263
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700264 // Class to store past calculated refresh rate and determine whether
265 // the refresh rate calculated is consistent with past values
266 class RefreshRateHistory {
267 public:
268 static constexpr auto HISTORY_SIZE = 90;
269 static constexpr std::chrono::nanoseconds HISTORY_DURATION = 2s;
270
271 RefreshRateHistory(const std::string& name) : mName(name) {}
272
273 // Clears History
274 void clear();
275
Jerry Chang04eb8e02023-11-15 08:06:07 +0000276 // Adds a new refresh rate and returns valid refresh rate if it is consistent enough
277 Fps add(Fps refreshRate, nsecs_t now, const RefreshRateSelector&);
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700278
279 private:
Marin Shalamanov1bc43ee2020-11-20 16:56:52 +0100280 friend class LayerHistoryTest;
Vishnu Nair47b7bb42023-09-29 16:27:33 -0700281 friend class LayerHistoryIntegrationTest;
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700282
283 // Holds the refresh rate when it was calculated
284 struct RefreshRateData {
Dominik Laskowski6eab42d2021-09-13 14:34:13 -0700285 Fps refreshRate;
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700286 nsecs_t timestamp = 0;
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700287 };
288
289 // Holds tracing strings
290 struct HeuristicTraceTagData {
291 std::string min;
292 std::string max;
293 std::string consistent;
294 std::string average;
295 };
296
Jerry Chang04eb8e02023-11-15 08:06:07 +0000297 Fps selectRefreshRate(const RefreshRateSelector&) const;
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700298 HeuristicTraceTagData makeHeuristicTraceTagData() const;
299
300 const std::string mName;
301 mutable std::optional<HeuristicTraceTagData> mHeuristicTraceTagData;
302 std::deque<RefreshRateData> mRefreshRates;
Marin Shalamanove8a663d2020-11-24 17:48:00 +0100303 static constexpr float MARGIN_CONSISTENT_FPS = 1.0;
Jerry Chang04eb8e02023-11-15 08:06:07 +0000304 static constexpr float MARGIN_CONSISTENT_FPS_FOR_CLOSEST_REFRESH_RATE = 5.0;
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700305 };
306
ramindani63db24e2023-04-03 10:56:05 -0700307 // Represents whether we were able to determine either layer is frequent or infrequent
308 bool mIsFrequencyConclusive = true;
309 struct Frequent {
310 bool isFrequent;
311 bool clearHistory;
312 // Represents whether we were able to determine isFrequent conclusively
313 bool isConclusive;
Arthur Hungc70bee22023-06-02 01:35:52 +0000314 // Represents whether the latest frames are small dirty.
315 bool isSmallDirty = false;
ramindani63db24e2023-04-03 10:56:05 -0700316 };
317 Frequent isFrequent(nsecs_t now) const;
Ady Abraham5def7332020-05-29 16:13:47 -0700318 bool isAnimating(nsecs_t now) const;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800319 bool hasEnoughDataForHeuristic() const;
Dominik Laskowskid82e0f02022-10-26 15:23:04 -0400320 std::optional<Fps> calculateRefreshRateIfPossible(const RefreshRateSelector&, nsecs_t now);
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700321 std::optional<nsecs_t> calculateAverageFrameTime() const;
Ady Abrahamdfb63ba2020-05-27 20:05:05 +0000322 bool isFrameTimeValid(const FrameTimeData&) const;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800323
Ady Abrahama6b676e2020-05-27 14:29:09 -0700324 const std::string mName;
Ady Abrahambdda8f02021-04-01 16:06:11 -0700325 const uid_t mOwnerUid;
Ady Abrahama6b676e2020-05-27 14:29:09 -0700326
Marin Shalamanov4ad8b302020-12-11 15:50:08 +0100327 // Used for sanitizing the heuristic data. If two frames are less than
328 // this period apart from each other they'll be considered as duplicates.
Dominik Laskowski6eab42d2021-09-13 14:34:13 -0700329 static constexpr nsecs_t kMinPeriodBetweenFrames = (240_Hz).getPeriodNsecs();
Marin Shalamanov2045d5b2020-12-28 18:11:41 +0100330 // Used for sanitizing the heuristic data. If two frames are more than
331 // this period apart from each other, the interval between them won't be
332 // taken into account when calculating average frame rate.
333 static constexpr nsecs_t kMaxPeriodBetweenFrames = kMinFpsForFrequentLayer.getPeriodNsecs();
Arthur Hungc70bee22023-06-02 01:35:52 +0000334 // Used for sanitizing the heuristic data. If frames are small dirty updating and are less
335 // than this period apart from each other, the interval between them won't be
336 // taken into account when calculating average frame rate.
337 static constexpr nsecs_t kMinPeriodBetweenSmallDirtyFrames = (60_Hz).getPeriodNsecs();
338
Ady Abraham8a82ba62020-01-17 12:43:17 -0800339 LayerHistory::LayerVoteType mDefaultVote;
340
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700341 LayerVote mLayerVote;
342
Ady Abraham8a82ba62020-01-17 12:43:17 -0800343 nsecs_t mLastUpdatedTime = 0;
344
Ady Abraham5def7332020-05-29 16:13:47 -0700345 nsecs_t mLastAnimationTime = 0;
346
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700347 RefreshRateHeuristicData mLastRefreshRate;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800348
Ady Abraham8a82ba62020-01-17 12:43:17 -0800349 std::deque<FrameTimeData> mFrameTimes;
Ady Abrahamdfb63ba2020-05-27 20:05:05 +0000350 std::chrono::time_point<std::chrono::steady_clock> mFrameTimeValidSince =
351 std::chrono::steady_clock::now();
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700352 static constexpr size_t HISTORY_SIZE = RefreshRateHistory::HISTORY_SIZE;
Arthur Hungc70bee22023-06-02 01:35:52 +0000353 static constexpr std::chrono::nanoseconds HISTORY_DURATION = LayerHistory::kMaxPeriodForHistory;
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700354
Vishnu Nairef68d6d2023-02-28 06:18:27 +0000355 std::unique_ptr<LayerProps> mLayerProps;
Ady Abrahambdda8f02021-04-01 16:06:11 -0700356
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700357 RefreshRateHistory mRefreshRateHistory;
358
Arthur Hung8144e022023-09-08 10:26:23 +0000359 // This will be accessed from only one thread when counting a layer is frequent or infrequent,
360 // and to determine whether a layer is in small dirty updating.
361 mutable int32_t mLastSmallDirtyCount = 0;
362
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700363 mutable std::unordered_map<LayerHistory::LayerVoteType, std::string> mTraceTags;
Ady Abrahamb1b9d412020-06-01 19:53:52 -0700364
365 // Shared for all LayerInfo instances
Ady Abraham0ccd79b2020-06-10 10:11:17 -0700366 static bool sTraceEnabled;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800367};
368
Vishnu Nairef68d6d2023-02-28 06:18:27 +0000369struct LayerProps {
370 bool visible = false;
371 FloatRect bounds;
372 ui::Transform transform;
373 LayerInfo::FrameRate setFrameRateVote;
374 int32_t frameRateSelectionPriority = -1;
Arthur Hungc70bee22023-06-02 01:35:52 +0000375 bool isSmallDirty = false;
Alec Mouri89f5d4e2023-10-20 17:12:49 +0000376 bool isFrontBuffered = false;
Vishnu Nairef68d6d2023-02-28 06:18:27 +0000377};
378
Ady Abraham8a82ba62020-01-17 12:43:17 -0800379} // namespace scheduler
380} // namespace android