drm_hwcomposer: Enable VSyncWorker thread as needed
Rather than explicitly enabling and disabling the VSyncWorker thread
from HwcDisplay, move the logic to enable/disable the thread into
VSyncWorker, and enable it based on whether HwcDisplay has requested
vsync timeline events, or timeline tracking.
This simplifies the public interface for VSyncWorker, and removes the
need for holding the global lock to check whether the thread should be
enabled or not.
Change-Id: Ic1632a19b268ea1d4ed2d8ec8704ef531481211c
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/drm/VSyncWorker.h b/drm/VSyncWorker.h
index f032d79..f1143e4 100644
--- a/drm/VSyncWorker.h
+++ b/drm/VSyncWorker.h
@@ -41,8 +41,6 @@
VSyncWorkerCallbacks &callbacks)
-> std::shared_ptr<VSyncWorker>;
- void VSyncControl(bool enabled);
-
// Set the expected vsync period.
void SetVsyncPeriodNs(uint32_t vsync_period_ns);
@@ -65,6 +63,10 @@
int64_t GetPhasedVSync(int64_t frame_ns, int64_t current) const;
int SyntheticWaitVBlank(int64_t *timestamp);
+ // Must hold the lock before calling these.
+ void UpdateVSyncControl();
+ bool ShouldEnable() const;
+
VSyncWorkerCallbacks callbacks_;
SharedFd drm_fd_;