blob: f79688dfe0a39f0c78bca88bda4584f1c9280453 [file] [log] [blame]
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001/*
2 * Copyright (C) 2011 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
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080017// TODO(b/129481165): remove the #pragma below and fix conversion issues
18#pragma clang diagnostic push
19#pragma clang diagnostic ignored "-Wconversion"
20
Mathias Agopian841cde52012-03-01 15:44:37 -080021#define ATRACE_TAG ATRACE_TAG_GRAPHICS
22
Lloyd Pique46a46b32018-01-31 19:01:18 -080023#include <pthread.h>
24#include <sched.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080025#include <sys/types.h>
Dominik Laskowskid9e4de62019-01-21 14:23:01 -080026
Lloyd Pique46a46b32018-01-31 19:01:18 -080027#include <chrono>
28#include <cstdint>
Dominik Laskowskid9e4de62019-01-21 14:23:01 -080029#include <optional>
30#include <type_traits>
Ady Abraham011f8ba2022-11-22 15:09:07 -080031#include <utility>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080032
Yiwei Zhang5434a782018-12-05 18:06:32 -080033#include <android-base/stringprintf.h>
34
Ady Abraham0bb6a472020-10-12 10:22:13 -070035#include <binder/IPCThreadState.h>
36
Mathias Agopiana4cb35a2012-08-20 20:07:34 -070037#include <cutils/compiler.h>
Lloyd Pique46a46b32018-01-31 19:01:18 -080038#include <cutils/sched_policy.h>
Mathias Agopiana4cb35a2012-08-20 20:07:34 -070039
Mathias Agopiand0566bc2011-11-17 17:49:17 -080040#include <gui/DisplayEventReceiver.h>
41
42#include <utils/Errors.h>
Mathias Agopian841cde52012-03-01 15:44:37 -080043#include <utils/Trace.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080044
Rachel Lee0655a912023-04-20 19:54:18 -070045#include <scheduler/VsyncConfig.h>
Marin Shalamanov23c44202020-12-22 19:09:20 +010046#include "DisplayHardware/DisplayMode.h"
Adithya Srinivasan5f683cf2020-09-15 14:21:04 -070047#include "FrameTimeline.h"
Ady Abraham011f8ba2022-11-22 15:09:07 -080048#include "VSyncDispatch.h"
49#include "VSyncTracker.h"
Marin Shalamanov23c44202020-12-22 19:09:20 +010050
51#include "EventThread.h"
Mathias Agopiand0566bc2011-11-17 17:49:17 -080052
Ady Abraham62f216c2020-10-13 19:07:23 -070053#undef LOG_TAG
54#define LOG_TAG "EventThread"
55
Lloyd Pique46a46b32018-01-31 19:01:18 -080056using namespace std::chrono_literals;
Mathias Agopiand0566bc2011-11-17 17:49:17 -080057
Lloyd Pique46a46b32018-01-31 19:01:18 -080058namespace android {
59
Dominik Laskowskid9e4de62019-01-21 14:23:01 -080060using base::StringAppendF;
61using base::StringPrintf;
62
63namespace {
64
65auto vsyncPeriod(VSyncRequest request) {
66 return static_cast<std::underlying_type_t<VSyncRequest>>(request);
67}
68
69std::string toString(VSyncRequest request) {
70 switch (request) {
71 case VSyncRequest::None:
72 return "VSyncRequest::None";
73 case VSyncRequest::Single:
74 return "VSyncRequest::Single";
Tim Murrayb5daa912020-09-09 21:29:13 +000075 case VSyncRequest::SingleSuppressCallback:
76 return "VSyncRequest::SingleSuppressCallback";
Dominik Laskowskid9e4de62019-01-21 14:23:01 -080077 default:
78 return StringPrintf("VSyncRequest::Periodic{period=%d}", vsyncPeriod(request));
79 }
80}
81
82std::string toString(const EventThreadConnection& connection) {
83 return StringPrintf("Connection{%p, %s}", &connection,
84 toString(connection.vsyncRequest).c_str());
85}
86
87std::string toString(const DisplayEventReceiver::Event& event) {
88 switch (event.header.type) {
89 case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG:
Marin Shalamanova524a092020-07-27 21:39:55 +020090 return StringPrintf("Hotplug{displayId=%s, %s}",
91 to_string(event.header.displayId).c_str(),
Dominik Laskowskid9e4de62019-01-21 14:23:01 -080092 event.hotplug.connected ? "connected" : "disconnected");
93 case DisplayEventReceiver::DISPLAY_EVENT_VSYNC:
Rachel Leeb9c5a772022-02-04 21:17:37 -080094 return StringPrintf("VSync{displayId=%s, count=%u, expectedPresentationTime=%" PRId64
95 "}",
Marin Shalamanova524a092020-07-27 21:39:55 +020096 to_string(event.header.displayId).c_str(), event.vsync.count,
Rachel Leeb9c5a772022-02-04 21:17:37 -080097 event.vsync.vsyncData.preferredExpectedPresentationTime());
Marin Shalamanova7fe3042021-01-29 21:02:08 +010098 case DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE:
99 return StringPrintf("ModeChanged{displayId=%s, modeId=%u}",
100 to_string(event.header.displayId).c_str(), event.modeChange.modeId);
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800101 default:
102 return "Event{}";
103 }
104}
105
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800106DisplayEventReceiver::Event makeHotplug(PhysicalDisplayId displayId, nsecs_t timestamp,
107 bool connected) {
Dominik Laskowski23b867a2019-01-22 12:44:53 -0800108 DisplayEventReceiver::Event event;
109 event.header = {DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG, displayId, timestamp};
110 event.hotplug.connected = connected;
111 return event;
112}
113
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800114DisplayEventReceiver::Event makeVSync(PhysicalDisplayId displayId, nsecs_t timestamp,
Rachel Leeb9c5a772022-02-04 21:17:37 -0800115 uint32_t count, nsecs_t expectedPresentationTime,
Rachel Lee0d943202022-02-01 23:29:41 -0800116 nsecs_t deadlineTimestamp) {
Dominik Laskowski23b867a2019-01-22 12:44:53 -0800117 DisplayEventReceiver::Event event;
118 event.header = {DisplayEventReceiver::DISPLAY_EVENT_VSYNC, displayId, timestamp};
119 event.vsync.count = count;
Rachel Leeb9c5a772022-02-04 21:17:37 -0800120 event.vsync.vsyncData.preferredFrameTimelineIndex = 0;
121 // Temporarily store the current vsync information in frameTimelines[0], marked as
122 // platform-preferred. When the event is dispatched later, the frame interval at that time is
123 // used with this information to generate multiple frame timeline choices.
124 event.vsync.vsyncData.frameTimelines[0] = {.vsyncId = FrameTimelineInfo::INVALID_VSYNC_ID,
125 .deadlineTimestamp = deadlineTimestamp,
126 .expectedPresentationTime =
127 expectedPresentationTime};
Dominik Laskowski23b867a2019-01-22 12:44:53 -0800128 return event;
129}
130
Ady Abraham67434eb2022-12-01 17:48:12 -0800131DisplayEventReceiver::Event makeModeChanged(const scheduler::FrameRateMode& mode) {
Ady Abraham447052e2019-02-13 16:07:27 -0800132 DisplayEventReceiver::Event event;
Ady Abraham67434eb2022-12-01 17:48:12 -0800133 event.header = {DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE,
134 mode.modePtr->getPhysicalDisplayId(), systemTime()};
135 event.modeChange.modeId = mode.modePtr->getId().value();
136 event.modeChange.vsyncPeriod = mode.fps.getPeriodNsecs();
Ady Abraham447052e2019-02-13 16:07:27 -0800137 return event;
138}
139
Ady Abraham62f216c2020-10-13 19:07:23 -0700140DisplayEventReceiver::Event makeFrameRateOverrideEvent(PhysicalDisplayId displayId,
141 FrameRateOverride frameRateOverride) {
142 return DisplayEventReceiver::Event{
143 .header =
144 DisplayEventReceiver::Event::Header{
145 .type = DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE,
146 .displayId = displayId,
147 .timestamp = systemTime(),
148 },
149 .frameRateOverride = frameRateOverride,
150 };
151}
152
153DisplayEventReceiver::Event makeFrameRateOverrideFlushEvent(PhysicalDisplayId displayId) {
154 return DisplayEventReceiver::Event{
155 .header = DisplayEventReceiver::Event::Header{
156 .type = DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE_FLUSH,
157 .displayId = displayId,
158 .timestamp = systemTime(),
159 }};
160}
161
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800162} // namespace
Lloyd Pique46a46b32018-01-31 19:01:18 -0800163
Huihong Luo1b0c49f2022-03-15 19:18:21 -0700164EventThreadConnection::EventThreadConnection(EventThread* eventThread, uid_t callingUid,
165 ResyncCallback resyncCallback,
166 EventRegistrationFlags eventRegistration)
Dominik Laskowskif654d572018-12-20 11:03:06 -0800167 : resyncCallback(std::move(resyncCallback)),
Ady Abraham0bb6a472020-10-12 10:22:13 -0700168 mOwnerUid(callingUid),
Ady Abraham62f216c2020-10-13 19:07:23 -0700169 mEventRegistration(eventRegistration),
Dominik Laskowskif654d572018-12-20 11:03:06 -0800170 mEventThread(eventThread),
171 mChannel(gui::BitTube::DefaultSize) {}
Ana Krulec85c39af2018-12-26 17:29:57 -0800172
173EventThreadConnection::~EventThreadConnection() {
174 // do nothing here -- clean-up will happen automatically
175 // when the main thread wakes up
176}
177
178void EventThreadConnection::onFirstRef() {
179 // NOTE: mEventThread doesn't hold a strong reference on us
Ady Abrahamd11bade2022-08-01 16:18:03 -0700180 mEventThread->registerDisplayEventConnection(sp<EventThreadConnection>::fromExisting(this));
Ana Krulec85c39af2018-12-26 17:29:57 -0800181}
182
Huihong Luo6fac5232021-11-22 16:05:23 -0800183binder::Status EventThreadConnection::stealReceiveChannel(gui::BitTube* outChannel) {
Ady Abraham899e8cd2022-06-06 15:16:06 -0700184 std::scoped_lock lock(mLock);
185 if (mChannel.initCheck() != NO_ERROR) {
186 return binder::Status::fromStatusT(NAME_NOT_FOUND);
187 }
188
Ana Krulec85c39af2018-12-26 17:29:57 -0800189 outChannel->setReceiveFd(mChannel.moveReceiveFd());
Alec Mouri967d5d72020-08-05 12:50:03 -0700190 outChannel->setSendFd(base::unique_fd(dup(mChannel.getSendFd())));
Huihong Luo6fac5232021-11-22 16:05:23 -0800191 return binder::Status::ok();
Ana Krulec85c39af2018-12-26 17:29:57 -0800192}
193
Huihong Luo6fac5232021-11-22 16:05:23 -0800194binder::Status EventThreadConnection::setVsyncRate(int rate) {
Ady Abrahamd11bade2022-08-01 16:18:03 -0700195 mEventThread->setVsyncRate(static_cast<uint32_t>(rate),
196 sp<EventThreadConnection>::fromExisting(this));
Huihong Luo6fac5232021-11-22 16:05:23 -0800197 return binder::Status::ok();
Ana Krulec85c39af2018-12-26 17:29:57 -0800198}
199
Huihong Luo6fac5232021-11-22 16:05:23 -0800200binder::Status EventThreadConnection::requestNextVsync() {
Rachel Leeef2e21f2022-02-01 14:51:34 -0800201 ATRACE_CALL();
Ady Abrahamd11bade2022-08-01 16:18:03 -0700202 mEventThread->requestNextVsync(sp<EventThreadConnection>::fromExisting(this));
Huihong Luo6fac5232021-11-22 16:05:23 -0800203 return binder::Status::ok();
Ana Krulec85c39af2018-12-26 17:29:57 -0800204}
205
Rachel Leeb9c5a772022-02-04 21:17:37 -0800206binder::Status EventThreadConnection::getLatestVsyncEventData(
207 ParcelableVsyncEventData* outVsyncEventData) {
Rachel Leeef2e21f2022-02-01 14:51:34 -0800208 ATRACE_CALL();
Ady Abrahamd11bade2022-08-01 16:18:03 -0700209 outVsyncEventData->vsync =
210 mEventThread->getLatestVsyncEventData(sp<EventThreadConnection>::fromExisting(this));
Rachel Leeef2e21f2022-02-01 14:51:34 -0800211 return binder::Status::ok();
212}
213
Ana Krulec85c39af2018-12-26 17:29:57 -0800214status_t EventThreadConnection::postEvent(const DisplayEventReceiver::Event& event) {
Ady Abraham62f216c2020-10-13 19:07:23 -0700215 constexpr auto toStatus = [](ssize_t size) {
216 return size < 0 ? status_t(size) : status_t(NO_ERROR);
217 };
218
219 if (event.header.type == DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE ||
220 event.header.type == DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE_FLUSH) {
221 mPendingEvents.emplace_back(event);
222 if (event.header.type == DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE) {
223 return status_t(NO_ERROR);
224 }
225
226 auto size = DisplayEventReceiver::sendEvents(&mChannel, mPendingEvents.data(),
227 mPendingEvents.size());
228 mPendingEvents.clear();
229 return toStatus(size);
230 }
231
232 auto size = DisplayEventReceiver::sendEvents(&mChannel, &event, 1);
233 return toStatus(size);
Ana Krulec85c39af2018-12-26 17:29:57 -0800234}
235
236// ---------------------------------------------------------------------------
237
Lloyd Pique0fcde1b2017-12-20 16:50:21 -0800238EventThread::~EventThread() = default;
239
240namespace impl {
241
Leon Scroggins III67388622023-02-06 20:36:20 -0500242EventThread::EventThread(const char* name, std::shared_ptr<scheduler::VsyncSchedule> vsyncSchedule,
Adithya Srinivasan5f683cf2020-09-15 14:21:04 -0700243 android::frametimeline::TokenManager* tokenManager,
Leon Scroggins IIIdb16a2b2023-02-06 17:50:05 -0500244 ThrottleVsyncCallback throttleVsyncCallback,
245 GetVsyncPeriodFunction getVsyncPeriodFunction,
Ady Abraham011f8ba2022-11-22 15:09:07 -0800246 std::chrono::nanoseconds workDuration,
247 std::chrono::nanoseconds readyDuration)
248 : mThreadName(name),
249 mVsyncTracer(base::StringPrintf("VSYNC-%s", name), 0),
250 mWorkDuration(base::StringPrintf("VsyncWorkDuration-%s", name), workDuration),
251 mReadyDuration(readyDuration),
Leon Scroggins III67388622023-02-06 20:36:20 -0500252 mVsyncSchedule(std::move(vsyncSchedule)),
253 mVsyncRegistration(mVsyncSchedule->getDispatch(), createDispatchCallback(), name),
Adithya Srinivasan5f683cf2020-09-15 14:21:04 -0700254 mTokenManager(tokenManager),
Leon Scroggins IIIdb16a2b2023-02-06 17:50:05 -0500255 mThrottleVsyncCallback(std::move(throttleVsyncCallback)),
256 mGetVsyncPeriodFunction(std::move(getVsyncPeriodFunction)) {
257 LOG_ALWAYS_FATAL_IF(getVsyncPeriodFunction == nullptr,
258 "getVsyncPeriodFunction must not be null");
259
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800260 mThread = std::thread([this]() NO_THREAD_SAFETY_ANALYSIS {
261 std::unique_lock<std::mutex> lock(mMutex);
262 threadMain(lock);
263 });
Lloyd Pique46a46b32018-01-31 19:01:18 -0800264
Dominik Laskowski6505f792019-09-18 11:10:05 -0700265 pthread_setname_np(mThread.native_handle(), mThreadName);
Lloyd Pique46a46b32018-01-31 19:01:18 -0800266
267 pid_t tid = pthread_gettid_np(mThread.native_handle());
268
269 // Use SCHED_FIFO to minimize jitter
270 constexpr int EVENT_THREAD_PRIORITY = 2;
271 struct sched_param param = {0};
272 param.sched_priority = EVENT_THREAD_PRIORITY;
273 if (pthread_setschedparam(mThread.native_handle(), SCHED_FIFO, &param) != 0) {
274 ALOGE("Couldn't set SCHED_FIFO for EventThread");
275 }
276
277 set_sched_policy(tid, SP_FOREGROUND);
278}
279
280EventThread::~EventThread() {
281 {
282 std::lock_guard<std::mutex> lock(mMutex);
Dominik Laskowski029cc122019-01-23 19:52:06 -0800283 mState = State::Quit;
Lloyd Pique46a46b32018-01-31 19:01:18 -0800284 mCondition.notify_all();
285 }
286 mThread.join();
Ruchi Kandoief472ec2014-04-02 12:50:06 -0700287}
288
Ady Abraham9c53ee72020-07-22 21:16:18 -0700289void EventThread::setDuration(std::chrono::nanoseconds workDuration,
290 std::chrono::nanoseconds readyDuration) {
Lloyd Pique46a46b32018-01-31 19:01:18 -0800291 std::lock_guard<std::mutex> lock(mMutex);
Ady Abraham011f8ba2022-11-22 15:09:07 -0800292 mWorkDuration = workDuration;
293 mReadyDuration = readyDuration;
294
295 mVsyncRegistration.update({.workDuration = mWorkDuration.get().count(),
296 .readyDuration = mReadyDuration.count(),
297 .earliestVsync = mLastVsyncCallbackTime.ns()});
Dan Stozadb4ac3c2015-04-14 11:34:01 -0700298}
299
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700300sp<EventThreadConnection> EventThread::createEventConnection(
Huihong Luo1b0c49f2022-03-15 19:18:21 -0700301 ResyncCallback resyncCallback, EventRegistrationFlags eventRegistration) const {
Ady Abrahamd11bade2022-08-01 16:18:03 -0700302 return sp<EventThreadConnection>::make(const_cast<EventThread*>(this),
303 IPCThreadState::self()->getCallingUid(),
304 std::move(resyncCallback), eventRegistration);
Mathias Agopian8aedd472012-01-24 16:39:14 -0800305}
306
Ana Krulec85c39af2018-12-26 17:29:57 -0800307status_t EventThread::registerDisplayEventConnection(const sp<EventThreadConnection>& connection) {
Lloyd Pique46a46b32018-01-31 19:01:18 -0800308 std::lock_guard<std::mutex> lock(mMutex);
Chia-I Wu98cd38f2018-09-14 11:53:25 -0700309
310 // this should never happen
311 auto it = std::find(mDisplayEventConnections.cbegin(),
312 mDisplayEventConnections.cend(), connection);
313 if (it != mDisplayEventConnections.cend()) {
314 ALOGW("DisplayEventConnection %p already exists", connection.get());
315 mCondition.notify_all();
316 return ALREADY_EXISTS;
317 }
318
319 mDisplayEventConnections.push_back(connection);
Lloyd Pique46a46b32018-01-31 19:01:18 -0800320 mCondition.notify_all();
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800321 return NO_ERROR;
322}
323
Ana Krulec85c39af2018-12-26 17:29:57 -0800324void EventThread::removeDisplayEventConnectionLocked(const wp<EventThreadConnection>& connection) {
Chia-I Wu98cd38f2018-09-14 11:53:25 -0700325 auto it = std::find(mDisplayEventConnections.cbegin(),
326 mDisplayEventConnections.cend(), connection);
327 if (it != mDisplayEventConnections.cend()) {
328 mDisplayEventConnections.erase(it);
329 }
Mathias Agopian478ae5e2011-12-06 17:22:19 -0800330}
331
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800332void EventThread::setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) {
333 if (static_cast<std::underlying_type_t<VSyncRequest>>(rate) < 0) {
334 return;
335 }
336
337 std::lock_guard<std::mutex> lock(mMutex);
338
339 const auto request = rate == 0 ? VSyncRequest::None : static_cast<VSyncRequest>(rate);
340 if (connection->vsyncRequest != request) {
341 connection->vsyncRequest = request;
342 mCondition.notify_all();
Mathias Agopian478ae5e2011-12-06 17:22:19 -0800343 }
344}
345
Ady Abraham8532d012019-05-08 14:50:56 -0700346void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection) {
Dominik Laskowskif654d572018-12-20 11:03:06 -0800347 if (connection->resyncCallback) {
348 connection->resyncCallback();
Lloyd Pique24b0a482018-03-09 18:52:26 -0800349 }
Tim Murray4a4e4a22016-04-19 16:29:23 +0000350
Ana Krulec7d1d6832018-12-27 11:10:09 -0800351 std::lock_guard<std::mutex> lock(mMutex);
352
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800353 if (connection->vsyncRequest == VSyncRequest::None) {
354 connection->vsyncRequest = VSyncRequest::Single;
Lloyd Pique46a46b32018-01-31 19:01:18 -0800355 mCondition.notify_all();
Tim Murrayb5daa912020-09-09 21:29:13 +0000356 } else if (connection->vsyncRequest == VSyncRequest::SingleSuppressCallback) {
357 connection->vsyncRequest = VSyncRequest::Single;
Mathias Agopian478ae5e2011-12-06 17:22:19 -0800358 }
Mathias Agopian23748662011-12-05 14:33:34 -0800359}
360
Rachel Leeef2e21f2022-02-01 14:51:34 -0800361VsyncEventData EventThread::getLatestVsyncEventData(
362 const sp<EventThreadConnection>& connection) const {
Rachel Leeb5223cf2022-03-14 14:39:27 -0700363 // Resync so that the vsync is accurate with hardware. getLatestVsyncEventData is an alternate
364 // way to get vsync data (instead of posting callbacks to Choreographer).
365 if (connection->resyncCallback) {
366 connection->resyncCallback();
367 }
368
Rachel Leeef2e21f2022-02-01 14:51:34 -0800369 VsyncEventData vsyncEventData;
Leon Scroggins IIIdb16a2b2023-02-06 17:50:05 -0500370 nsecs_t frameInterval = mGetVsyncPeriodFunction(connection->mOwnerUid);
371 vsyncEventData.frameInterval = frameInterval;
Ady Abraham011f8ba2022-11-22 15:09:07 -0800372 const auto [presentTime, deadline] = [&]() -> std::pair<nsecs_t, nsecs_t> {
Rachel Leeb9c5a772022-02-04 21:17:37 -0800373 std::lock_guard<std::mutex> lock(mMutex);
Leon Scroggins III67388622023-02-06 20:36:20 -0500374 const auto vsyncTime = mVsyncSchedule->getTracker().nextAnticipatedVSyncTimeFrom(
Ady Abraham011f8ba2022-11-22 15:09:07 -0800375 systemTime() + mWorkDuration.get().count() + mReadyDuration.count());
376 return {vsyncTime, vsyncTime - mReadyDuration.count()};
377 }();
Leon Scroggins IIIdb16a2b2023-02-06 17:50:05 -0500378 generateFrameTimeline(vsyncEventData, frameInterval, systemTime(SYSTEM_TIME_MONOTONIC),
379 presentTime, deadline);
Rachel Leeef2e21f2022-02-01 14:51:34 -0800380 return vsyncEventData;
381}
382
Dominik Laskowskie99b98c2023-02-02 12:37:23 -0500383void EventThread::enableSyntheticVsync(bool enable) {
Lloyd Pique46a46b32018-01-31 19:01:18 -0800384 std::lock_guard<std::mutex> lock(mMutex);
Dominik Laskowskie99b98c2023-02-02 12:37:23 -0500385 if (!mVSyncState || mVSyncState->synthetic == enable) {
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800386 return;
Mathias Agopian22ffb112012-04-10 21:04:02 -0700387 }
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800388
Dominik Laskowskie99b98c2023-02-02 12:37:23 -0500389 mVSyncState->synthetic = enable;
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800390 mCondition.notify_all();
Mathias Agopian22ffb112012-04-10 21:04:02 -0700391}
392
Ady Abraham011f8ba2022-11-22 15:09:07 -0800393void EventThread::onVsync(nsecs_t vsyncTime, nsecs_t wakeupTime, nsecs_t readyTime) {
Lloyd Pique46a46b32018-01-31 19:01:18 -0800394 std::lock_guard<std::mutex> lock(mMutex);
Ady Abraham011f8ba2022-11-22 15:09:07 -0800395 mLastVsyncCallbackTime = TimePoint::fromNs(vsyncTime);
Dominik Laskowski23b867a2019-01-22 12:44:53 -0800396
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800397 LOG_FATAL_IF(!mVSyncState);
Ady Abraham011f8ba2022-11-22 15:09:07 -0800398 mVsyncTracer = (mVsyncTracer + 1) % 2;
399 mPendingEvents.push_back(makeVSync(mVSyncState->displayId, wakeupTime, ++mVSyncState->count,
400 vsyncTime, readyTime));
Lloyd Pique46a46b32018-01-31 19:01:18 -0800401 mCondition.notify_all();
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700402}
403
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800404void EventThread::onHotplugReceived(PhysicalDisplayId displayId, bool connected) {
Lloyd Pique46a46b32018-01-31 19:01:18 -0800405 std::lock_guard<std::mutex> lock(mMutex);
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700406
Dominik Laskowski23b867a2019-01-22 12:44:53 -0800407 mPendingEvents.push_back(makeHotplug(displayId, systemTime(), connected));
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700408 mCondition.notify_all();
Mathias Agopian148994e2012-09-19 17:31:36 -0700409}
410
Ady Abraham67434eb2022-12-01 17:48:12 -0800411void EventThread::onModeChanged(const scheduler::FrameRateMode& mode) {
Ady Abraham447052e2019-02-13 16:07:27 -0800412 std::lock_guard<std::mutex> lock(mMutex);
413
Ady Abraham690f4612021-07-01 23:24:03 -0700414 mPendingEvents.push_back(makeModeChanged(mode));
Ady Abraham447052e2019-02-13 16:07:27 -0800415 mCondition.notify_all();
416}
417
Ady Abraham62f216c2020-10-13 19:07:23 -0700418void EventThread::onFrameRateOverridesChanged(PhysicalDisplayId displayId,
419 std::vector<FrameRateOverride> overrides) {
420 std::lock_guard<std::mutex> lock(mMutex);
421
422 for (auto frameRateOverride : overrides) {
423 mPendingEvents.push_back(makeFrameRateOverrideEvent(displayId, frameRateOverride));
424 }
425 mPendingEvents.push_back(makeFrameRateOverrideFlushEvent(displayId));
426
427 mCondition.notify_all();
428}
429
Alec Mouri717bcb62020-02-10 17:07:19 -0800430size_t EventThread::getEventThreadConnectionCount() {
431 std::lock_guard<std::mutex> lock(mMutex);
432 return mDisplayEventConnections.size();
433}
434
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800435void EventThread::threadMain(std::unique_lock<std::mutex>& lock) {
436 DisplayEventConsumers consumers;
437
Dominik Laskowski029cc122019-01-23 19:52:06 -0800438 while (mState != State::Quit) {
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800439 std::optional<DisplayEventReceiver::Event> event;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700440
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800441 // Determine next event to dispatch.
442 if (!mPendingEvents.empty()) {
443 event = mPendingEvents.front();
444 mPendingEvents.pop_front();
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800445
Huihong Luoab8ffef2022-08-18 13:02:26 -0700446 if (event->header.type == DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG) {
447 if (event->hotplug.connected && !mVSyncState) {
448 mVSyncState.emplace(event->header.displayId);
449 } else if (!event->hotplug.connected && mVSyncState &&
450 mVSyncState->displayId == event->header.displayId) {
451 mVSyncState.reset();
452 }
Dominik Laskowski029cc122019-01-23 19:52:06 -0800453 }
Mathias Agopianff28e202012-09-20 23:24:19 -0700454 }
455
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800456 bool vsyncRequested = false;
Mathias Agopian148994e2012-09-19 17:31:36 -0700457
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800458 // Find connections that should consume this event.
Chia-I Wu98cd38f2018-09-14 11:53:25 -0700459 auto it = mDisplayEventConnections.begin();
460 while (it != mDisplayEventConnections.end()) {
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800461 if (const auto connection = it->promote()) {
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800462 if (event && shouldConsumeEvent(*event, connection)) {
463 consumers.push_back(connection);
Mathias Agopianf6bbd442012-08-21 15:47:28 -0700464 }
Mathias Agopianb4d18ed2012-09-20 23:14:05 -0700465
Ady Abraham011f8ba2022-11-22 15:09:07 -0800466 vsyncRequested |= connection->vsyncRequest != VSyncRequest::None;
467
Chia-I Wu98cd38f2018-09-14 11:53:25 -0700468 ++it;
Mathias Agopianf6bbd442012-08-21 15:47:28 -0700469 } else {
Chia-I Wu98cd38f2018-09-14 11:53:25 -0700470 it = mDisplayEventConnections.erase(it);
Mathias Agopianf6bbd442012-08-21 15:47:28 -0700471 }
472 }
473
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800474 if (!consumers.empty()) {
475 dispatchEvent(*event, consumers);
476 consumers.clear();
477 }
478
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800479 if (mVSyncState && vsyncRequested) {
Ady Abraham011f8ba2022-11-22 15:09:07 -0800480 mState = mVSyncState->synthetic ? State::SyntheticVSync : State::VSync;
Dominik Laskowski029cc122019-01-23 19:52:06 -0800481 } else {
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800482 ALOGW_IF(!mVSyncState, "Ignoring VSYNC request while display is disconnected");
Ady Abraham011f8ba2022-11-22 15:09:07 -0800483 mState = State::Idle;
Dominik Laskowski029cc122019-01-23 19:52:06 -0800484 }
485
Ady Abraham011f8ba2022-11-22 15:09:07 -0800486 if (mState == State::VSync) {
487 const auto scheduleResult =
488 mVsyncRegistration.schedule({.workDuration = mWorkDuration.get().count(),
489 .readyDuration = mReadyDuration.count(),
490 .earliestVsync = mLastVsyncCallbackTime.ns()});
491 LOG_ALWAYS_FATAL_IF(!scheduleResult, "Error scheduling callback");
492 } else {
493 mVsyncRegistration.cancel();
Mathias Agopianf6bbd442012-08-21 15:47:28 -0700494 }
495
Ady Abraham011f8ba2022-11-22 15:09:07 -0800496 if (!mPendingEvents.empty()) {
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800497 continue;
498 }
499
500 // Wait for event or client registration/request.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800501 if (mState == State::Idle) {
502 mCondition.wait(lock);
503 } else {
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800504 // Generate a fake VSYNC after a long timeout in case the driver stalls. When the
505 // display is off, keep feeding clients at 60 Hz.
Ady Abraham5facfb12020-04-22 15:18:31 -0700506 const std::chrono::nanoseconds timeout =
507 mState == State::SyntheticVSync ? 16ms : 1000ms;
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800508 if (mCondition.wait_for(lock, timeout) == std::cv_status::timeout) {
Ady Abraham5e7371c2020-03-24 14:47:24 -0700509 if (mState == State::VSync) {
510 ALOGW("Faking VSYNC due to driver stall for thread %s", mThreadName);
Ady Abraham5e7371c2020-03-24 14:47:24 -0700511 }
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800512
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800513 LOG_FATAL_IF(!mVSyncState);
Ady Abraham5facfb12020-04-22 15:18:31 -0700514 const auto now = systemTime(SYSTEM_TIME_MONOTONIC);
Ady Abraham8cb21882020-08-26 18:22:05 -0700515 const auto deadlineTimestamp = now + timeout.count();
516 const auto expectedVSyncTime = deadlineTimestamp + timeout.count();
Ady Abraham5facfb12020-04-22 15:18:31 -0700517 mPendingEvents.push_back(makeVSync(mVSyncState->displayId, now,
Ady Abraham8cb21882020-08-26 18:22:05 -0700518 ++mVSyncState->count, expectedVSyncTime,
Rachel Lee0d943202022-02-01 23:29:41 -0800519 deadlineTimestamp));
Mathias Agopianf6bbd442012-08-21 15:47:28 -0700520 }
521 }
Lloyd Pique46a46b32018-01-31 19:01:18 -0800522 }
Ady Abraham011f8ba2022-11-22 15:09:07 -0800523 // cancel any pending vsync event before exiting
524 mVsyncRegistration.cancel();
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800525}
Mathias Agopianf6bbd442012-08-21 15:47:28 -0700526
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800527bool EventThread::shouldConsumeEvent(const DisplayEventReceiver::Event& event,
528 const sp<EventThreadConnection>& connection) const {
Leon Scroggins IIIed66a352023-03-23 17:55:43 -0400529 const auto throttleVsync = [&]() REQUIRES(mMutex) {
Leon Scroggins III31d41412022-11-18 16:42:53 -0500530 const auto& vsyncData = event.vsync.vsyncData;
Rachel Lee2248f522023-01-27 16:45:23 -0800531 if (connection->frameRate.isValid()) {
Leon Scroggins III67388622023-02-06 20:36:20 -0500532 return !mVsyncSchedule->getTracker()
Rachel Lee2248f522023-01-27 16:45:23 -0800533 .isVSyncInPhase(vsyncData.preferredExpectedPresentationTime(),
534 connection->frameRate);
535 }
536
Leon Scroggins IIIdb16a2b2023-02-06 17:50:05 -0500537 return mThrottleVsyncCallback &&
538 mThrottleVsyncCallback(event.vsync.vsyncData.preferredExpectedPresentationTime(),
539 connection->mOwnerUid);
Ady Abraham0bb6a472020-10-12 10:22:13 -0700540 };
541
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800542 switch (event.header.type) {
543 case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG:
544 return true;
545
Marin Shalamanova7fe3042021-01-29 21:02:08 +0100546 case DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE: {
Ady Abraham62f216c2020-10-13 19:07:23 -0700547 return connection->mEventRegistration.test(
Huihong Luo1b0c49f2022-03-15 19:18:21 -0700548 gui::ISurfaceComposer::EventRegistration::modeChanged);
Alec Mouri60aee1c2019-10-28 16:18:59 -0700549 }
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700550
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800551 case DisplayEventReceiver::DISPLAY_EVENT_VSYNC:
552 switch (connection->vsyncRequest) {
553 case VSyncRequest::None:
554 return false;
Tim Murrayb5daa912020-09-09 21:29:13 +0000555 case VSyncRequest::SingleSuppressCallback:
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800556 connection->vsyncRequest = VSyncRequest::None;
Tim Murrayb5daa912020-09-09 21:29:13 +0000557 return false;
Ady Abraham0bb6a472020-10-12 10:22:13 -0700558 case VSyncRequest::Single: {
559 if (throttleVsync()) {
560 return false;
561 }
Tim Murrayb5daa912020-09-09 21:29:13 +0000562 connection->vsyncRequest = VSyncRequest::SingleSuppressCallback;
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800563 return true;
Ady Abraham0bb6a472020-10-12 10:22:13 -0700564 }
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800565 case VSyncRequest::Periodic:
Ady Abraham0bb6a472020-10-12 10:22:13 -0700566 if (throttleVsync()) {
567 return false;
568 }
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800569 return true;
570 default:
Ady Abraham0bb6a472020-10-12 10:22:13 -0700571 // We don't throttle vsync if the app set a vsync request rate
572 // since there is no easy way to do that and this is a very
573 // rare case
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800574 return event.vsync.count % vsyncPeriod(connection->vsyncRequest) == 0;
575 }
576
Ady Abraham62f216c2020-10-13 19:07:23 -0700577 case DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE:
578 [[fallthrough]];
579 case DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE_FLUSH:
580 return connection->mEventRegistration.test(
Huihong Luo1b0c49f2022-03-15 19:18:21 -0700581 gui::ISurfaceComposer::EventRegistration::frameRateOverride);
Ady Abraham62f216c2020-10-13 19:07:23 -0700582
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800583 default:
584 return false;
585 }
586}
587
Rachel Lee8d0c6102021-11-03 22:00:25 +0000588int64_t EventThread::generateToken(nsecs_t timestamp, nsecs_t deadlineTimestamp,
Rachel Leeb9c5a772022-02-04 21:17:37 -0800589 nsecs_t expectedPresentationTime) const {
Rachel Lee3f028662021-11-04 19:32:24 +0000590 if (mTokenManager != nullptr) {
591 return mTokenManager->generateTokenForPredictions(
Rachel Leeb9c5a772022-02-04 21:17:37 -0800592 {timestamp, deadlineTimestamp, expectedPresentationTime});
Rachel Lee3f028662021-11-04 19:32:24 +0000593 }
594 return FrameTimelineInfo::INVALID_VSYNC_ID;
595}
596
Rachel Leeb9c5a772022-02-04 21:17:37 -0800597void EventThread::generateFrameTimeline(VsyncEventData& outVsyncEventData, nsecs_t frameInterval,
598 nsecs_t timestamp,
599 nsecs_t preferredExpectedPresentationTime,
600 nsecs_t preferredDeadlineTimestamp) const {
Rachel Lee0655a912023-04-20 19:54:18 -0700601 uint32_t currentIndex = 0;
Rachel Lee3f028662021-11-04 19:32:24 +0000602 // Add 1 to ensure the preferredFrameTimelineIndex entry (when multiplier == 0) is included.
Rachel Lee0655a912023-04-20 19:54:18 -0700603 for (int64_t multiplier = -VsyncEventData::kFrameTimelinesLength + 1;
Rachel Lee18c34372022-01-20 13:57:18 -0800604 currentIndex < VsyncEventData::kFrameTimelinesLength; multiplier++) {
Rachel Leeb9c5a772022-02-04 21:17:37 -0800605 nsecs_t deadlineTimestamp = preferredDeadlineTimestamp + multiplier * frameInterval;
Rachel Lee0655a912023-04-20 19:54:18 -0700606 // Valid possible frame timelines must have future values, so find a later frame timeline.
607 if (deadlineTimestamp <= timestamp) {
608 continue;
Rachel Lee3f028662021-11-04 19:32:24 +0000609 }
Rachel Lee0655a912023-04-20 19:54:18 -0700610
611 nsecs_t expectedPresentationTime =
612 preferredExpectedPresentationTime + multiplier * frameInterval;
613 if (expectedPresentationTime >= preferredExpectedPresentationTime +
614 scheduler::VsyncConfig::kEarlyLatchMaxThreshold.count()) {
615 break;
616 }
617
618 if (multiplier == 0) {
619 outVsyncEventData.preferredFrameTimelineIndex = currentIndex;
620 }
621
622 outVsyncEventData.frameTimelines[currentIndex] =
623 {.vsyncId = generateToken(timestamp, deadlineTimestamp, expectedPresentationTime),
624 .deadlineTimestamp = deadlineTimestamp,
625 .expectedPresentationTime = expectedPresentationTime};
626 currentIndex++;
Rachel Lee3f028662021-11-04 19:32:24 +0000627 }
Rachel Lee0655a912023-04-20 19:54:18 -0700628 outVsyncEventData.frameTimelinesLength = currentIndex;
Rachel Lee3f028662021-11-04 19:32:24 +0000629}
630
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800631void EventThread::dispatchEvent(const DisplayEventReceiver::Event& event,
632 const DisplayEventConsumers& consumers) {
633 for (const auto& consumer : consumers) {
Jorim Jaggic0086af2021-02-12 18:18:11 +0100634 DisplayEventReceiver::Event copy = event;
635 if (event.header.type == DisplayEventReceiver::DISPLAY_EVENT_VSYNC) {
Leon Scroggins IIIdb16a2b2023-02-06 17:50:05 -0500636 const int64_t frameInterval = mGetVsyncPeriodFunction(consumer->mOwnerUid);
637 copy.vsync.vsyncData.frameInterval = frameInterval;
638 generateFrameTimeline(copy.vsync.vsyncData, frameInterval, copy.header.timestamp,
Rachel Leeb9c5a772022-02-04 21:17:37 -0800639 event.vsync.vsyncData.preferredExpectedPresentationTime(),
640 event.vsync.vsyncData.preferredDeadlineTimestamp());
Jorim Jaggic0086af2021-02-12 18:18:11 +0100641 }
642 switch (consumer->postEvent(copy)) {
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800643 case NO_ERROR:
644 break;
645
646 case -EAGAIN:
647 // TODO: Try again if pipe is full.
648 ALOGW("Failed dispatching %s for %s", toString(event).c_str(),
649 toString(*consumer).c_str());
650 break;
651
652 default:
653 // Treat EPIPE and other errors as fatal.
654 removeDisplayEventConnectionLocked(consumer);
655 }
656 }
Mathias Agopianf6bbd442012-08-21 15:47:28 -0700657}
658
Yiwei Zhang5434a782018-12-05 18:06:32 -0800659void EventThread::dump(std::string& result) const {
Lloyd Pique46a46b32018-01-31 19:01:18 -0800660 std::lock_guard<std::mutex> lock(mMutex);
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800661
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800662 StringAppendF(&result, "%s: state=%s VSyncState=", mThreadName, toCString(mState));
663 if (mVSyncState) {
Marin Shalamanova524a092020-07-27 21:39:55 +0200664 StringAppendF(&result, "{displayId=%s, count=%u%s}\n",
665 to_string(mVSyncState->displayId).c_str(), mVSyncState->count,
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800666 mVSyncState->synthetic ? ", synthetic" : "");
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800667 } else {
668 StringAppendF(&result, "none\n");
669 }
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800670
Ady Abraham011f8ba2022-11-22 15:09:07 -0800671 const auto relativeLastCallTime =
672 ticks<std::milli, float>(mLastVsyncCallbackTime - TimePoint::now());
673 StringAppendF(&result, "mWorkDuration=%.2f mReadyDuration=%.2f last vsync time ",
674 mWorkDuration.get().count() / 1e6f, mReadyDuration.count() / 1e6f);
675 StringAppendF(&result, "%.2fms relative to now\n", relativeLastCallTime);
676
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800677 StringAppendF(&result, " pending events (count=%zu):\n", mPendingEvents.size());
678 for (const auto& event : mPendingEvents) {
679 StringAppendF(&result, " %s\n", toString(event).c_str());
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -0700680 }
Dominik Laskowskid9e4de62019-01-21 14:23:01 -0800681
682 StringAppendF(&result, " connections (count=%zu):\n", mDisplayEventConnections.size());
683 for (const auto& ptr : mDisplayEventConnections) {
684 if (const auto connection = ptr.promote()) {
685 StringAppendF(&result, " %s\n", toString(*connection).c_str());
686 }
687 }
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400688 result += '\n';
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800689}
690
Dominik Laskowski029cc122019-01-23 19:52:06 -0800691const char* EventThread::toCString(State state) {
692 switch (state) {
693 case State::Idle:
694 return "Idle";
695 case State::Quit:
696 return "Quit";
697 case State::SyntheticVSync:
698 return "SyntheticVSync";
699 case State::VSync:
700 return "VSync";
701 }
702}
703
Leon Scroggins III67388622023-02-06 20:36:20 -0500704void EventThread::onNewVsyncSchedule(std::shared_ptr<scheduler::VsyncSchedule> schedule) {
705 std::lock_guard<std::mutex> lock(mMutex);
706 const bool reschedule = mVsyncRegistration.cancel() == scheduler::CancelResult::Cancelled;
707 mVsyncSchedule = std::move(schedule);
708 mVsyncRegistration =
709 scheduler::VSyncCallbackRegistration(mVsyncSchedule->getDispatch(),
710 createDispatchCallback(), mThreadName);
711 if (reschedule) {
712 mVsyncRegistration.schedule({.workDuration = mWorkDuration.get().count(),
713 .readyDuration = mReadyDuration.count(),
714 .earliestVsync = mLastVsyncCallbackTime.ns()});
715 }
716}
717
718scheduler::VSyncDispatch::Callback EventThread::createDispatchCallback() {
719 return [this](nsecs_t vsyncTime, nsecs_t wakeupTime, nsecs_t readyTime) {
720 onVsync(vsyncTime, wakeupTime, readyTime);
721 };
722}
723
Lloyd Pique0fcde1b2017-12-20 16:50:21 -0800724} // namespace impl
Lloyd Pique46a46b32018-01-31 19:01:18 -0800725} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800726
727// TODO(b/129481165): remove the #pragma below and fix conversion issues
728#pragma clang diagnostic pop // ignored "-Wconversion"