From 62f216c62edbe4c997e959cfb28c8609664978df Mon Sep 17 00:00:00 2001 From: Ady Abraham Date: Tue, 13 Oct 2020 19:07:23 -0700 Subject: SurfaceFlinger: Add DISPLAY_EVENT_FRAME_RATE_OVERRIDE Add a new event to DisplayEventReceiver that conveys a list of apps whose frame rates have been overriden. This event is processed by the DisplayManager to advertise the new frame rate to the overridden app. Change-Id: I89fce8b5b4d9db65ec5db7dd2393c384c0fcfd82 Bug: 169271059 Bug: 169271062 Bug: 170503758 Test: manual test using SF backdoor --- libs/gui/DisplayEventDispatcher.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libs/gui/DisplayEventDispatcher.cpp') diff --git a/libs/gui/DisplayEventDispatcher.cpp b/libs/gui/DisplayEventDispatcher.cpp index abfee61685..c6c9a8f7a7 100644 --- a/libs/gui/DisplayEventDispatcher.cpp +++ b/libs/gui/DisplayEventDispatcher.cpp @@ -33,10 +33,10 @@ namespace android { // using just a few large reads. static const size_t EVENT_BUFFER_SIZE = 100; -DisplayEventDispatcher::DisplayEventDispatcher(const sp& looper, - ISurfaceComposer::VsyncSource vsyncSource, - ISurfaceComposer::ConfigChanged configChanged) - : mLooper(looper), mReceiver(vsyncSource, configChanged), mWaitingForVsync(false) { +DisplayEventDispatcher::DisplayEventDispatcher( + const sp& looper, ISurfaceComposer::VsyncSource vsyncSource, + ISurfaceComposer::EventRegistrationFlags eventRegistration) + : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } @@ -139,6 +139,7 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, ssize_t n; while ((n = mReceiver.getEvents(buf, EVENT_BUFFER_SIZE)) > 0) { ALOGV("dispatcher %p ~ Read %d events.", this, int(n)); + mFrameRateOverrides.reserve(n); for (ssize_t i = 0; i < n; i++) { const DisplayEventReceiver::Event& ev = buf[i]; switch (ev.header.type) { @@ -162,6 +163,13 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, case DisplayEventReceiver::DISPLAY_EVENT_NULL: dispatchNullEvent(ev.header.timestamp, ev.header.displayId); break; + case DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE: + mFrameRateOverrides.emplace_back(ev.frameRateOverride); + break; + case DisplayEventReceiver::DISPLAY_EVENT_FRAME_RATE_OVERRIDE_FLUSH: + dispatchFrameRateOverrides(ev.header.timestamp, ev.header.displayId, + std::move(mFrameRateOverrides)); + break; default: ALOGW("dispatcher %p ~ ignoring unknown event type %#x", this, ev.header.type); break; -- cgit v1.2.3-59-g8ed1b