|
14 | 14 |
|
15 | 15 | namespace flutter {
|
16 | 16 |
|
| 17 | +/// Records timestamps for various phases of a frame rendering process. |
| 18 | +/// |
| 19 | +/// Recorder is created on vsync and destroyed after the rasterization of the |
| 20 | +/// frame. |
17 | 21 | class FrameTimingsRecorder {
|
18 | 22 | public:
|
| 23 | + /// Various states that the recorder can be in. When created the recorder is |
| 24 | + /// in an unitialized state and transtions in sequential order of the states. |
19 | 25 | enum class State : uint32_t {
|
20 |
| - kUnitialized = 1, |
| 26 | + kUninitialized = 1, |
21 | 27 | kVsync = 2,
|
22 | 28 | kBuildStart = 3,
|
23 | 29 | kBuildEnd = 4,
|
24 | 30 | kRasterStart = 5,
|
25 | 31 | kRasterEnd = 6,
|
26 | 32 | };
|
27 | 33 |
|
| 34 | + /// Default constructor, initializes the recorder with State::kUninitialized. |
28 | 35 | FrameTimingsRecorder();
|
29 | 36 |
|
30 | 37 | ~FrameTimingsRecorder();
|
31 | 38 |
|
| 39 | + /// Timestamp of the vsync signal. |
32 | 40 | fml::TimePoint GetVsyncStartTime() const;
|
33 | 41 |
|
| 42 | + /// Timestamp of when the frame was targeted to be presented. |
| 43 | + /// |
| 44 | + /// This is typically the next vsync signal timestamp. |
34 | 45 | fml::TimePoint GetVsyncTargetTime() const;
|
35 | 46 |
|
| 47 | + /// Timestamp of when the frame building started. |
36 | 48 | fml::TimePoint GetBuildStartTime() const;
|
37 | 49 |
|
| 50 | + /// Timestamp of when the frame was finished building. |
38 | 51 | fml::TimePoint GetBuildEndTime() const;
|
39 | 52 |
|
| 53 | + /// Timestamp of when the frame rasterization started. |
40 | 54 | fml::TimePoint GetRasterStartTime() const;
|
41 | 55 |
|
| 56 | + /// Timestamp of when the frame rasterization finished. |
42 | 57 | fml::TimePoint GetRasterEndTime() const;
|
43 | 58 |
|
| 59 | + /// Duration of the frame build time. |
44 | 60 | fml::TimeDelta GetBuildDuration() const;
|
45 | 61 |
|
| 62 | + /// Records a vsync event. |
46 | 63 | void RecordVsync(fml::TimePoint vsync_start, fml::TimePoint vsync_target);
|
47 | 64 |
|
| 65 | + /// Records a build start event. |
48 | 66 | void RecordBuildStart(fml::TimePoint build_start);
|
49 | 67 |
|
| 68 | + /// Records a build end event. |
50 | 69 | void RecordBuildEnd(fml::TimePoint build_end);
|
51 | 70 |
|
| 71 | + /// Records a raster start event. |
52 | 72 | void RecordRasterStart(fml::TimePoint raster_start);
|
53 | 73 |
|
| 74 | + /// Clones the recorder until (and including) the specified state. |
54 | 75 | std::unique_ptr<FrameTimingsRecorder> CloneUntil(State state);
|
55 | 76 |
|
| 77 | + /// Records a raster end event, and builds a `FrameTiming` that summarizes all |
| 78 | + /// the events. This summary is sent to the framework. |
56 | 79 | FrameTiming RecordRasterEnd(fml::TimePoint raster_end);
|
57 | 80 |
|
58 | 81 | private:
|
59 | 82 | mutable std::mutex state_mutex_;
|
60 |
| - State state_ = State::kUnitialized; |
| 83 | + State state_ = State::kUninitialized; |
61 | 84 |
|
62 | 85 | fml::TimePoint vsync_start_ = fml::TimePoint::Min();
|
63 | 86 | fml::TimePoint vsync_target_ = fml::TimePoint::Min();
|
|
0 commit comments