diff options
author | Jamie Gennis <jgennis@google.com> | 2012-11-08 19:23:28 -0800 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2012-11-19 17:45:09 -0800 |
commit | 82dbc7429f5f9f2b303b31dc5b9f2bfd1bbe6add (patch) | |
tree | 34e41a744b71b39132f5542872aac952c2c2a829 /libs/ui/Fence.cpp | |
parent | e64b38fad2cc6686fb6691aaf65c735f505a49a5 (diff) | |
download | frameworks_native-82dbc7429f5f9f2b303b31dc5b9f2bfd1bbe6add.zip frameworks_native-82dbc7429f5f9f2b303b31dc5b9f2bfd1bbe6add.tar.gz frameworks_native-82dbc7429f5f9f2b303b31dc5b9f2bfd1bbe6add.tar.bz2 |
SurfaceFlinger: refactor frame time tracking
This change moves the frame time history tracking code out of Layer and into a
new class called FrameTracker. It also changes the tracking to use signal
timestamps from fences when available for more accurate results.
Change-Id: I323c5f075c58bf86ce363b52af885ad0f6365f2b
Diffstat (limited to 'libs/ui/Fence.cpp')
-rw-r--r-- | libs/ui/Fence.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp index d214b97..84f5a47 100644 --- a/libs/ui/Fence.cpp +++ b/libs/ui/Fence.cpp @@ -18,6 +18,9 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 + // This is needed for stdint.h to define INT64_MAX in C++ + #define __STDC_LIMIT_MACROS + #include <sync/sync.h> #include <ui/Fence.h> #include <unistd.h> @@ -86,6 +89,32 @@ int Fence::dup() const { return ::dup(mFenceFd); } +nsecs_t Fence::getSignalTime() const { + if (mFenceFd == -1) { + return -1; + } + + struct sync_fence_info_data* finfo = sync_fence_info(mFenceFd); + if (finfo == NULL) { + ALOGE("sync_fence_info returned NULL for fd %d", mFenceFd); + return -1; + } + if (finfo->status != 1) { + return INT64_MAX; + } + + struct sync_pt_info* pinfo = NULL; + uint64_t timestamp = 0; + while ((pinfo = sync_pt_info(finfo, pinfo)) != NULL) { + if (pinfo->timestamp_ns > timestamp) { + timestamp = pinfo->timestamp_ns; + } + } + sync_fence_info_free(finfo); + + return nsecs_t(timestamp); +} + size_t Fence::getFlattenedSize() const { return 0; } |