Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 17 | #undef LOG_TAG |
| 18 | #define LOG_TAG "Scheduler" |
Ana Krulec | 7ab5603 | 2018-11-02 20:51:06 +0100 | [diff] [blame] | 19 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 20 | |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 21 | #include "Scheduler.h" |
| 22 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 23 | #include <android-base/properties.h> |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 24 | #include <android-base/stringprintf.h> |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 25 | #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> |
| 26 | #include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h> |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 27 | #include <configstore/Utils.h> |
Ady Abraham | 8f1ee7f | 2019-04-05 10:32:50 -0700 | [diff] [blame] | 28 | #include <input/InputWindow.h> |
Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 29 | #include <system/window.h> |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 30 | #include <ui/DisplayStatInfo.h> |
Ana Krulec | 3084c05 | 2018-11-21 20:27:17 +0100 | [diff] [blame] | 31 | #include <utils/Timers.h> |
Ana Krulec | 7ab5603 | 2018-11-02 20:51:06 +0100 | [diff] [blame] | 32 | #include <utils/Trace.h> |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 33 | |
Dominik Laskowski | f7a09ed | 2019-10-07 13:54:18 -0700 | [diff] [blame] | 34 | #include <algorithm> |
| 35 | #include <cinttypes> |
| 36 | #include <cstdint> |
| 37 | #include <functional> |
| 38 | #include <memory> |
| 39 | #include <numeric> |
| 40 | |
| 41 | #include "../Layer.h" |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 42 | #include "DispSync.h" |
| 43 | #include "DispSyncSource.h" |
| 44 | #include "EventThread.h" |
Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 45 | #include "InjectVSyncSource.h" |
Ana Krulec | f2c006d | 2019-06-21 15:37:07 -0700 | [diff] [blame] | 46 | #include "OneShotTimer.h" |
Ana Krulec | 434c22d | 2018-11-28 13:48:36 +0100 | [diff] [blame] | 47 | #include "SchedulerUtils.h" |
Sundong Ahn | d5e08f6 | 2018-12-12 20:27:28 +0900 | [diff] [blame] | 48 | #include "SurfaceFlingerProperties.h" |
Kevin DuBois | 0028738 | 2019-11-19 15:11:55 -0800 | [diff] [blame] | 49 | #include "Timer.h" |
| 50 | #include "VSyncDispatchTimerQueue.h" |
| 51 | #include "VSyncPredictor.h" |
| 52 | #include "VSyncReactor.h" |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 53 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 54 | #define RETURN_IF_INVALID_HANDLE(handle, ...) \ |
| 55 | do { \ |
| 56 | if (mConnections.count(handle) == 0) { \ |
| 57 | ALOGE("Invalid connection handle %" PRIuPTR, handle.id); \ |
| 58 | return __VA_ARGS__; \ |
| 59 | } \ |
| 60 | } while (false) |
| 61 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 62 | using namespace std::string_literals; |
| 63 | |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 64 | namespace android { |
Ady Abraham | 5a85855 | 2020-03-31 17:54:56 -0700 | [diff] [blame] | 65 | |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 66 | namespace { |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 67 | |
Ady Abraham | 5a85855 | 2020-03-31 17:54:56 -0700 | [diff] [blame] | 68 | std::unique_ptr<scheduler::VSyncTracker> createVSyncTracker() { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 69 | // TODO(b/144707443): Tune constants. |
| 70 | constexpr int kDefaultRate = 60; |
| 71 | constexpr auto initialPeriod = std::chrono::duration<nsecs_t, std::ratio<1, kDefaultRate>>(1); |
| 72 | constexpr nsecs_t idealPeriod = |
| 73 | std::chrono::duration_cast<std::chrono::nanoseconds>(initialPeriod).count(); |
| 74 | constexpr size_t vsyncTimestampHistorySize = 20; |
| 75 | constexpr size_t minimumSamplesForPrediction = 6; |
| 76 | constexpr uint32_t discardOutlierPercent = 20; |
| 77 | return std::make_unique<scheduler::VSyncPredictor>(idealPeriod, vsyncTimestampHistorySize, |
| 78 | minimumSamplesForPrediction, |
| 79 | discardOutlierPercent); |
Ady Abraham | 5a85855 | 2020-03-31 17:54:56 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 82 | std::unique_ptr<scheduler::VSyncDispatch> createVSyncDispatch(scheduler::VSyncTracker& tracker) { |
| 83 | // TODO(b/144707443): Tune constants. |
| 84 | constexpr std::chrono::nanoseconds vsyncMoveThreshold = 3ms; |
| 85 | constexpr std::chrono::nanoseconds timerSlack = 500us; |
Ady Abraham | 5a85855 | 2020-03-31 17:54:56 -0700 | [diff] [blame] | 86 | return std::make_unique< |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 87 | scheduler::VSyncDispatchTimerQueue>(std::make_unique<scheduler::Timer>(), tracker, |
Ady Abraham | 5a85855 | 2020-03-31 17:54:56 -0700 | [diff] [blame] | 88 | timerSlack.count(), vsyncMoveThreshold.count()); |
| 89 | } |
| 90 | |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 91 | const char* toContentDetectionString(bool useContentDetection, bool useContentDetectionV2) { |
| 92 | if (!useContentDetection) return "off"; |
| 93 | return useContentDetectionV2 ? "V2" : "V1"; |
| 94 | } |
| 95 | |
| 96 | } // namespace |
| 97 | |
Ady Abraham | 8735eac | 2020-08-12 16:35:04 -0700 | [diff] [blame^] | 98 | class PredictedVsyncTracer { |
| 99 | public: |
| 100 | PredictedVsyncTracer(scheduler::VSyncDispatch& dispatch) |
| 101 | : mRegistration(dispatch, std::bind(&PredictedVsyncTracer::callback, this), |
| 102 | "PredictedVsyncTracer") { |
| 103 | scheduleRegistration(); |
| 104 | } |
| 105 | |
| 106 | private: |
| 107 | TracedOrdinal<bool> mParity = {"VSYNC-predicted", 0}; |
| 108 | scheduler::VSyncCallbackRegistration mRegistration; |
| 109 | |
| 110 | void scheduleRegistration() { mRegistration.schedule({0, 0, 0}); } |
| 111 | |
| 112 | void callback() { |
| 113 | mParity = !mParity; |
| 114 | scheduleRegistration(); |
| 115 | } |
| 116 | }; |
| 117 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 118 | Scheduler::Scheduler(const scheduler::RefreshRateConfigs& configs, ISchedulerCallback& callback) |
| 119 | : Scheduler(configs, callback, |
| 120 | {.supportKernelTimer = sysprop::support_kernel_idle_timer(false), |
| 121 | .useContentDetection = sysprop::use_content_detection_for_refresh_rate(false), |
| 122 | .useContentDetectionV2 = |
Ady Abraham | 49cb7d5 | 2020-07-22 18:37:07 -0700 | [diff] [blame] | 123 | base::GetBoolProperty("debug.sf.use_content_detection_v2"s, true)}) {} |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 124 | |
| 125 | Scheduler::Scheduler(const scheduler::RefreshRateConfigs& configs, ISchedulerCallback& callback, |
| 126 | Options options) |
| 127 | : Scheduler(createVsyncSchedule(options), configs, callback, |
| 128 | createLayerHistory(configs, options.useContentDetectionV2), options) { |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 129 | using namespace sysprop; |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 130 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 131 | const int setIdleTimerMs = base::GetIntProperty("debug.sf.set_idle_timer_ms"s, 0); |
Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 132 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 133 | if (const auto millis = setIdleTimerMs ? setIdleTimerMs : set_idle_timer_ms(0); millis > 0) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 134 | const auto callback = mOptions.supportKernelTimer ? &Scheduler::kernelIdleTimerCallback |
| 135 | : &Scheduler::idleTimerCallback; |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 136 | mIdleTimer.emplace( |
| 137 | std::chrono::milliseconds(millis), |
| 138 | [this, callback] { std::invoke(callback, this, TimerState::Reset); }, |
| 139 | [this, callback] { std::invoke(callback, this, TimerState::Expired); }); |
Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 140 | mIdleTimer->start(); |
| 141 | } |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 142 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 143 | if (const int64_t millis = set_touch_timer_ms(0); millis > 0) { |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 144 | // Touch events are coming to SF every 100ms, so the timer needs to be higher than that |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 145 | mTouchTimer.emplace( |
| 146 | std::chrono::milliseconds(millis), |
Dominik Laskowski | dd252cd | 2019-07-26 09:10:16 -0700 | [diff] [blame] | 147 | [this] { touchTimerCallback(TimerState::Reset); }, |
| 148 | [this] { touchTimerCallback(TimerState::Expired); }); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 149 | mTouchTimer->start(); |
| 150 | } |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 151 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 152 | if (const int64_t millis = set_display_power_timer_ms(0); millis > 0) { |
| 153 | mDisplayPowerTimer.emplace( |
| 154 | std::chrono::milliseconds(millis), |
Dominik Laskowski | dd252cd | 2019-07-26 09:10:16 -0700 | [diff] [blame] | 155 | [this] { displayPowerTimerCallback(TimerState::Reset); }, |
| 156 | [this] { displayPowerTimerCallback(TimerState::Expired); }); |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 157 | mDisplayPowerTimer->start(); |
| 158 | } |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 161 | Scheduler::Scheduler(VsyncSchedule schedule, const scheduler::RefreshRateConfigs& configs, |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 162 | ISchedulerCallback& schedulerCallback, |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 163 | std::unique_ptr<LayerHistory> layerHistory, Options options) |
| 164 | : mOptions(options), |
| 165 | mVsyncSchedule(std::move(schedule)), |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 166 | mLayerHistory(std::move(layerHistory)), |
Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 167 | mSchedulerCallback(schedulerCallback), |
Ady Abraham | 8735eac | 2020-08-12 16:35:04 -0700 | [diff] [blame^] | 168 | mRefreshRateConfigs(configs), |
| 169 | mPredictedVsyncTracer( |
| 170 | base::GetBoolProperty("debug.sf.show_predicted_vsync", false) |
| 171 | ? std::make_unique<PredictedVsyncTracer>(*mVsyncSchedule.dispatch) |
| 172 | : nullptr) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 173 | mSchedulerCallback.setVsyncEnabled(false); |
| 174 | } |
Dominik Laskowski | 7c9dbf9 | 2019-08-01 17:57:31 -0700 | [diff] [blame] | 175 | |
Lloyd Pique | 1f9f1a4 | 2019-01-31 13:04:00 -0800 | [diff] [blame] | 176 | Scheduler::~Scheduler() { |
Ana Krulec | f2c006d | 2019-06-21 15:37:07 -0700 | [diff] [blame] | 177 | // Ensure the OneShotTimer threads are joined before we start destroying state. |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 178 | mDisplayPowerTimer.reset(); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 179 | mTouchTimer.reset(); |
Lloyd Pique | 1f9f1a4 | 2019-01-31 13:04:00 -0800 | [diff] [blame] | 180 | mIdleTimer.reset(); |
| 181 | } |
Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 182 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 183 | Scheduler::VsyncSchedule Scheduler::createVsyncSchedule(Options options) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 184 | auto clock = std::make_unique<scheduler::SystemClock>(); |
| 185 | auto tracker = createVSyncTracker(); |
| 186 | auto dispatch = createVSyncDispatch(*tracker); |
| 187 | |
| 188 | // TODO(b/144707443): Tune constants. |
| 189 | constexpr size_t pendingFenceLimit = 20; |
Ady Abraham | 8735eac | 2020-08-12 16:35:04 -0700 | [diff] [blame^] | 190 | auto sync = |
| 191 | std::make_unique<scheduler::VSyncReactor>(std::move(clock), *tracker, pendingFenceLimit, |
| 192 | options.supportKernelTimer); |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 193 | return {std::move(sync), std::move(tracker), std::move(dispatch)}; |
| 194 | } |
| 195 | |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 196 | std::unique_ptr<LayerHistory> Scheduler::createLayerHistory( |
| 197 | const scheduler::RefreshRateConfigs& configs, bool useContentDetectionV2) { |
| 198 | if (!configs.canSwitch()) return nullptr; |
| 199 | |
| 200 | if (useContentDetectionV2) { |
| 201 | return std::make_unique<scheduler::impl::LayerHistoryV2>(configs); |
| 202 | } |
| 203 | |
| 204 | return std::make_unique<scheduler::impl::LayerHistory>(); |
| 205 | } |
| 206 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 207 | DispSync& Scheduler::getPrimaryDispSync() { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 208 | return *mVsyncSchedule.sync; |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Ady Abraham | 9c53ee7 | 2020-07-22 21:16:18 -0700 | [diff] [blame] | 211 | std::unique_ptr<VSyncSource> Scheduler::makePrimaryDispSyncSource( |
| 212 | const char* name, std::chrono::nanoseconds workDuration, |
| 213 | std::chrono::nanoseconds readyDuration, bool traceVsync) { |
| 214 | return std::make_unique<scheduler::DispSyncSource>(*mVsyncSchedule.dispatch, workDuration, |
| 215 | readyDuration, traceVsync, name); |
Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 218 | Scheduler::ConnectionHandle Scheduler::createConnection( |
Ady Abraham | 9c53ee7 | 2020-07-22 21:16:18 -0700 | [diff] [blame] | 219 | const char* connectionName, std::chrono::nanoseconds workDuration, |
| 220 | std::chrono::nanoseconds readyDuration, |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 221 | impl::EventThread::InterceptVSyncsCallback interceptCallback) { |
Ady Abraham | 9c53ee7 | 2020-07-22 21:16:18 -0700 | [diff] [blame] | 222 | auto vsyncSource = makePrimaryDispSyncSource(connectionName, workDuration, readyDuration); |
Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 223 | auto eventThread = std::make_unique<impl::EventThread>(std::move(vsyncSource), |
| 224 | std::move(interceptCallback)); |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 225 | return createConnection(std::move(eventThread)); |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 226 | } |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 227 | |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 228 | Scheduler::ConnectionHandle Scheduler::createConnection(std::unique_ptr<EventThread> eventThread) { |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 229 | const ConnectionHandle handle = ConnectionHandle{mNextConnectionHandleId++}; |
| 230 | ALOGV("Creating a connection handle with ID %" PRIuPTR, handle.id); |
Dominik Laskowski | f654d57 | 2018-12-20 11:03:06 -0800 | [diff] [blame] | 231 | |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 232 | auto connection = |
| 233 | createConnectionInternal(eventThread.get(), ISurfaceComposer::eConfigChangedSuppress); |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 234 | |
| 235 | mConnections.emplace(handle, Connection{connection, std::move(eventThread)}); |
| 236 | return handle; |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 239 | sp<EventThreadConnection> Scheduler::createConnectionInternal( |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 240 | EventThread* eventThread, ISurfaceComposer::ConfigChanged configChanged) { |
| 241 | return eventThread->createEventConnection([&] { resync(); }, configChanged); |
Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 244 | sp<IDisplayEventConnection> Scheduler::createDisplayEventConnection( |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 245 | ConnectionHandle handle, ISurfaceComposer::ConfigChanged configChanged) { |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 246 | RETURN_IF_INVALID_HANDLE(handle, nullptr); |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 247 | return createConnectionInternal(mConnections[handle].thread.get(), configChanged); |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 250 | sp<EventThreadConnection> Scheduler::getEventConnection(ConnectionHandle handle) { |
| 251 | RETURN_IF_INVALID_HANDLE(handle, nullptr); |
| 252 | return mConnections[handle].connection; |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 255 | void Scheduler::onHotplugReceived(ConnectionHandle handle, PhysicalDisplayId displayId, |
| 256 | bool connected) { |
| 257 | RETURN_IF_INVALID_HANDLE(handle); |
| 258 | mConnections[handle].thread->onHotplugReceived(displayId, connected); |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 261 | void Scheduler::onScreenAcquired(ConnectionHandle handle) { |
| 262 | RETURN_IF_INVALID_HANDLE(handle); |
| 263 | mConnections[handle].thread->onScreenAcquired(); |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 266 | void Scheduler::onScreenReleased(ConnectionHandle handle) { |
| 267 | RETURN_IF_INVALID_HANDLE(handle); |
| 268 | mConnections[handle].thread->onScreenReleased(); |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 271 | void Scheduler::onPrimaryDisplayConfigChanged(ConnectionHandle handle, PhysicalDisplayId displayId, |
| 272 | HwcConfigIndexType configId, nsecs_t vsyncPeriod) { |
| 273 | std::lock_guard<std::mutex> lock(mFeatureStateLock); |
| 274 | // Cache the last reported config for primary display. |
| 275 | mFeatures.cachedConfigChangedParams = {handle, displayId, configId, vsyncPeriod}; |
| 276 | onNonPrimaryDisplayConfigChanged(handle, displayId, configId, vsyncPeriod); |
| 277 | } |
| 278 | |
| 279 | void Scheduler::dispatchCachedReportedConfig() { |
| 280 | const auto configId = *mFeatures.configId; |
| 281 | const auto vsyncPeriod = |
| 282 | mRefreshRateConfigs.getRefreshRateFromConfigId(configId).getVsyncPeriod(); |
| 283 | |
| 284 | // If there is no change from cached config, there is no need to dispatch an event |
| 285 | if (configId == mFeatures.cachedConfigChangedParams->configId && |
| 286 | vsyncPeriod == mFeatures.cachedConfigChangedParams->vsyncPeriod) { |
| 287 | return; |
| 288 | } |
| 289 | |
| 290 | mFeatures.cachedConfigChangedParams->configId = configId; |
| 291 | mFeatures.cachedConfigChangedParams->vsyncPeriod = vsyncPeriod; |
| 292 | onNonPrimaryDisplayConfigChanged(mFeatures.cachedConfigChangedParams->handle, |
| 293 | mFeatures.cachedConfigChangedParams->displayId, |
| 294 | mFeatures.cachedConfigChangedParams->configId, |
| 295 | mFeatures.cachedConfigChangedParams->vsyncPeriod); |
| 296 | } |
| 297 | |
| 298 | void Scheduler::onNonPrimaryDisplayConfigChanged(ConnectionHandle handle, |
| 299 | PhysicalDisplayId displayId, |
| 300 | HwcConfigIndexType configId, nsecs_t vsyncPeriod) { |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 301 | RETURN_IF_INVALID_HANDLE(handle); |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 302 | mConnections[handle].thread->onConfigChanged(displayId, configId, vsyncPeriod); |
Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 303 | } |
| 304 | |
Alec Mouri | 717bcb6 | 2020-02-10 17:07:19 -0800 | [diff] [blame] | 305 | size_t Scheduler::getEventThreadConnectionCount(ConnectionHandle handle) { |
| 306 | RETURN_IF_INVALID_HANDLE(handle, 0); |
| 307 | return mConnections[handle].thread->getEventThreadConnectionCount(); |
| 308 | } |
| 309 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 310 | void Scheduler::dump(ConnectionHandle handle, std::string& result) const { |
| 311 | RETURN_IF_INVALID_HANDLE(handle); |
| 312 | mConnections.at(handle).thread->dump(result); |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 313 | } |
| 314 | |
Ady Abraham | 9c53ee7 | 2020-07-22 21:16:18 -0700 | [diff] [blame] | 315 | void Scheduler::setDuration(ConnectionHandle handle, std::chrono::nanoseconds workDuration, |
| 316 | std::chrono::nanoseconds readyDuration) { |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 317 | RETURN_IF_INVALID_HANDLE(handle); |
Ady Abraham | 9c53ee7 | 2020-07-22 21:16:18 -0700 | [diff] [blame] | 318 | mConnections[handle].thread->setDuration(workDuration, readyDuration); |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 319 | } |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 320 | |
| 321 | void Scheduler::getDisplayStatInfo(DisplayStatInfo* stats) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 322 | stats->vsyncTime = getPrimaryDispSync().computeNextRefresh(0, systemTime()); |
| 323 | stats->vsyncPeriod = getPrimaryDispSync().getPeriod(); |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 326 | Scheduler::ConnectionHandle Scheduler::enableVSyncInjection(bool enable) { |
| 327 | if (mInjectVSyncs == enable) { |
| 328 | return {}; |
| 329 | } |
| 330 | |
| 331 | ALOGV("%s VSYNC injection", enable ? "Enabling" : "Disabling"); |
| 332 | |
| 333 | if (!mInjectorConnectionHandle) { |
| 334 | auto vsyncSource = std::make_unique<InjectVSyncSource>(); |
| 335 | mVSyncInjector = vsyncSource.get(); |
| 336 | |
| 337 | auto eventThread = |
| 338 | std::make_unique<impl::EventThread>(std::move(vsyncSource), |
| 339 | impl::EventThread::InterceptVSyncsCallback()); |
| 340 | |
| 341 | mInjectorConnectionHandle = createConnection(std::move(eventThread)); |
| 342 | } |
| 343 | |
| 344 | mInjectVSyncs = enable; |
| 345 | return mInjectorConnectionHandle; |
| 346 | } |
| 347 | |
Ady Abraham | 9c53ee7 | 2020-07-22 21:16:18 -0700 | [diff] [blame] | 348 | bool Scheduler::injectVSync(nsecs_t when, nsecs_t expectedVSyncTime, nsecs_t deadlineTimestamp) { |
Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 349 | if (!mInjectVSyncs || !mVSyncInjector) { |
| 350 | return false; |
| 351 | } |
| 352 | |
Ady Abraham | 9c53ee7 | 2020-07-22 21:16:18 -0700 | [diff] [blame] | 353 | mVSyncInjector->onInjectSyncEvent(when, expectedVSyncTime, deadlineTimestamp); |
Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 354 | return true; |
| 355 | } |
| 356 | |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 357 | void Scheduler::enableHardwareVsync() { |
| 358 | std::lock_guard<std::mutex> lock(mHWVsyncLock); |
| 359 | if (!mPrimaryHWVsyncEnabled && mHWVsyncAvailable) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 360 | getPrimaryDispSync().beginResync(); |
| 361 | mSchedulerCallback.setVsyncEnabled(true); |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 362 | mPrimaryHWVsyncEnabled = true; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | void Scheduler::disableHardwareVsync(bool makeUnavailable) { |
| 367 | std::lock_guard<std::mutex> lock(mHWVsyncLock); |
| 368 | if (mPrimaryHWVsyncEnabled) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 369 | mSchedulerCallback.setVsyncEnabled(false); |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 370 | mPrimaryHWVsyncEnabled = false; |
| 371 | } |
| 372 | if (makeUnavailable) { |
| 373 | mHWVsyncAvailable = false; |
| 374 | } |
| 375 | } |
| 376 | |
Ana Krulec | c287042 | 2019-01-29 19:00:58 -0800 | [diff] [blame] | 377 | void Scheduler::resyncToHardwareVsync(bool makeAvailable, nsecs_t period) { |
| 378 | { |
| 379 | std::lock_guard<std::mutex> lock(mHWVsyncLock); |
| 380 | if (makeAvailable) { |
| 381 | mHWVsyncAvailable = makeAvailable; |
| 382 | } else if (!mHWVsyncAvailable) { |
| 383 | // Hardware vsync is not currently available, so abort the resync |
| 384 | // attempt for now |
| 385 | return; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | if (period <= 0) { |
| 390 | return; |
| 391 | } |
| 392 | |
| 393 | setVsyncPeriod(period); |
| 394 | } |
| 395 | |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 396 | void Scheduler::resync() { |
Long Ling | 457bef9 | 2019-09-11 14:43:11 -0700 | [diff] [blame] | 397 | static constexpr nsecs_t kIgnoreDelay = ms2ns(750); |
Ana Krulec | c287042 | 2019-01-29 19:00:58 -0800 | [diff] [blame] | 398 | |
| 399 | const nsecs_t now = systemTime(); |
Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 400 | const nsecs_t last = mLastResyncTime.exchange(now); |
Ana Krulec | c287042 | 2019-01-29 19:00:58 -0800 | [diff] [blame] | 401 | |
| 402 | if (now - last > kIgnoreDelay) { |
Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 403 | resyncToHardwareVsync(false, mRefreshRateConfigs.getCurrentRefreshRate().getVsyncPeriod()); |
Ana Krulec | c287042 | 2019-01-29 19:00:58 -0800 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 407 | void Scheduler::setVsyncPeriod(nsecs_t period) { |
Ady Abraham | 3aff917 | 2019-02-07 19:10:26 -0800 | [diff] [blame] | 408 | std::lock_guard<std::mutex> lock(mHWVsyncLock); |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 409 | getPrimaryDispSync().setPeriod(period); |
Ady Abraham | 3aff917 | 2019-02-07 19:10:26 -0800 | [diff] [blame] | 410 | |
| 411 | if (!mPrimaryHWVsyncEnabled) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 412 | getPrimaryDispSync().beginResync(); |
| 413 | mSchedulerCallback.setVsyncEnabled(true); |
Ady Abraham | 3aff917 | 2019-02-07 19:10:26 -0800 | [diff] [blame] | 414 | mPrimaryHWVsyncEnabled = true; |
| 415 | } |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Ady Abraham | 5dee2f1 | 2020-02-05 17:49:47 -0800 | [diff] [blame] | 418 | void Scheduler::addResyncSample(nsecs_t timestamp, std::optional<nsecs_t> hwcVsyncPeriod, |
| 419 | bool* periodFlushed) { |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 420 | bool needsHwVsync = false; |
Alec Mouri | f8e689c | 2019-05-20 18:32:22 -0700 | [diff] [blame] | 421 | *periodFlushed = false; |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 422 | { // Scope for the lock |
| 423 | std::lock_guard<std::mutex> lock(mHWVsyncLock); |
| 424 | if (mPrimaryHWVsyncEnabled) { |
Ady Abraham | 5dee2f1 | 2020-02-05 17:49:47 -0800 | [diff] [blame] | 425 | needsHwVsync = |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 426 | getPrimaryDispSync().addResyncSample(timestamp, hwcVsyncPeriod, periodFlushed); |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | |
| 430 | if (needsHwVsync) { |
| 431 | enableHardwareVsync(); |
| 432 | } else { |
| 433 | disableHardwareVsync(false); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | void Scheduler::addPresentFence(const std::shared_ptr<FenceTime>& fenceTime) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 438 | if (getPrimaryDispSync().addPresentFence(fenceTime)) { |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 439 | enableHardwareVsync(); |
| 440 | } else { |
| 441 | disableHardwareVsync(false); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | void Scheduler::setIgnorePresentFences(bool ignore) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 446 | getPrimaryDispSync().setIgnorePresentFences(ignore); |
Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Ady Abraham | 0ed31c9 | 2020-04-16 11:48:45 -0700 | [diff] [blame] | 449 | nsecs_t Scheduler::getDispSyncExpectedPresentTime(nsecs_t now) { |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 450 | return getPrimaryDispSync().expectedPresentTime(now); |
Ady Abraham | c3e2131 | 2019-02-07 14:30:23 -0800 | [diff] [blame] | 451 | } |
| 452 | |
Dominik Laskowski | f7a09ed | 2019-10-07 13:54:18 -0700 | [diff] [blame] | 453 | void Scheduler::registerLayer(Layer* layer) { |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 454 | if (!mLayerHistory) return; |
| 455 | |
Steven Thomas | debafed | 2020-05-18 17:30:35 -0700 | [diff] [blame] | 456 | const auto minFps = mRefreshRateConfigs.getMinRefreshRate().getFps(); |
| 457 | const auto maxFps = mRefreshRateConfigs.getMaxRefreshRate().getFps(); |
| 458 | |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 459 | if (layer->getWindowType() == InputWindowInfo::Type::STATUS_BAR) { |
Steven Thomas | debafed | 2020-05-18 17:30:35 -0700 | [diff] [blame] | 460 | mLayerHistory->registerLayer(layer, minFps, maxFps, |
Ana Krulec | 3d367c8 | 2020-02-25 15:02:01 -0800 | [diff] [blame] | 461 | scheduler::LayerHistory::LayerVoteType::NoVote); |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 462 | } else if (!mOptions.useContentDetection) { |
Steven Thomas | debafed | 2020-05-18 17:30:35 -0700 | [diff] [blame] | 463 | // If the content detection feature is off, all layers are registered at Max. We still keep |
| 464 | // the layer history, since we use it for other features (like Frame Rate API), so layers |
| 465 | // still need to be registered. |
| 466 | mLayerHistory->registerLayer(layer, minFps, maxFps, |
| 467 | scheduler::LayerHistory::LayerVoteType::Max); |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 468 | } else if (!mOptions.useContentDetectionV2) { |
Steven Thomas | debafed | 2020-05-18 17:30:35 -0700 | [diff] [blame] | 469 | // In V1 of content detection, all layers are registered as Heuristic (unless it's |
| 470 | // wallpaper). |
| 471 | const auto highFps = |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 472 | layer->getWindowType() == InputWindowInfo::Type::WALLPAPER ? minFps : maxFps; |
Ana Krulec | 3d367c8 | 2020-02-25 15:02:01 -0800 | [diff] [blame] | 473 | |
Steven Thomas | debafed | 2020-05-18 17:30:35 -0700 | [diff] [blame] | 474 | mLayerHistory->registerLayer(layer, minFps, highFps, |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 475 | scheduler::LayerHistory::LayerVoteType::Heuristic); |
| 476 | } else { |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 477 | if (layer->getWindowType() == InputWindowInfo::Type::WALLPAPER) { |
Ana Krulec | 3d367c8 | 2020-02-25 15:02:01 -0800 | [diff] [blame] | 478 | // Running Wallpaper at Min is considered as part of content detection. |
Steven Thomas | debafed | 2020-05-18 17:30:35 -0700 | [diff] [blame] | 479 | mLayerHistory->registerLayer(layer, minFps, maxFps, |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 480 | scheduler::LayerHistory::LayerVoteType::Min); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 481 | } else { |
Steven Thomas | debafed | 2020-05-18 17:30:35 -0700 | [diff] [blame] | 482 | mLayerHistory->registerLayer(layer, minFps, maxFps, |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 483 | scheduler::LayerHistory::LayerVoteType::Heuristic); |
| 484 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 485 | } |
Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 486 | } |
| 487 | |
Ady Abraham | 5def733 | 2020-05-29 16:13:47 -0700 | [diff] [blame] | 488 | void Scheduler::recordLayerHistory(Layer* layer, nsecs_t presentTime, |
| 489 | LayerHistory::LayerUpdateType updateType) { |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 490 | if (mLayerHistory) { |
Ady Abraham | 5def733 | 2020-05-29 16:13:47 -0700 | [diff] [blame] | 491 | mLayerHistory->record(layer, presentTime, systemTime(), updateType); |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 492 | } |
Ana Krulec | 3084c05 | 2018-11-21 20:27:17 +0100 | [diff] [blame] | 493 | } |
| 494 | |
Ady Abraham | 32efd54 | 2020-05-19 17:49:26 -0700 | [diff] [blame] | 495 | void Scheduler::setConfigChangePending(bool pending) { |
| 496 | if (mLayerHistory) { |
| 497 | mLayerHistory->setConfigChangePending(pending); |
| 498 | } |
| 499 | } |
| 500 | |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 501 | void Scheduler::chooseRefreshRateForContent() { |
| 502 | if (!mLayerHistory) return; |
| 503 | |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 504 | ATRACE_CALL(); |
| 505 | |
| 506 | scheduler::LayerHistory::Summary summary = mLayerHistory->summarize(systemTime()); |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 507 | HwcConfigIndexType newConfigId; |
Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 508 | { |
| 509 | std::lock_guard<std::mutex> lock(mFeatureStateLock); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 510 | if (mFeatures.contentRequirements == summary) { |
Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 511 | return; |
| 512 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 513 | mFeatures.contentRequirements = summary; |
Ady Abraham | 4ccdcb4 | 2020-02-11 17:34:34 -0800 | [diff] [blame] | 514 | mFeatures.contentDetectionV1 = |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 515 | !summary.empty() ? ContentDetectionState::On : ContentDetectionState::Off; |
| 516 | |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 517 | scheduler::RefreshRateConfigs::GlobalSignals consideredSignals; |
| 518 | newConfigId = calculateRefreshRateConfigIndexType(&consideredSignals); |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 519 | if (mFeatures.configId == newConfigId) { |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 520 | // We don't need to change the config, but we might need to send an event |
| 521 | // about a config change, since it was suppressed due to a previous idleConsidered |
| 522 | if (!consideredSignals.idle) { |
| 523 | dispatchCachedReportedConfig(); |
| 524 | } |
Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 525 | return; |
| 526 | } |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 527 | mFeatures.configId = newConfigId; |
Ady Abraham | 2e1dd89 | 2020-03-05 13:48:36 -0800 | [diff] [blame] | 528 | auto& newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 529 | mSchedulerCallback.changeRefreshRate(newRefreshRate, |
| 530 | consideredSignals.idle ? ConfigEvent::None |
| 531 | : ConfigEvent::Changed); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 532 | } |
Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 533 | } |
| 534 | |
Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 535 | void Scheduler::resetIdleTimer() { |
| 536 | if (mIdleTimer) { |
| 537 | mIdleTimer->reset(); |
Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 538 | } |
| 539 | } |
| 540 | |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 541 | void Scheduler::notifyTouchEvent() { |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 542 | if (mTouchTimer) { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 543 | mTouchTimer->reset(); |
Steven Thomas | 540730a | 2020-01-08 20:12:42 -0800 | [diff] [blame] | 544 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 545 | if (mOptions.supportKernelTimer && mIdleTimer) { |
Steven Thomas | 540730a | 2020-01-08 20:12:42 -0800 | [diff] [blame] | 546 | mIdleTimer->reset(); |
| 547 | } |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 548 | } |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 549 | } |
| 550 | |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 551 | void Scheduler::setDisplayPowerState(bool normal) { |
| 552 | { |
| 553 | std::lock_guard<std::mutex> lock(mFeatureStateLock); |
Dominik Laskowski | dd252cd | 2019-07-26 09:10:16 -0700 | [diff] [blame] | 554 | mFeatures.isDisplayPowerStateNormal = normal; |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | if (mDisplayPowerTimer) { |
| 558 | mDisplayPowerTimer->reset(); |
| 559 | } |
| 560 | |
| 561 | // Display Power event will boost the refresh rate to performance. |
| 562 | // Clear Layer History to get fresh FPS detection |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 563 | if (mLayerHistory) { |
| 564 | mLayerHistory->clear(); |
| 565 | } |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 566 | } |
| 567 | |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 568 | void Scheduler::kernelIdleTimerCallback(TimerState state) { |
| 569 | ATRACE_INT("ExpiredKernelIdleTimer", static_cast<int>(state)); |
Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 570 | |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 571 | // TODO(145561154): cleanup the kernel idle timer implementation and the refresh rate |
| 572 | // magic number |
Ady Abraham | 2e1dd89 | 2020-03-05 13:48:36 -0800 | [diff] [blame] | 573 | const auto& refreshRate = mRefreshRateConfigs.getCurrentRefreshRate(); |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 574 | constexpr float FPS_THRESHOLD_FOR_KERNEL_TIMER = 65.0f; |
Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 575 | if (state == TimerState::Reset && refreshRate.getFps() > FPS_THRESHOLD_FOR_KERNEL_TIMER) { |
Alec Mouri | 7f01518 | 2019-07-11 13:56:22 -0700 | [diff] [blame] | 576 | // If we're not in performance mode then the kernel timer shouldn't do |
| 577 | // anything, as the refresh rate during DPU power collapse will be the |
| 578 | // same. |
Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 579 | resyncToHardwareVsync(true /* makeAvailable */, refreshRate.getVsyncPeriod()); |
| 580 | } else if (state == TimerState::Expired && |
| 581 | refreshRate.getFps() <= FPS_THRESHOLD_FOR_KERNEL_TIMER) { |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 582 | // Disable HW VSYNC if the timer expired, as we don't need it enabled if |
| 583 | // we're not pushing frames, and if we're in PERFORMANCE mode then we'll |
| 584 | // need to update the DispSync model anyway. |
| 585 | disableHardwareVsync(false /* makeUnavailable */); |
Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 586 | } |
Ady Abraham | a09852a | 2020-02-20 14:23:42 -0800 | [diff] [blame] | 587 | |
| 588 | mSchedulerCallback.kernelTimerChanged(state == TimerState::Expired); |
Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 591 | void Scheduler::idleTimerCallback(TimerState state) { |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 592 | handleTimerStateChanged(&mFeatures.idleTimer, state); |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 593 | ATRACE_INT("ExpiredIdleTimer", static_cast<int>(state)); |
Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 594 | } |
| 595 | |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 596 | void Scheduler::touchTimerCallback(TimerState state) { |
Dominik Laskowski | dd252cd | 2019-07-26 09:10:16 -0700 | [diff] [blame] | 597 | const TouchState touch = state == TimerState::Reset ? TouchState::Active : TouchState::Inactive; |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 598 | // Touch event will boost the refresh rate to performance. |
| 599 | // Clear layer history to get fresh FPS detection. |
| 600 | // NOTE: Instead of checking all the layers, we should be checking the layer |
| 601 | // that is currently on top. b/142507166 will give us this capability. |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 602 | if (handleTimerStateChanged(&mFeatures.touch, touch)) { |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 603 | if (mLayerHistory) { |
| 604 | mLayerHistory->clear(); |
| 605 | } |
Ady Abraham | 1adbb72 | 2020-05-15 11:51:48 -0700 | [diff] [blame] | 606 | } |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 607 | ATRACE_INT("TouchState", static_cast<int>(touch)); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 608 | } |
| 609 | |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 610 | void Scheduler::displayPowerTimerCallback(TimerState state) { |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 611 | handleTimerStateChanged(&mFeatures.displayPowerTimer, state); |
Dominik Laskowski | 3a80a38 | 2019-07-25 11:16:07 -0700 | [diff] [blame] | 612 | ATRACE_INT("ExpiredDisplayPowerTimer", static_cast<int>(state)); |
Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 615 | void Scheduler::dump(std::string& result) const { |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 616 | using base::StringAppendF; |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 617 | |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 618 | StringAppendF(&result, "+ Idle timer: %s\n", mIdleTimer ? mIdleTimer->dump().c_str() : "off"); |
Ana Krulec | 3d367c8 | 2020-02-25 15:02:01 -0800 | [diff] [blame] | 619 | StringAppendF(&result, "+ Touch timer: %s\n", |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 620 | mTouchTimer ? mTouchTimer->dump().c_str() : "off"); |
| 621 | StringAppendF(&result, "+ Content detection: %s %s\n\n", |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 622 | toContentDetectionString(mOptions.useContentDetection, |
| 623 | mOptions.useContentDetectionV2), |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 624 | mLayerHistory ? mLayerHistory->dump().c_str() : "(no layer history)"); |
Ana Krulec | b43429d | 2019-01-09 14:28:51 -0800 | [diff] [blame] | 625 | } |
| 626 | |
Ady Abraham | 8735eac | 2020-08-12 16:35:04 -0700 | [diff] [blame^] | 627 | void Scheduler::dumpVSync(std::string& s) const { |
| 628 | using base::StringAppendF; |
| 629 | |
| 630 | StringAppendF(&s, "VSyncReactor:\n"); |
| 631 | mVsyncSchedule.sync->dump(s); |
| 632 | StringAppendF(&s, "VSyncDispatch:\n"); |
| 633 | mVsyncSchedule.dispatch->dump(s); |
| 634 | } |
| 635 | |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 636 | template <class T> |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 637 | bool Scheduler::handleTimerStateChanged(T* currentState, T newState) { |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 638 | HwcConfigIndexType newConfigId; |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 639 | scheduler::RefreshRateConfigs::GlobalSignals consideredSignals; |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 640 | { |
| 641 | std::lock_guard<std::mutex> lock(mFeatureStateLock); |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 642 | if (*currentState == newState) { |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 643 | return false; |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 644 | } |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 645 | *currentState = newState; |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 646 | newConfigId = calculateRefreshRateConfigIndexType(&consideredSignals); |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 647 | if (mFeatures.configId == newConfigId) { |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 648 | // We don't need to change the config, but we might need to send an event |
| 649 | // about a config change, since it was suppressed due to a previous idleConsidered |
| 650 | if (!consideredSignals.idle) { |
| 651 | dispatchCachedReportedConfig(); |
| 652 | } |
| 653 | return consideredSignals.touch; |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 654 | } |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 655 | mFeatures.configId = newConfigId; |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 656 | } |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 657 | const RefreshRate& newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 658 | mSchedulerCallback.changeRefreshRate(newRefreshRate, |
| 659 | consideredSignals.idle ? ConfigEvent::None |
| 660 | : ConfigEvent::Changed); |
| 661 | return consideredSignals.touch; |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 662 | } |
| 663 | |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 664 | HwcConfigIndexType Scheduler::calculateRefreshRateConfigIndexType( |
| 665 | scheduler::RefreshRateConfigs::GlobalSignals* consideredSignals) { |
Ady Abraham | 4ccdcb4 | 2020-02-11 17:34:34 -0800 | [diff] [blame] | 666 | ATRACE_CALL(); |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 667 | if (consideredSignals) *consideredSignals = {}; |
Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 668 | |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 669 | // If Display Power is not in normal operation we want to be in performance mode. When coming |
| 670 | // back to normal mode, a grace period is given with DisplayPowerTimer. |
Ana Krulec | 3f6a206 | 2020-01-23 15:48:01 -0800 | [diff] [blame] | 671 | if (mDisplayPowerTimer && |
| 672 | (!mFeatures.isDisplayPowerStateNormal || |
| 673 | mFeatures.displayPowerTimer == TimerState::Reset)) { |
Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 674 | return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); |
Ana Krulec | 3f6a206 | 2020-01-23 15:48:01 -0800 | [diff] [blame] | 675 | } |
Ady Abraham | 6fe2c17 | 2019-07-12 12:37:57 -0700 | [diff] [blame] | 676 | |
Steven Thomas | bb37432 | 2020-04-28 22:47:16 -0700 | [diff] [blame] | 677 | const bool touchActive = mTouchTimer && mFeatures.touch == TouchState::Active; |
| 678 | const bool idle = mIdleTimer && mFeatures.idleTimer == TimerState::Expired; |
| 679 | |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 680 | if (!mOptions.useContentDetectionV2) { |
Ady Abraham | 4ccdcb4 | 2020-02-11 17:34:34 -0800 | [diff] [blame] | 681 | // As long as touch is active we want to be in performance mode. |
Steven Thomas | bb37432 | 2020-04-28 22:47:16 -0700 | [diff] [blame] | 682 | if (touchActive) { |
Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 683 | return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); |
Ady Abraham | 4ccdcb4 | 2020-02-11 17:34:34 -0800 | [diff] [blame] | 684 | } |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 685 | |
Steven Thomas | bb37432 | 2020-04-28 22:47:16 -0700 | [diff] [blame] | 686 | // If timer has expired as it means there is no new content on the screen. |
| 687 | if (idle) { |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 688 | if (consideredSignals) consideredSignals->idle = true; |
Steven Thomas | bb37432 | 2020-04-28 22:47:16 -0700 | [diff] [blame] | 689 | return mRefreshRateConfigs.getMinRefreshRateByPolicy().getConfigId(); |
| 690 | } |
Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 691 | |
Ana Krulec | 3f6a206 | 2020-01-23 15:48:01 -0800 | [diff] [blame] | 692 | // If content detection is off we choose performance as we don't know the content fps. |
Ady Abraham | 4ccdcb4 | 2020-02-11 17:34:34 -0800 | [diff] [blame] | 693 | if (mFeatures.contentDetectionV1 == ContentDetectionState::Off) { |
Ana Krulec | 3803b8d | 2020-02-03 16:35:46 -0800 | [diff] [blame] | 694 | // NOTE: V1 always calls this, but this is not a default behavior for V2. |
Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 695 | return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); |
Steven Thomas | 540730a | 2020-01-08 20:12:42 -0800 | [diff] [blame] | 696 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 697 | |
| 698 | // Content detection is on, find the appropriate refresh rate with minimal error |
Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 699 | return mRefreshRateConfigs.getRefreshRateForContent(mFeatures.contentRequirements) |
| 700 | .getConfigId(); |
Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 701 | } |
| 702 | |
Ady Abraham | 1adbb72 | 2020-05-15 11:51:48 -0700 | [diff] [blame] | 703 | return mRefreshRateConfigs |
Ady Abraham | dfd6216 | 2020-06-10 16:11:56 -0700 | [diff] [blame] | 704 | .getBestRefreshRate(mFeatures.contentRequirements, {.touch = touchActive, .idle = idle}, |
| 705 | consideredSignals) |
Ady Abraham | 1adbb72 | 2020-05-15 11:51:48 -0700 | [diff] [blame] | 706 | .getConfigId(); |
Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 707 | } |
| 708 | |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 709 | std::optional<HwcConfigIndexType> Scheduler::getPreferredConfigId() { |
Daniel Solomon | 0f0ddc1 | 2019-08-19 19:31:09 -0700 | [diff] [blame] | 710 | std::lock_guard<std::mutex> lock(mFeatureStateLock); |
Ana Krulec | 3f6a206 | 2020-01-23 15:48:01 -0800 | [diff] [blame] | 711 | // Make sure that the default config ID is first updated, before returned. |
| 712 | if (mFeatures.configId.has_value()) { |
Ana Krulec | 3803b8d | 2020-02-03 16:35:46 -0800 | [diff] [blame] | 713 | mFeatures.configId = calculateRefreshRateConfigIndexType(); |
Ana Krulec | 3f6a206 | 2020-01-23 15:48:01 -0800 | [diff] [blame] | 714 | } |
Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 715 | return mFeatures.configId; |
Daniel Solomon | 0f0ddc1 | 2019-08-19 19:31:09 -0700 | [diff] [blame] | 716 | } |
| 717 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 718 | void Scheduler::onNewVsyncPeriodChangeTimeline(const hal::VsyncPeriodChangeTimeline& timeline) { |
Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 719 | if (timeline.refreshRequired) { |
| 720 | mSchedulerCallback.repaintEverythingForHWC(); |
| 721 | } |
| 722 | |
| 723 | std::lock_guard<std::mutex> lock(mVsyncTimelineLock); |
| 724 | mLastVsyncPeriodChangeTimeline = std::make_optional(timeline); |
| 725 | |
| 726 | const auto maxAppliedTime = systemTime() + MAX_VSYNC_APPLIED_TIME.count(); |
| 727 | if (timeline.newVsyncAppliedTimeNanos > maxAppliedTime) { |
| 728 | mLastVsyncPeriodChangeTimeline->newVsyncAppliedTimeNanos = maxAppliedTime; |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | void Scheduler::onDisplayRefreshed(nsecs_t timestamp) { |
| 733 | bool callRepaint = false; |
| 734 | { |
| 735 | std::lock_guard<std::mutex> lock(mVsyncTimelineLock); |
| 736 | if (mLastVsyncPeriodChangeTimeline && mLastVsyncPeriodChangeTimeline->refreshRequired) { |
| 737 | if (mLastVsyncPeriodChangeTimeline->refreshTimeNanos < timestamp) { |
| 738 | mLastVsyncPeriodChangeTimeline->refreshRequired = false; |
| 739 | } else { |
| 740 | // We need to send another refresh as refreshTimeNanos is still in the future |
| 741 | callRepaint = true; |
| 742 | } |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | if (callRepaint) { |
| 747 | mSchedulerCallback.repaintEverythingForHWC(); |
Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 748 | } |
| 749 | } |
| 750 | |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 751 | void Scheduler::onPrimaryDisplayAreaChanged(uint32_t displayArea) { |
| 752 | if (mLayerHistory) { |
| 753 | mLayerHistory->setDisplayArea(displayArea); |
| 754 | } |
| 755 | } |
| 756 | |
Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 757 | } // namespace android |