diff options
author | 2021-02-09 02:27:08 +0000 | |
---|---|---|
committer | 2021-02-09 02:27:08 +0000 | |
commit | 1ff99d8f3357ae14fd1de4d5658e32d145f4b1d0 (patch) | |
tree | f68d052e6221f55a08a6c0ef54e0e5d02607a5cb | |
parent | 981787535c543cf82ef6f92ad17e9d15b6dc032f (diff) |
Revert "DisplayEventDispatcher: optimize binder calls"
This reverts commit 981787535c543cf82ef6f92ad17e9d15b6dc032f.
Reason for revert: b/179721483
Change-Id: I667bbcdb6cc8c06624d6dbb599aa612b0af24951
-rw-r--r-- | libs/gui/DisplayEventDispatcher.cpp | 70 | ||||
-rw-r--r-- | libs/gui/include/gui/DisplayEventDispatcher.h | 15 | ||||
-rw-r--r-- | services/surfaceflinger/Scheduler/EventThread.cpp | 4 |
3 files changed, 22 insertions, 67 deletions
diff --git a/libs/gui/DisplayEventDispatcher.cpp b/libs/gui/DisplayEventDispatcher.cpp index 2ad484add3..c6c9a8f7a7 100644 --- a/libs/gui/DisplayEventDispatcher.cpp +++ b/libs/gui/DisplayEventDispatcher.cpp @@ -36,9 +36,7 @@ static const size_t EVENT_BUFFER_SIZE = 100; DisplayEventDispatcher::DisplayEventDispatcher( const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::EventRegistrationFlags eventRegistration) - : mLooper(looper), - mReceiver(vsyncSource, eventRegistration), - mVsyncState(VsyncState::Unregistered) { + : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } @@ -68,37 +66,26 @@ void DisplayEventDispatcher::dispose() { } status_t DisplayEventDispatcher::scheduleVsync() { - switch (mVsyncState) { - case VsyncState::Unregistered: { - ALOGV("dispatcher %p ~ Scheduling vsync.", this); - - // Drain all pending events. - nsecs_t vsyncTimestamp; - PhysicalDisplayId vsyncDisplayId; - uint32_t vsyncCount; - VsyncEventData vsyncEventData; - if (processPendingEvents(&vsyncTimestamp, &vsyncDisplayId, &vsyncCount, - &vsyncEventData)) { - ALOGE("dispatcher %p ~ last event processed while scheduling was for %" PRId64 "", - this, ns2ms(static_cast<nsecs_t>(vsyncTimestamp))); - } - - status_t status = mReceiver.setVsyncRate(1); - if (status) { - ALOGW("Failed to set vsync rate, status=%d", status); - return status; - } - - mVsyncState = VsyncState::RegisteredAndWaitingForVsync; - break; + if (!mWaitingForVsync) { + ALOGV("dispatcher %p ~ Scheduling vsync.", this); + + // Drain all pending events. + nsecs_t vsyncTimestamp; + PhysicalDisplayId vsyncDisplayId; + uint32_t vsyncCount; + VsyncEventData vsyncEventData; + if (processPendingEvents(&vsyncTimestamp, &vsyncDisplayId, &vsyncCount, &vsyncEventData)) { + ALOGE("dispatcher %p ~ last event processed while scheduling was for %" PRId64 "", this, + ns2ms(static_cast<nsecs_t>(vsyncTimestamp))); } - case VsyncState::Registered: { - mVsyncState = VsyncState::RegisteredAndWaitingForVsync; - break; - } - case VsyncState::RegisteredAndWaitingForVsync: { - break; + + status_t status = mReceiver.requestNextVsync(); + if (status) { + ALOGW("Failed to request next vsync, status=%d", status); + return status; } + + mWaitingForVsync = true; } return OK; } @@ -136,23 +123,8 @@ int DisplayEventDispatcher::handleEvent(int, int events, void*) { ", displayId=%s, count=%d, vsyncId=%" PRId64, this, ns2ms(vsyncTimestamp), to_string(vsyncDisplayId).c_str(), vsyncCount, vsyncEventData.id); - switch (mVsyncState) { - case VsyncState::Unregistered: - ALOGW("Received unexpected VSYNC event"); - break; - case VsyncState::RegisteredAndWaitingForVsync: - mVsyncState = VsyncState::Registered; - dispatchVsync(vsyncTimestamp, vsyncDisplayId, vsyncCount, vsyncEventData); - break; - case VsyncState::Registered: - status_t status = mReceiver.setVsyncRate(0); - if (status) { - ALOGW("Failed to reset vsync rate, status=%d", status); - return status; - } - mVsyncState = VsyncState::Unregistered; - break; - } + mWaitingForVsync = false; + dispatchVsync(vsyncTimestamp, vsyncDisplayId, vsyncCount, vsyncEventData); } return 1; // keep the callback diff --git a/libs/gui/include/gui/DisplayEventDispatcher.h b/libs/gui/include/gui/DisplayEventDispatcher.h index 4c2b08b2bb..5587acf08f 100644 --- a/libs/gui/include/gui/DisplayEventDispatcher.h +++ b/libs/gui/include/gui/DisplayEventDispatcher.h @@ -52,20 +52,7 @@ protected: private: sp<Looper> mLooper; DisplayEventReceiver mReceiver; - // The state of vsync event registration and whether the client is expecting - // an event or not. - enum class VsyncState { - // The dispatcher is not registered for vsync events. - Unregistered, - // The dispatcher is registered to receive vsync events but should not dispatch it to the - // client as the client is not expecting a vsync event. - Registered, - - // The dispatcher is registered to receive vsync events and supposed to dispatch it to - // the client. - RegisteredAndWaitingForVsync, - }; - VsyncState mVsyncState; + bool mWaitingForVsync; std::vector<FrameRateOverride> mFrameRateOverrides; diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp index f90c130992..c12a7b106a 100644 --- a/services/surfaceflinger/Scheduler/EventThread.cpp +++ b/services/surfaceflinger/Scheduler/EventThread.cpp @@ -303,10 +303,6 @@ void EventThread::setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& c std::lock_guard<std::mutex> lock(mMutex); const auto request = rate == 0 ? VSyncRequest::None : static_cast<VSyncRequest>(rate); - if (request != VSyncRequest::None && connection->resyncCallback) { - connection->resyncCallback(); - } - if (connection->vsyncRequest != request) { connection->vsyncRequest = request; mCondition.notify_all(); |