Use VsyncEventData in DisplayEventReceiver::Event.
Clean-up that re-uses VsyncEventData so it's easier to maintain.
The ParcelableVsyncEventData is used in AIDL. It is separated from
VsyncEventData because of the union in
DisplayEventReceiver::Event and Parcelable has non-trivial
constructors.
Bug: 218563993
Test: atest ChoreographerNativeTest
Test: atest libsurfaceflinger_unittest
Test: atest libgui_test
Change-Id: I3ebeb1c7826300c27c4a12d4dba6fbd16305e9e1
diff --git a/libs/nativedisplay/AChoreographer.cpp b/libs/nativedisplay/AChoreographer.cpp
index b182a4a..3ce381b 100644
--- a/libs/nativedisplay/AChoreographer.cpp
+++ b/libs/nativedisplay/AChoreographer.cpp
@@ -103,9 +103,7 @@
struct ChoreographerFrameCallbackDataImpl {
int64_t frameTimeNanos{0};
- std::array<VsyncEventData::FrameTimeline, VsyncEventData::kFrameTimelinesLength> frameTimelines;
-
- size_t preferredFrameTimelineIndex;
+ VsyncEventData vsyncEventData;
const Choreographer* choreographer;
};
@@ -450,8 +448,7 @@
ChoreographerFrameCallbackDataImpl Choreographer::createFrameCallbackData(nsecs_t timestamp) const {
return {.frameTimeNanos = timestamp,
- .preferredFrameTimelineIndex = mLastVsyncEventData.preferredFrameTimelineIndex,
- .frameTimelines = mLastVsyncEventData.frameTimelines,
+ .vsyncEventData = mLastVsyncEventData,
.choreographer = this};
}
@@ -634,7 +631,7 @@
AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data);
LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(),
"Data is only valid in callback");
- return frameCallbackData->frameTimelines.size();
+ return VsyncEventData::kFrameTimelinesLength;
}
size_t AChoreographerFrameCallbackData_getPreferredFrameTimelineIndex(
const AChoreographerFrameCallbackData* data) {
@@ -642,7 +639,7 @@
AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data);
LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(),
"Data is only valid in callback");
- return frameCallbackData->preferredFrameTimelineIndex;
+ return frameCallbackData->vsyncEventData.preferredFrameTimelineIndex;
}
AVsyncId AChoreographerFrameCallbackData_getFrameTimelineVsyncId(
const AChoreographerFrameCallbackData* data, size_t index) {
@@ -650,8 +647,8 @@
AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data);
LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(),
"Data is only valid in callback");
- LOG_ALWAYS_FATAL_IF(index >= frameCallbackData->frameTimelines.size(), "Index out of bounds");
- return frameCallbackData->frameTimelines[index].id;
+ LOG_ALWAYS_FATAL_IF(index >= VsyncEventData::kFrameTimelinesLength, "Index out of bounds");
+ return frameCallbackData->vsyncEventData.frameTimelines[index].vsyncId;
}
int64_t AChoreographerFrameCallbackData_getFrameTimelineExpectedPresentTimeNanos(
const AChoreographerFrameCallbackData* data, size_t index) {
@@ -659,8 +656,8 @@
AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data);
LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(),
"Data is only valid in callback");
- LOG_ALWAYS_FATAL_IF(index >= frameCallbackData->frameTimelines.size(), "Index out of bounds");
- return frameCallbackData->frameTimelines[index].expectedPresentTime;
+ LOG_ALWAYS_FATAL_IF(index >= VsyncEventData::kFrameTimelinesLength, "Index out of bounds");
+ return frameCallbackData->vsyncEventData.frameTimelines[index].expectedPresentationTime;
}
int64_t AChoreographerFrameCallbackData_getFrameTimelineDeadlineNanos(
const AChoreographerFrameCallbackData* data, size_t index) {
@@ -668,8 +665,8 @@
AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data);
LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(),
"Data is only valid in callback");
- LOG_ALWAYS_FATAL_IF(index >= frameCallbackData->frameTimelines.size(), "Index out of bounds");
- return frameCallbackData->frameTimelines[index].deadlineTimestamp;
+ LOG_ALWAYS_FATAL_IF(index >= VsyncEventData::kFrameTimelinesLength, "Index out of bounds");
+ return frameCallbackData->vsyncEventData.frameTimelines[index].deadlineTimestamp;
}
AChoreographer* AChoreographer_create() {