SurfaceFlinger: pass frame deadline to Choreographer
Pass the frame deadline calculated by SF to AChoreographer so
hwui would be able to improve its stats by knowing if a frame is
likely to be late.
Bug: 169858174
Test: manul
Change-Id: I9433d990684b968cbe1cd3ce17717b616d01b9a2
diff --git a/libs/nativedisplay/AChoreographer.cpp b/libs/nativedisplay/AChoreographer.cpp
index 470f28f..9e515cd 100644
--- a/libs/nativedisplay/AChoreographer.cpp
+++ b/libs/nativedisplay/AChoreographer.cpp
@@ -129,13 +129,14 @@
static Choreographer* getForThread();
virtual ~Choreographer() override EXCLUDES(gChoreographers.lock);
int64_t getVsyncId() const;
+ int64_t getFrameDeadline() const;
private:
Choreographer(const Choreographer&) = delete;
void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count,
- int64_t vsyncId) override;
+ VsyncEventData vsyncEventData) override;
void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) override;
void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t configId,
nsecs_t vsyncPeriod) override;
@@ -149,7 +150,7 @@
std::vector<RefreshRateCallback> mRefreshRateCallbacks;
nsecs_t mLatestVsyncPeriod = -1;
- int64_t mLastVsyncId = -1;
+ VsyncEventData mLastVsyncEventData;
const sp<Looper> mLooper;
const std::thread::id mThreadId;
@@ -354,7 +355,8 @@
// TODO(b/74619554): The PhysicalDisplayId is ignored because SF only emits VSYNC events for the
// internal display and DisplayEventReceiver::requestNextVsync only allows requesting VSYNC for
// the internal display implicitly.
-void Choreographer::dispatchVsync(nsecs_t timestamp, PhysicalDisplayId, uint32_t, int64_t vsyncId) {
+void Choreographer::dispatchVsync(nsecs_t timestamp, PhysicalDisplayId, uint32_t,
+ VsyncEventData vsyncEventData) {
std::vector<FrameCallback> callbacks{};
{
std::lock_guard<std::mutex> _l{mLock};
@@ -364,7 +366,7 @@
mFrameCallbacks.pop();
}
}
- mLastVsyncId = vsyncId;
+ mLastVsyncEventData = vsyncEventData;
for (const auto& cb : callbacks) {
if (cb.callback64 != nullptr) {
cb.callback64(timestamp, cb.data);
@@ -410,7 +412,11 @@
}
int64_t Choreographer::getVsyncId() const {
- return mLastVsyncId;
+ return mLastVsyncEventData.id;
+}
+
+int64_t Choreographer::getFrameDeadline() const {
+ return mLastVsyncEventData.deadlineTimestamp;
}
} // namespace android
@@ -492,6 +498,10 @@
return AChoreographer_to_Choreographer(choreographer)->getVsyncId();
}
+int64_t AChoreographer_getFrameDeadline(const AChoreographer* choreographer) {
+ return AChoreographer_to_Choreographer(choreographer)->getFrameDeadline();
+}
+
} // namespace android
/* Glue for the NDK interface */