summaryrefslogtreecommitdiff
path: root/libs/hwui/FrameInfo.h
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2019-07-25 13:12:02 -0400
committerStan Iliev <stani@google.com>2019-08-01 18:53:21 +0000
commit7203e1f55a57bf809c3d07a391b82c364fb60b7e (patch)
tree7471929e5b6ed42cb150bbbb9883e64a5e570007 /libs/hwui/FrameInfo.h
parent85a6a5aa3b56749f2f30c442eff8837efb9ebde1 (diff)
Add GPU draw stats to gfxinfo and GraphicsStatsService
Test: ran dumpsys with gfxinfo and graphicsstats Change-Id: Id9950de87dc4343c6878baa6a6dd42fbc8aeddef
Diffstat (limited to 'libs/hwui/FrameInfo.h')
-rw-r--r--libs/hwui/FrameInfo.h9
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 {