SF: Remove fixed-size array for VSYNC events
EventThread maintains two DisplayEventReceiver::Event instances to store
the latest VSYNC state for the internal and external displays, regardless
of their connection status. This CL removes the (unused) latter instance,
replaces the former with VSyncState, and generalizes event processing by
queuing up VSYNC events along with hotplug events.
The VSyncState lifetime will be tied to hotplug events in a future CL.
Bug: 74619554
Test: libsurfaceflinger_unittest
Test: dumpsys SurfaceFlinger --vsync
Change-Id: I5fbc1d08259145387dab73596a0cfe4624c35676
diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h
index b622e7a..1a8ebb7 100644
--- a/services/surfaceflinger/Scheduler/EventThread.h
+++ b/services/surfaceflinger/Scheduler/EventThread.h
@@ -18,7 +18,6 @@
#include <sys/types.h>
-#include <array>
#include <condition_variable>
#include <cstdint>
#include <deque>
@@ -199,8 +198,20 @@
std::vector<wp<EventThreadConnection>> mDisplayEventConnections GUARDED_BY(mMutex);
std::deque<DisplayEventReceiver::Event> mPendingEvents GUARDED_BY(mMutex);
- std::array<DisplayEventReceiver::Event, 2> mVSyncEvent GUARDED_BY(mMutex);
- bool mUseSoftwareVSync GUARDED_BY(mMutex) = false;
+
+ // VSYNC state of connected display.
+ struct VSyncState {
+ uint32_t displayId = 0;
+
+ // Number of VSYNC events since display was connected.
+ uint32_t count = 0;
+
+ // True if VSYNC should be faked, e.g. when display is off.
+ bool synthetic = false;
+ };
+
+ VSyncState mVSyncState GUARDED_BY(mMutex);
+
bool mVsyncEnabled GUARDED_BY(mMutex) = false;
bool mKeepRunning GUARDED_BY(mMutex) = true;