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

Commit ed816e6c authored by Brian Anderson's avatar Brian Anderson
Browse files

Add FrameEvents::isValidTimestamp

Refactor only.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I86653ac14186ca509f58a94047f25a7b74231b30
parent b04c6f03
Loading
Loading
Loading
Loading
+22 −16
Original line number Original line Diff line number Diff line
@@ -52,6 +52,16 @@ enum class FrameEvent {


// A collection of timestamps corresponding to a single frame.
// A collection of timestamps corresponding to a single frame.
struct FrameEvents {
struct FrameEvents {
    static constexpr auto EVENT_COUNT =
            static_cast<size_t>(FrameEvent::EVENT_COUNT);
    static_assert(EVENT_COUNT <= 32, "Event count sanity check failed.");
    static constexpr nsecs_t TIMESTAMP_PENDING =
            std::numeric_limits<nsecs_t>::max();

    static inline bool isValidTimestamp(nsecs_t time) {
        return time != TIMESTAMP_PENDING;
    }

    bool hasPostedInfo() const;
    bool hasPostedInfo() const;
    bool hasRequestedPresentInfo() const;
    bool hasRequestedPresentInfo() const;
    bool hasLatchInfo() const;
    bool hasLatchInfo() const;
@@ -67,10 +77,6 @@ struct FrameEvents {
    void checkFencesForCompletion();
    void checkFencesForCompletion();
    void dump(String8& outString) const;
    void dump(String8& outString) const;


    static constexpr size_t EVENT_COUNT =
            static_cast<size_t>(FrameEvent::EVENT_COUNT);
    static_assert(EVENT_COUNT <= 32, "Event count sanity check failed.");

    bool valid{false};
    bool valid{false};
    uint64_t frameNumber{0};
    uint64_t frameNumber{0};


@@ -81,12 +87,12 @@ struct FrameEvents {
    bool addRetireCalled{false};
    bool addRetireCalled{false};
    bool addReleaseCalled{false};
    bool addReleaseCalled{false};


    nsecs_t postedTime{-1};
    nsecs_t postedTime{TIMESTAMP_PENDING};
    nsecs_t requestedPresentTime{-1};
    nsecs_t requestedPresentTime{TIMESTAMP_PENDING};
    nsecs_t latchTime{-1};
    nsecs_t latchTime{TIMESTAMP_PENDING};
    nsecs_t firstRefreshStartTime{-1};
    nsecs_t firstRefreshStartTime{TIMESTAMP_PENDING};
    nsecs_t lastRefreshStartTime{-1};
    nsecs_t lastRefreshStartTime{TIMESTAMP_PENDING};
    nsecs_t dequeueReadyTime{-1};
    nsecs_t dequeueReadyTime{TIMESTAMP_PENDING};


    std::shared_ptr<FenceTime> acquireFence{FenceTime::NO_FENCE};
    std::shared_ptr<FenceTime> acquireFence{FenceTime::NO_FENCE};
    std::shared_ptr<FenceTime> gpuCompositionDoneFence{FenceTime::NO_FENCE};
    std::shared_ptr<FenceTime> gpuCompositionDoneFence{FenceTime::NO_FENCE};
@@ -273,12 +279,12 @@ private:
    bool mAddRetireCalled{0};
    bool mAddRetireCalled{0};
    bool mAddReleaseCalled{0};
    bool mAddReleaseCalled{0};


    nsecs_t mPostedTime{0};
    nsecs_t mPostedTime{FrameEvents::TIMESTAMP_PENDING};
    nsecs_t mRequestedPresentTime{0};
    nsecs_t mRequestedPresentTime{FrameEvents::TIMESTAMP_PENDING};
    nsecs_t mLatchTime{0};
    nsecs_t mLatchTime{FrameEvents::TIMESTAMP_PENDING};
    nsecs_t mFirstRefreshStartTime{0};
    nsecs_t mFirstRefreshStartTime{FrameEvents::TIMESTAMP_PENDING};
    nsecs_t mLastRefreshStartTime{0};
    nsecs_t mLastRefreshStartTime{FrameEvents::TIMESTAMP_PENDING};
    nsecs_t mDequeueReadyTime{0};
    nsecs_t mDequeueReadyTime{FrameEvents::TIMESTAMP_PENDING};


    FenceTime::Snapshot mGpuCompositionDoneFence;
    FenceTime::Snapshot mGpuCompositionDoneFence;
    FenceTime::Snapshot mDisplayPresentFence;
    FenceTime::Snapshot mDisplayPresentFence;
+10 −10
Original line number Original line Diff line number Diff line
@@ -35,19 +35,19 @@ namespace android {
// ============================================================================
// ============================================================================


bool FrameEvents::hasPostedInfo() const {
bool FrameEvents::hasPostedInfo() const {
    return Fence::isValidTimestamp(postedTime);
    return FrameEvents::isValidTimestamp(postedTime);
}
}


bool FrameEvents::hasRequestedPresentInfo() const {
bool FrameEvents::hasRequestedPresentInfo() const {
    return Fence::isValidTimestamp(requestedPresentTime);
    return FrameEvents::isValidTimestamp(requestedPresentTime);
}
}


bool FrameEvents::hasLatchInfo() const {
bool FrameEvents::hasLatchInfo() const {
    return Fence::isValidTimestamp(latchTime);
    return FrameEvents::isValidTimestamp(latchTime);
}
}


bool FrameEvents::hasFirstRefreshStartInfo() const {
bool FrameEvents::hasFirstRefreshStartInfo() const {
    return Fence::isValidTimestamp(firstRefreshStartTime);
    return FrameEvents::isValidTimestamp(firstRefreshStartTime);
}
}


bool FrameEvents::hasLastRefreshStartInfo() const {
bool FrameEvents::hasLastRefreshStartInfo() const {
@@ -58,7 +58,7 @@ bool FrameEvents::hasLastRefreshStartInfo() const {
}
}


bool FrameEvents::hasDequeueReadyInfo() const {
bool FrameEvents::hasDequeueReadyInfo() const {
    return Fence::isValidTimestamp(dequeueReadyTime);
    return FrameEvents::isValidTimestamp(dequeueReadyTime);
}
}


bool FrameEvents::hasAcquireInfo() const {
bool FrameEvents::hasAcquireInfo() const {
@@ -119,21 +119,21 @@ void FrameEvents::dump(String8& outString) const
    outString.appendFormat("--- Req. Present\t%" PRId64 "\n", requestedPresentTime);
    outString.appendFormat("--- Req. Present\t%" PRId64 "\n", requestedPresentTime);


    outString.appendFormat("--- Latched     \t");
    outString.appendFormat("--- Latched     \t");
    if (Fence::isValidTimestamp(latchTime)) {
    if (FrameEvents::isValidTimestamp(latchTime)) {
        outString.appendFormat("%" PRId64 "\n", latchTime);
        outString.appendFormat("%" PRId64 "\n", latchTime);
    } else {
    } else {
        outString.appendFormat("Pending\n");
        outString.appendFormat("Pending\n");
    }
    }


    outString.appendFormat("--- Refresh (First)\t");
    outString.appendFormat("--- Refresh (First)\t");
    if (Fence::isValidTimestamp(firstRefreshStartTime)) {
    if (FrameEvents::isValidTimestamp(firstRefreshStartTime)) {
        outString.appendFormat("%" PRId64 "\n", firstRefreshStartTime);
        outString.appendFormat("%" PRId64 "\n", firstRefreshStartTime);
    } else {
    } else {
        outString.appendFormat("Pending\n");
        outString.appendFormat("Pending\n");
    }
    }


    outString.appendFormat("--- Refresh (Last)\t");
    outString.appendFormat("--- Refresh (Last)\t");
    if (Fence::isValidTimestamp(lastRefreshStartTime)) {
    if (FrameEvents::isValidTimestamp(lastRefreshStartTime)) {
        outString.appendFormat("%" PRId64 "\n", lastRefreshStartTime);
        outString.appendFormat("%" PRId64 "\n", lastRefreshStartTime);
    } else {
    } else {
        outString.appendFormat("Pending\n");
        outString.appendFormat("Pending\n");
@@ -149,7 +149,7 @@ void FrameEvents::dump(String8& outString) const
            !addRetireCalled, *displayRetireFence);
            !addRetireCalled, *displayRetireFence);


    outString.appendFormat("--- DequeueReady  \t");
    outString.appendFormat("--- DequeueReady  \t");
    if (Fence::isValidTimestamp(dequeueReadyTime)) {
    if (FrameEvents::isValidTimestamp(dequeueReadyTime)) {
        outString.appendFormat("%" PRId64 "\n", dequeueReadyTime);
        outString.appendFormat("%" PRId64 "\n", dequeueReadyTime);
    } else {
    } else {
        outString.appendFormat("Pending\n");
        outString.appendFormat("Pending\n");
@@ -408,7 +408,7 @@ void ConsumerFrameEventHistory::addPreComposition(
    }
    }
    frame->lastRefreshStartTime = refreshStartTime;
    frame->lastRefreshStartTime = refreshStartTime;
    mFramesDirty[mCompositionOffset].setDirty<FrameEvent::LAST_REFRESH_START>();
    mFramesDirty[mCompositionOffset].setDirty<FrameEvent::LAST_REFRESH_START>();
    if (!Fence::isValidTimestamp(frame->firstRefreshStartTime)) {
    if (!FrameEvents::isValidTimestamp(frame->firstRefreshStartTime)) {
        frame->firstRefreshStartTime = refreshStartTime;
        frame->firstRefreshStartTime = refreshStartTime;
        mFramesDirty[mCompositionOffset].setDirty<FrameEvent::FIRST_REFRESH_START>();
        mFramesDirty[mCompositionOffset].setDirty<FrameEvent::FIRST_REFRESH_START>();
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -230,7 +230,7 @@ static bool checkConsumerForUpdates(


static void getFrameTimestamp(nsecs_t *dst, const nsecs_t& src) {
static void getFrameTimestamp(nsecs_t *dst, const nsecs_t& src) {
    if (dst != nullptr) {
    if (dst != nullptr) {
        *dst = Fence::isValidTimestamp(src) ? src : 0;
        *dst = FrameEvents::isValidTimestamp(src) ? src : 0;
    }
    }
}
}