SF: return the expected wakeup time from VSyncDispatch
Return the expected wakeup of a callback scheduled with VSyncDispatch.
This would help the client to better plan it's work. In particular
this would be used for SF to know when to schedule the region sample
thread to capture the screen.
Bug: 181983990
Test: SF unit tests
Change-Id: I38b538c1f6fac7cadcf456c55e78f67cf637480d
diff --git a/services/surfaceflinger/Scheduler/VSyncDispatch.h b/services/surfaceflinger/Scheduler/VSyncDispatch.h
index 9d71103..b52706f 100644
--- a/services/surfaceflinger/Scheduler/VSyncDispatch.h
+++ b/services/surfaceflinger/Scheduler/VSyncDispatch.h
@@ -16,8 +16,10 @@
#pragma once
+#include <utils/Log.h>
#include <utils/Timers.h>
#include <functional>
+#include <optional>
#include <string>
#include "StrongTyping.h"
@@ -26,7 +28,8 @@
class TimeKeeper;
class VSyncTracker;
-enum class ScheduleResult { Scheduled, CannotSchedule, Error };
+using ScheduleResult = std::optional<nsecs_t>;
+
enum class CancelResult { Cancelled, TooLate, Error };
/*
@@ -121,11 +124,8 @@
*
* \param [in] token The callback to schedule.
* \param [in] scheduleTiming The timing information for this schedule call
- * \return A ScheduleResult::Scheduled if callback was scheduled.
- * A ScheduleResult::CannotSchedule
- * if (workDuration + readyDuration - earliestVsync) is in the past,
- * or if a callback was dispatched for the predictedVsync already. A ScheduleResult::Error if
- * there was another error.
+ * \return The expected callback time if a callback was scheduled.
+ * std::nullopt if the callback is not registered.
*/
virtual ScheduleResult schedule(CallbackToken token, ScheduleTiming scheduleTiming) = 0;