EGL: Use frameId instead of framesAgo for frame events.
Using a frameId allows an app to poll for timestamps
from a thread other than the swapping thread.
Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*
Change-Id: I3faac0513929837982a2e63f7e0d3d529bd28f10
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index c2ed91a..2e3a7de 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -833,6 +833,9 @@
case NATIVE_WINDOW_SET_AUTO_REFRESH:
res = dispatchSetAutoRefresh(args);
break;
+ case NATIVE_WINDOW_GET_NEXT_FRAME_ID:
+ res = dispatchGetNextFrameId(args);
+ break;
case NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS:
res = dispatchEnableFrameTimestamps(args);
break;
@@ -962,6 +965,12 @@
return setAutoRefresh(autoRefresh);
}
+int Surface::dispatchGetNextFrameId(va_list args) {
+ uint64_t* nextFrameId = va_arg(args, uint64_t*);
+ *nextFrameId = getNextFrameNumber();
+ return NO_ERROR;
+}
+
int Surface::dispatchEnableFrameTimestamps(va_list args) {
bool enable = va_arg(args, int);
enableFrameTimestamps(enable);
@@ -969,7 +978,7 @@
}
int Surface::dispatchGetFrameTimestamps(va_list args) {
- uint32_t framesAgo = va_arg(args, uint32_t);
+ uint64_t frameId = va_arg(args, uint64_t);
nsecs_t* outRequestedPresentTime = va_arg(args, int64_t*);
nsecs_t* outAcquireTime = va_arg(args, int64_t*);
nsecs_t* outLatchTime = va_arg(args, int64_t*);
@@ -980,7 +989,7 @@
nsecs_t* outDisplayRetireTime = va_arg(args, int64_t*);
nsecs_t* outDequeueReadyTime = va_arg(args, int64_t*);
nsecs_t* outReleaseTime = va_arg(args, int64_t*);
- return getFrameTimestamps(getNextFrameNumber() - 1 - framesAgo,
+ return getFrameTimestamps(frameId,
outRequestedPresentTime, outAcquireTime, outLatchTime,
outFirstRefreshStartTime, outLastRefreshStartTime,
outGlCompositionDoneTime, outDisplayPresentTime,