At a quick glance, one could easily think of the "engine_time" as the
GPU thread time and the "frame_time" as the UI thread time because the
GPU thread time is mainly spent on the engine while the UI thread time
is mainly spent on the Dart framework to generate the frame.
But it's actually the other way. The "engine_time" is UI thread time and
the "frame_time" is the GPU thread time.
To avoid the confusion, rename them to "ui_time" and "raster_time"
respectively. I avoided the "gpu_time" because the rasterization may be
purely on a CPU backed software Skia backend.
Cache a SkSurface with previously drawn shapes so that we do not need to draw them again in future frames.
On Nexus 5X test device, old render time for just the overlay was 1.3ms-3.0ms and this version improves to 0.9ms-1.3ms running flutter gallery in profile mode.
1. Mark perf overlay path as volatile
2. Set sample_margin_width = 0 to get a bar graph instead of saw-tooth.
Previously, the perf overlay itself could be a significant performance
hit and that makes it difficult to profile flutter app.
- fix dartdocs for addPerformanceOverlay
- make PerformanceOverlayLayer honour its x, y, and height.
- fix the y axis of PerformanceOverlayLayer to only show 3x16ms, since
if it's more than 16ms it really doesn't matter what it is.
- make the label on the PerformanceOverlayLayer show the worst time on
record not the instantaneous time.
- pin the fps to a maximum of 60Hz