Add FrameEvents::isValidTimestamp
Refactor only.
Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*
Change-Id: I86653ac14186ca509f58a94047f25a7b74231b30
diff --git a/include/gui/FrameTimestamps.h b/include/gui/FrameTimestamps.h
index 174c5ea..0c4af46 100644
--- a/include/gui/FrameTimestamps.h
+++ b/include/gui/FrameTimestamps.h
@@ -52,6 +52,16 @@
// A collection of timestamps corresponding to a single frame.
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 hasRequestedPresentInfo() const;
bool hasLatchInfo() const;
@@ -67,10 +77,6 @@
void checkFencesForCompletion();
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};
uint64_t frameNumber{0};
@@ -81,12 +87,12 @@
bool addRetireCalled{false};
bool addReleaseCalled{false};
- nsecs_t postedTime{-1};
- nsecs_t requestedPresentTime{-1};
- nsecs_t latchTime{-1};
- nsecs_t firstRefreshStartTime{-1};
- nsecs_t lastRefreshStartTime{-1};
- nsecs_t dequeueReadyTime{-1};
+ nsecs_t postedTime{TIMESTAMP_PENDING};
+ nsecs_t requestedPresentTime{TIMESTAMP_PENDING};
+ nsecs_t latchTime{TIMESTAMP_PENDING};
+ nsecs_t firstRefreshStartTime{TIMESTAMP_PENDING};
+ nsecs_t lastRefreshStartTime{TIMESTAMP_PENDING};
+ nsecs_t dequeueReadyTime{TIMESTAMP_PENDING};
std::shared_ptr<FenceTime> acquireFence{FenceTime::NO_FENCE};
std::shared_ptr<FenceTime> gpuCompositionDoneFence{FenceTime::NO_FENCE};
@@ -273,12 +279,12 @@
bool mAddRetireCalled{0};
bool mAddReleaseCalled{0};
- nsecs_t mPostedTime{0};
- nsecs_t mRequestedPresentTime{0};
- nsecs_t mLatchTime{0};
- nsecs_t mFirstRefreshStartTime{0};
- nsecs_t mLastRefreshStartTime{0};
- nsecs_t mDequeueReadyTime{0};
+ nsecs_t mPostedTime{FrameEvents::TIMESTAMP_PENDING};
+ nsecs_t mRequestedPresentTime{FrameEvents::TIMESTAMP_PENDING};
+ nsecs_t mLatchTime{FrameEvents::TIMESTAMP_PENDING};
+ nsecs_t mFirstRefreshStartTime{FrameEvents::TIMESTAMP_PENDING};
+ nsecs_t mLastRefreshStartTime{FrameEvents::TIMESTAMP_PENDING};
+ nsecs_t mDequeueReadyTime{FrameEvents::TIMESTAMP_PENDING};
FenceTime::Snapshot mGpuCompositionDoneFence;
FenceTime::Snapshot mDisplayPresentFence;
diff --git a/libs/gui/FrameTimestamps.cpp b/libs/gui/FrameTimestamps.cpp
index f11ffdd..f427e68 100644
--- a/libs/gui/FrameTimestamps.cpp
+++ b/libs/gui/FrameTimestamps.cpp
@@ -35,19 +35,19 @@
// ============================================================================
bool FrameEvents::hasPostedInfo() const {
- return Fence::isValidTimestamp(postedTime);
+ return FrameEvents::isValidTimestamp(postedTime);
}
bool FrameEvents::hasRequestedPresentInfo() const {
- return Fence::isValidTimestamp(requestedPresentTime);
+ return FrameEvents::isValidTimestamp(requestedPresentTime);
}
bool FrameEvents::hasLatchInfo() const {
- return Fence::isValidTimestamp(latchTime);
+ return FrameEvents::isValidTimestamp(latchTime);
}
bool FrameEvents::hasFirstRefreshStartInfo() const {
- return Fence::isValidTimestamp(firstRefreshStartTime);
+ return FrameEvents::isValidTimestamp(firstRefreshStartTime);
}
bool FrameEvents::hasLastRefreshStartInfo() const {
@@ -58,7 +58,7 @@
}
bool FrameEvents::hasDequeueReadyInfo() const {
- return Fence::isValidTimestamp(dequeueReadyTime);
+ return FrameEvents::isValidTimestamp(dequeueReadyTime);
}
bool FrameEvents::hasAcquireInfo() const {
@@ -119,21 +119,21 @@
outString.appendFormat("--- Req. Present\t%" PRId64 "\n", requestedPresentTime);
outString.appendFormat("--- Latched \t");
- if (Fence::isValidTimestamp(latchTime)) {
+ if (FrameEvents::isValidTimestamp(latchTime)) {
outString.appendFormat("%" PRId64 "\n", latchTime);
} else {
outString.appendFormat("Pending\n");
}
outString.appendFormat("--- Refresh (First)\t");
- if (Fence::isValidTimestamp(firstRefreshStartTime)) {
+ if (FrameEvents::isValidTimestamp(firstRefreshStartTime)) {
outString.appendFormat("%" PRId64 "\n", firstRefreshStartTime);
} else {
outString.appendFormat("Pending\n");
}
outString.appendFormat("--- Refresh (Last)\t");
- if (Fence::isValidTimestamp(lastRefreshStartTime)) {
+ if (FrameEvents::isValidTimestamp(lastRefreshStartTime)) {
outString.appendFormat("%" PRId64 "\n", lastRefreshStartTime);
} else {
outString.appendFormat("Pending\n");
@@ -149,7 +149,7 @@
!addRetireCalled, *displayRetireFence);
outString.appendFormat("--- DequeueReady \t");
- if (Fence::isValidTimestamp(dequeueReadyTime)) {
+ if (FrameEvents::isValidTimestamp(dequeueReadyTime)) {
outString.appendFormat("%" PRId64 "\n", dequeueReadyTime);
} else {
outString.appendFormat("Pending\n");
@@ -408,7 +408,7 @@
}
frame->lastRefreshStartTime = refreshStartTime;
mFramesDirty[mCompositionOffset].setDirty<FrameEvent::LAST_REFRESH_START>();
- if (!Fence::isValidTimestamp(frame->firstRefreshStartTime)) {
+ if (!FrameEvents::isValidTimestamp(frame->firstRefreshStartTime)) {
frame->firstRefreshStartTime = refreshStartTime;
mFramesDirty[mCompositionOffset].setDirty<FrameEvent::FIRST_REFRESH_START>();
}
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 45bf8c8..efb1524 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -230,7 +230,7 @@
static void getFrameTimestamp(nsecs_t *dst, const nsecs_t& src) {
if (dst != nullptr) {
- *dst = Fence::isValidTimestamp(src) ? src : 0;
+ *dst = FrameEvents::isValidTimestamp(src) ? src : 0;
}
}