Loading core/java/android/view/FrameMetrics.java +1 −1 Original line number Diff line number Diff line Loading @@ -220,7 +220,7 @@ public final class FrameMetrics { int SWAP_BUFFERS = 12; int FRAME_COMPLETED = 13; int FRAME_STATS_COUNT = 16; // must always be last int FRAME_STATS_COUNT = 17; // must always be last } /* Loading core/proto/android/service/graphicsstats.proto +3 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ message GraphicsStatsProto { // The frame time histogram for the package. repeated GraphicsStatsHistogramBucketProto histogram = 6; // The gpu frame time histogram for the package repeated GraphicsStatsHistogramBucketProto gpu_histogram = 7; } message GraphicsStatsJankSummaryProto { Loading libs/hwui/FrameInfo.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -37,13 +37,14 @@ const std::string FrameInfoNames[] = { "FrameCompleted", "DequeueBufferDuration", "QueueBufferDuration", "GpuCompleted", }; static_assert((sizeof(FrameInfoNames) / sizeof(FrameInfoNames[0])) == static_cast<int>(FrameInfoIndex::NumIndexes), "size mismatch: FrameInfoNames doesn't match the enum!"); static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 16, static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 17, "Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)"); void FrameInfo::importUiThreadInfo(int64_t* info) { Loading libs/hwui/FrameInfo.h +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 { Loading libs/hwui/JankTracker.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -232,5 +232,13 @@ void JankTracker::reset() { : FrameInfoIndex::IntendedVsync; } void JankTracker::finishGpuDraw(const FrameInfo& frame) { int64_t totalGPUDrawTime = frame.gpuDrawTime(); if (totalGPUDrawTime >= 0) { mData->reportGPUFrame(totalGPUDrawTime); (*mGlobalData)->reportGPUFrame(totalGPUDrawTime); } } } /* namespace uirenderer */ } /* namespace android */ Loading
core/java/android/view/FrameMetrics.java +1 −1 Original line number Diff line number Diff line Loading @@ -220,7 +220,7 @@ public final class FrameMetrics { int SWAP_BUFFERS = 12; int FRAME_COMPLETED = 13; int FRAME_STATS_COUNT = 16; // must always be last int FRAME_STATS_COUNT = 17; // must always be last } /* Loading
core/proto/android/service/graphicsstats.proto +3 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ message GraphicsStatsProto { // The frame time histogram for the package. repeated GraphicsStatsHistogramBucketProto histogram = 6; // The gpu frame time histogram for the package repeated GraphicsStatsHistogramBucketProto gpu_histogram = 7; } message GraphicsStatsJankSummaryProto { Loading
libs/hwui/FrameInfo.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -37,13 +37,14 @@ const std::string FrameInfoNames[] = { "FrameCompleted", "DequeueBufferDuration", "QueueBufferDuration", "GpuCompleted", }; static_assert((sizeof(FrameInfoNames) / sizeof(FrameInfoNames[0])) == static_cast<int>(FrameInfoIndex::NumIndexes), "size mismatch: FrameInfoNames doesn't match the enum!"); static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 16, static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 17, "Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)"); void FrameInfo::importUiThreadInfo(int64_t* info) { Loading
libs/hwui/FrameInfo.h +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 { Loading
libs/hwui/JankTracker.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -232,5 +232,13 @@ void JankTracker::reset() { : FrameInfoIndex::IntendedVsync; } void JankTracker::finishGpuDraw(const FrameInfo& frame) { int64_t totalGPUDrawTime = frame.gpuDrawTime(); if (totalGPUDrawTime >= 0) { mData->reportGPUFrame(totalGPUDrawTime); (*mGlobalData)->reportGPUFrame(totalGPUDrawTime); } } } /* namespace uirenderer */ } /* namespace android */