Add displayPresentTime to getFrameTimestamps
Makes HWC1 use displayRetireTime and HWC2 use
displayPresentTime.
Properly takes into account if HWC2On1Adapter is used.
Returns whether present or retire is supported via
eglQueryTimestampSupportedANDROID, which uses a
cached answer in Surface.
Surface::getFrameTimestamps returns with an error
if the caller requests an unsupported timestamp.
Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*
Change-Id: Ib91c2d05d7fb5cbf307e2dec1e20e79bcc19d90b
diff --git a/include/gui/Surface.h b/include/gui/Surface.h
index 470992c..aa5657f 100644
--- a/include/gui/Surface.h
+++ b/include/gui/Surface.h
@@ -135,10 +135,11 @@
sp<Fence>* outFence, float outTransformMatrix[16]);
// See IGraphicBufferProducer::getFrameTimestamps
- bool getFrameTimestamps(uint64_t frameNumber,
+ status_t getFrameTimestamps(uint64_t frameNumber,
nsecs_t* outRequestedPresentTime, nsecs_t* outAcquireTime,
nsecs_t* outRefreshStartTime, nsecs_t* outGlCompositionDoneTime,
- nsecs_t* outDisplayRetireTime, nsecs_t* outReleaseTime);
+ nsecs_t* outDisplayPresentTime, nsecs_t* outDisplayRetireTime,
+ nsecs_t* outReleaseTime);
status_t getUniqueId(uint64_t* outId) const;
@@ -238,6 +239,8 @@
enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
private:
+ void querySupportedTimestampsLocked() const;
+
void freeAllBuffers();
int getSlotFromBufferLocked(android_native_buffer_t* buffer) const;
@@ -380,6 +383,11 @@
Condition mQueueBufferCondition;
uint64_t mNextFrameNumber;
+
+ // Mutable because ANativeWindow::query needs this class const.
+ mutable bool mQueriedSupportedTimestamps;
+ mutable bool mFrameTimestampsSupportsPresent;
+ mutable bool mFrameTimestampsSupportsRetire;
};
namespace view {