Skip to content

Commit 1d844de

Browse files
Ben WidawskyAndroid (Google) Code Review
authored andcommitted
Merge "SF: Use VsyncSchedule's ID for EventThread" into main
2 parents 6919a49 + 59954c4 commit 1d844de

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

services/surfaceflinger/Scheduler/EventThread.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ void EventThread::onVsync(nsecs_t vsyncTime, nsecs_t wakeupTime, nsecs_t readyTi
426426

427427
LOG_FATAL_IF(!mVSyncState);
428428
mVsyncTracer = (mVsyncTracer + 1) % 2;
429-
mPendingEvents.push_back(makeVSync(mVSyncState->displayId, wakeupTime, ++mVSyncState->count,
430-
vsyncTime, readyTime));
429+
mPendingEvents.push_back(makeVSync(mVsyncSchedule->getPhysicalDisplayId(), wakeupTime,
430+
++mVSyncState->count, vsyncTime, readyTime));
431431
mCondition.notify_all();
432432
}
433433

@@ -486,9 +486,9 @@ void EventThread::threadMain(std::unique_lock<std::mutex>& lock) {
486486
if (event->header.type == DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG) {
487487
if (event->hotplug.connectionError == 0) {
488488
if (event->hotplug.connected && !mVSyncState) {
489-
mVSyncState.emplace(event->header.displayId);
490-
} else if (!event->hotplug.connected && mVSyncState &&
491-
mVSyncState->displayId == event->header.displayId) {
489+
mVSyncState.emplace();
490+
} else if (!event->hotplug.connected &&
491+
mVsyncSchedule->getPhysicalDisplayId() == event->header.displayId) {
492492
mVSyncState.reset();
493493
}
494494
} else {
@@ -559,7 +559,7 @@ void EventThread::threadMain(std::unique_lock<std::mutex>& lock) {
559559
const auto now = systemTime(SYSTEM_TIME_MONOTONIC);
560560
const auto deadlineTimestamp = now + timeout.count();
561561
const auto expectedVSyncTime = deadlineTimestamp + timeout.count();
562-
mPendingEvents.push_back(makeVSync(mVSyncState->displayId, now,
562+
mPendingEvents.push_back(makeVSync(mVsyncSchedule->getPhysicalDisplayId(), now,
563563
++mVSyncState->count, expectedVSyncTime,
564564
deadlineTimestamp));
565565
}
@@ -739,7 +739,7 @@ void EventThread::dump(std::string& result) const {
739739
StringAppendF(&result, "%s: state=%s VSyncState=", mThreadName, toCString(mState));
740740
if (mVSyncState) {
741741
StringAppendF(&result, "{displayId=%s, count=%u%s}\n",
742-
to_string(mVSyncState->displayId).c_str(), mVSyncState->count,
742+
to_string(mVsyncSchedule->getPhysicalDisplayId()).c_str(), mVSyncState->count,
743743
mVSyncState->synthetic ? ", synthetic" : "");
744744
} else {
745745
StringAppendF(&result, "none\n");

services/surfaceflinger/Scheduler/EventThread.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,6 @@ class EventThread : public android::EventThread {
235235

236236
// VSYNC state of connected display.
237237
struct VSyncState {
238-
explicit VSyncState(PhysicalDisplayId displayId) : displayId(displayId) {}
239-
240-
const PhysicalDisplayId displayId;
241-
242238
// Number of VSYNC events since display was connected.
243239
uint32_t count = 0;
244240

services/surfaceflinger/Scheduler/VsyncSchedule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class VsyncSchedule final : public IVsyncSource {
112112

113113
bool getPendingHardwareVsyncState() const REQUIRES(kMainThreadContext);
114114

115+
PhysicalDisplayId getPhysicalDisplayId() const { return mId; }
116+
115117
protected:
116118
using ControllerPtr = std::unique_ptr<VsyncController>;
117119

0 commit comments

Comments
 (0)