Change hwui jank detection to use deadline & gpu completion (1/2)

- Use GPU finish time as well as actual deadline to determine jank
rate.
- Use dynamic interval to adjust for 60/90hz switching
- Move frame metrics reporting into JankTracker to adjust the
deadline communicated to the app when in stuffing scenario.
- Adjust double-stuffing detection to be a bit more readable.

Test: GraphicsStatsValidationTest.java
Test: adb shell dumpsys gfxinfo
Test: FrameMetricsListenerTest
Test: Log output of FrameMetricsObserver
Bug: 169858044
Change-Id: I3a6b8ed163e2cf9cf2b67667110340ebe35f98a1
diff --git a/libs/hwui/ProfileData.h b/libs/hwui/ProfileData.h
index dd3ba66..9be194c 100644
--- a/libs/hwui/ProfileData.h
+++ b/libs/hwui/ProfileData.h
@@ -35,6 +35,7 @@
     kSlowSync,
     kSlowRT,
     kMissedDeadline,
+    kMissedDeadlineLegacy,
 
     // must be last
     NUM_BUCKETS,
@@ -60,10 +61,12 @@
     void reportFrame(int64_t duration);
     void reportGPUFrame(int64_t duration);
     void reportJank() { mJankFrameCount++; }
+    void reportJankLegacy() { mJankLegacyFrameCount++; }
     void reportJankType(JankType type) { mJankTypeCounts[static_cast<int>(type)]++; }
 
     uint32_t totalFrameCount() const { return mTotalFrameCount; }
     uint32_t jankFrameCount() const { return mJankFrameCount; }
+    uint32_t jankLegacyFrameCount() const { return mJankLegacyFrameCount; }
     nsecs_t statsStartTime() const { return mStatStartTime; }
     uint32_t jankTypeCount(JankType type) const { return mJankTypeCounts[static_cast<int>(type)]; }
     RenderPipelineType pipelineType() const { return mPipelineType; }
@@ -104,6 +107,7 @@
 
     uint32_t mTotalFrameCount;
     uint32_t mJankFrameCount;
+    uint32_t mJankLegacyFrameCount;
     nsecs_t mStatStartTime;
 
     // true if HWUI renders with Vulkan pipeline