Reland "SF: Encapsulate frame targeting"
Introduce FrameTargeter to isolate a display's per-frame metrics around
past/upcoming deadline targets. The Scheduler updates the FrameTargeter
on frame begin/end, whereas ICompositor (concretely SurfaceFlinger) has
read-only access via the FrameTarget interface.
For now, only instantiate the pacesetter's FrameTargeter.
The reverted Idf9f43b37f3479c94a478d154eaa46f43e0c6c9d had an incorrect
functional change that adjusted `earliestPresentTime` based on the past
VSYNC, which differs from the previous frame's VSYNC when targeting two
VSYNCs ahead. This CL restores the `earliestPresentTime` to be relative
to the previous frame.
Bug: 262269033
Bug: 241285475
Bug: 241285191
Test: Perfetto
Test: dumpsys SurfaceFlinger --scheduler
Test: atest libscheduler_test:FrameTargeterTest
Test: systemui-bubble-1-jank-suite on raven-userdebug
Change-Id: I584e299e8af55baae1125f45fd47b13f705a268c
diff --git a/services/surfaceflinger/Scheduler/VsyncSchedule.h b/services/surfaceflinger/Scheduler/VsyncSchedule.h
index 556ef80..c037ac8 100644
--- a/services/surfaceflinger/Scheduler/VsyncSchedule.h
+++ b/services/surfaceflinger/Scheduler/VsyncSchedule.h
@@ -20,14 +20,17 @@
#include <memory>
#include <string>
-#include <ThreadContext.h>
#include <android-base/thread_annotations.h>
#include <ftl/enum.h>
#include <ftl/optional.h>
-#include <scheduler/Features.h>
-#include <scheduler/Time.h>
#include <ui/DisplayId.h>
+#include <scheduler/Features.h>
+#include <scheduler/IVsyncSource.h>
+#include <scheduler/Time.h>
+
+#include "ThreadContext.h"
+
namespace android {
class EventThreadTest;
class VsyncScheduleTest;
@@ -48,15 +51,16 @@
using VsyncTracker = VSyncTracker;
// Schedule that synchronizes to hardware VSYNC of a physical display.
-class VsyncSchedule {
+class VsyncSchedule final : public IVsyncSource {
public:
using RequestHardwareVsync = std::function<void(PhysicalDisplayId, bool enabled)>;
VsyncSchedule(PhysicalDisplayId, FeatureFlags, RequestHardwareVsync);
~VsyncSchedule();
- Period period() const;
- TimePoint vsyncDeadlineAfter(TimePoint) const;
+ // IVsyncSource overrides:
+ Period period() const override;
+ TimePoint vsyncDeadlineAfter(TimePoint) const override;
// Inform the schedule that the period is changing and the schedule needs to recalibrate
// itself. The schedule will end the period transition internally. This will