diff options
Diffstat (limited to 'libs/hwui/FrameInfo.h')
-rw-r--r-- | libs/hwui/FrameInfo.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libs/hwui/FrameInfo.h b/libs/hwui/FrameInfo.h index b75192ff8476..51674fbd557e 100644 --- a/libs/hwui/FrameInfo.h +++ b/libs/hwui/FrameInfo.h @@ -51,6 +51,8 @@ enum class FrameInfoIndex { DequeueBufferDuration, QueueBufferDuration, + GpuCompleted, + // Must be the last value! // Also must be kept in sync with FrameMetrics.java#FRAME_STATS_COUNT NumIndexes @@ -143,6 +145,13 @@ public: return duration(FrameInfoIndex::IntendedVsync, FrameInfoIndex::FrameCompleted); } + inline int64_t gpuDrawTime() const { + // GPU start time is approximated to the moment before swapBuffer is invoked. + // We could add an EGLSyncKHR fence at the beginning of the frame, but that is an overhead. + int64_t endTime = get(FrameInfoIndex::GpuCompleted); + return endTime > 0 ? endTime - get(FrameInfoIndex::SwapBuffers) : -1; + } + inline int64_t& set(FrameInfoIndex index) { return mFrameInfo[static_cast<int>(index)]; } inline int64_t get(FrameInfoIndex index) const { |