Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c7f6176 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10068852 from d8e3b12b to udc-release

Change-Id: I3f5642961894c28af07516a10fda8bf80459945f
parents b68571a4 d8e3b12b
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@

namespace android::gui {

static_assert(VsyncEventData::kFrameTimelinesLength == 7,
              "Must update value in DisplayEventReceiver.java#FRAME_TIMELINES_LENGTH (and here)");
static_assert(VsyncEventData::kFrameTimelinesCapacity == 7,
              "Must update value in DisplayEventReceiver.java#FRAME_TIMELINES_CAPACITY (and here)");

int64_t VsyncEventData::preferredVsyncId() const {
    return frameTimelines[preferredFrameTimelineIndex].vsyncId;
@@ -46,11 +46,15 @@ status_t ParcelableVsyncEventData::readFromParcel(const Parcel* parcel) {

    SAFE_PARCEL(parcel->readInt64, &vsync.frameInterval);

    uint64_t uintPreferredFrameTimelineIndex;
    SAFE_PARCEL(parcel->readUint64, &uintPreferredFrameTimelineIndex);
    uint32_t uintPreferredFrameTimelineIndex;
    SAFE_PARCEL(parcel->readUint32, &uintPreferredFrameTimelineIndex);
    vsync.preferredFrameTimelineIndex = static_cast<size_t>(uintPreferredFrameTimelineIndex);

    for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
    uint32_t uintFrameTimelinesLength;
    SAFE_PARCEL(parcel->readUint32, &uintFrameTimelinesLength);
    vsync.frameTimelinesLength = static_cast<size_t>(uintFrameTimelinesLength);

    for (size_t i = 0; i < vsync.frameTimelinesLength; i++) {
        SAFE_PARCEL(parcel->readInt64, &vsync.frameTimelines[i].vsyncId);
        SAFE_PARCEL(parcel->readInt64, &vsync.frameTimelines[i].deadlineTimestamp);
        SAFE_PARCEL(parcel->readInt64, &vsync.frameTimelines[i].expectedPresentationTime);
@@ -60,8 +64,9 @@ status_t ParcelableVsyncEventData::readFromParcel(const Parcel* parcel) {
}
status_t ParcelableVsyncEventData::writeToParcel(Parcel* parcel) const {
    SAFE_PARCEL(parcel->writeInt64, vsync.frameInterval);
    SAFE_PARCEL(parcel->writeUint64, vsync.preferredFrameTimelineIndex);
    for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
    SAFE_PARCEL(parcel->writeUint32, vsync.preferredFrameTimelineIndex);
    SAFE_PARCEL(parcel->writeUint32, vsync.frameTimelinesLength);
    for (size_t i = 0; i < vsync.frameTimelinesLength; i++) {
        SAFE_PARCEL(parcel->writeInt64, vsync.frameTimelines[i].vsyncId);
        SAFE_PARCEL(parcel->writeInt64, vsync.frameTimelines[i].deadlineTimestamp);
        SAFE_PARCEL(parcel->writeInt64, vsync.frameTimelines[i].expectedPresentationTime);
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ DisplayEventReceiver::Event buildDisplayEvent(FuzzedDataProvider* fdp, uint32_t
            event.vsync.count = fdp->ConsumeIntegral<uint32_t>();
            event.vsync.vsyncData.frameInterval = fdp->ConsumeIntegral<uint64_t>();
            event.vsync.vsyncData.preferredFrameTimelineIndex = fdp->ConsumeIntegral<uint32_t>();
            for (size_t idx = 0; idx < gui::VsyncEventData::kFrameTimelinesLength; ++idx) {
            for (size_t idx = 0; idx < gui::VsyncEventData::kFrameTimelinesCapacity; ++idx) {
                event.vsync.vsyncData.frameTimelines[idx].vsyncId = fdp->ConsumeIntegral<int64_t>();
                event.vsync.vsyncData.frameTimelines[idx].deadlineTimestamp =
                        fdp->ConsumeIntegral<uint64_t>();
+6 −3
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@ namespace android::gui {
// Plain Old Data (POD) vsync data structure. For example, it can be easily used in the
// DisplayEventReceiver::Event union.
struct VsyncEventData {
    // Max amount of frame timelines is arbitrarily set to be reasonable.
    static constexpr int64_t kFrameTimelinesLength = 7;
    // Max capacity of frame timelines is arbitrarily set to be reasonable.
    static constexpr int64_t kFrameTimelinesCapacity = 7;

    // The current frame interval in ns when this frame was scheduled.
    int64_t frameInterval;
@@ -33,6 +33,9 @@ struct VsyncEventData {
    // Index into the frameTimelines that represents the platform's preferred frame timeline.
    uint32_t preferredFrameTimelineIndex;

    // Size of frame timelines provided by the platform; max is kFrameTimelinesCapacity.
    uint32_t frameTimelinesLength;

    struct alignas(8) FrameTimeline {
        // The Vsync Id corresponsing to this vsync event. This will be used to
        // populate ISurfaceComposer::setFrameTimelineVsync and
@@ -45,7 +48,7 @@ struct VsyncEventData {

        // The anticipated Vsync presentation time in nanos.
        int64_t expectedPresentationTime;
    } frameTimelines[kFrameTimelinesLength]; // Sorted possible frame timelines.
    } frameTimelines[kFrameTimelinesCapacity]; // Sorted possible frame timelines.

    // Gets the preferred frame timeline's vsync ID.
    int64_t preferredVsyncId() const;
+5 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ TEST(DisplayEventStructLayoutTest, TestEventAlignment) {
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync, count, 0);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync, vsyncData.frameInterval, 8);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync, vsyncData.preferredFrameTimelineIndex, 16);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync, vsyncData.frameTimelinesLength, 20);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync, vsyncData.frameTimelines, 24);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync, vsyncData.frameTimelines[0].vsyncId, 24);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync, vsyncData.frameTimelines[0].deadlineTimestamp,
@@ -44,16 +45,16 @@ TEST(DisplayEventStructLayoutTest, TestEventAlignment) {
    // Also test the offsets of the last frame timeline. A loop is not used because the non-const
    // index cannot be used in static_assert.
    const int lastFrameTimelineOffset = /* Start of array */ 24 +
            (VsyncEventData::kFrameTimelinesLength - 1) * /* Size of FrameTimeline */ 24;
            (VsyncEventData::kFrameTimelinesCapacity - 1) * /* Size of FrameTimeline */ 24;
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync,
                 vsyncData.frameTimelines[VsyncEventData::kFrameTimelinesLength - 1].vsyncId,
                 vsyncData.frameTimelines[VsyncEventData::kFrameTimelinesCapacity - 1].vsyncId,
                 lastFrameTimelineOffset);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync,
                 vsyncData.frameTimelines[VsyncEventData::kFrameTimelinesLength - 1]
                 vsyncData.frameTimelines[VsyncEventData::kFrameTimelinesCapacity - 1]
                         .deadlineTimestamp,
                 lastFrameTimelineOffset + 8);
    CHECK_OFFSET(DisplayEventReceiver::Event::VSync,
                 vsyncData.frameTimelines[VsyncEventData::kFrameTimelinesLength - 1]
                 vsyncData.frameTimelines[VsyncEventData::kFrameTimelinesCapacity - 1]
                         .expectedPresentationTime,
                 lastFrameTimelineOffset + 16);

+3 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ TEST(ParcelableVsyncEventData, Parcelling) {
    FrameTimeline timeline1 = FrameTimeline{4, 5, 6};
    data.vsync.frameTimelines[0] = timeline0;
    data.vsync.frameTimelines[1] = timeline1;
    data.vsync.frameTimelinesLength = 2;

    Parcel p;
    data.writeToParcel(&p);
@@ -45,7 +46,8 @@ TEST(ParcelableVsyncEventData, Parcelling) {
    data2.readFromParcel(&p);
    ASSERT_EQ(data.vsync.frameInterval, data2.vsync.frameInterval);
    ASSERT_EQ(data.vsync.preferredFrameTimelineIndex, data2.vsync.preferredFrameTimelineIndex);
    for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
    ASSERT_EQ(data.vsync.frameTimelinesLength, data2.vsync.frameTimelinesLength);
    for (int i = 0; i < VsyncEventData::kFrameTimelinesCapacity; i++) {
        ASSERT_EQ(data.vsync.frameTimelines[i].vsyncId, data2.vsync.frameTimelines[i].vsyncId);
        ASSERT_EQ(data.vsync.frameTimelines[i].deadlineTimestamp,
                  data2.vsync.frameTimelines[i].deadlineTimestamp);
Loading