forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompositor_timing_history.h
178 lines (149 loc) · 6.45 KB
/
compositor_timing_history.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_SCHEDULER_COMPOSITOR_TIMING_HISTORY_H_
#define CC_SCHEDULER_COMPOSITOR_TIMING_HISTORY_H_
#include <memory>
#include "base/macros.h"
#include "cc/base/rolling_time_delta_history.h"
#include "cc/cc_export.h"
#include "cc/tiles/tile_priority.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
namespace base {
namespace trace_event {
class TracedValue;
} // namespace trace_event
} // namespace base
namespace cc {
class RenderingStatsInstrumentation;
class CC_EXPORT CompositorTimingHistory {
public:
enum UMACategory {
RENDERER_UMA,
BROWSER_UMA,
NULL_UMA,
};
class UMAReporter;
CompositorTimingHistory(
bool using_synchronous_renderer_compositor,
UMACategory uma_category,
RenderingStatsInstrumentation* rendering_stats_instrumentation);
virtual ~CompositorTimingHistory();
void AsValueInto(base::trace_event::TracedValue* state) const;
// The main thread responsiveness depends heavily on whether or not the
// on_critical_path flag is set, so we record response times separately.
virtual base::TimeDelta BeginMainFrameQueueDurationCriticalEstimate() const;
virtual base::TimeDelta BeginMainFrameQueueDurationNotCriticalEstimate()
const;
virtual base::TimeDelta BeginMainFrameStartToReadyToCommitDurationEstimate()
const;
virtual base::TimeDelta CommitDurationEstimate() const;
virtual base::TimeDelta CommitToReadyToActivateDurationEstimate() const;
virtual base::TimeDelta PrepareTilesDurationEstimate() const;
virtual base::TimeDelta ActivateDurationEstimate() const;
virtual base::TimeDelta DrawDurationEstimate() const;
// State that affects when events should be expected/recorded/reported.
void SetRecordingEnabled(bool enabled);
void DidCreateAndInitializeLayerTreeFrameSink();
// Events to be timed.
void WillBeginImplFrame(bool new_active_tree_is_likely,
base::TimeTicks frame_time,
viz::BeginFrameArgs::BeginFrameArgsType frame_type,
base::TimeTicks now);
void WillFinishImplFrame(bool needs_redraw);
void BeginImplFrameNotExpectedSoon();
void WillBeginMainFrame(bool on_critical_path,
base::TimeTicks main_frame_time);
void BeginMainFrameStarted(base::TimeTicks main_thread_start_time);
void BeginMainFrameAborted();
void NotifyReadyToCommit();
void WillCommit();
void DidCommit();
void WillPrepareTiles();
void DidPrepareTiles();
void ReadyToActivate();
void WillActivate();
void DidActivate();
void DrawAborted();
void WillDraw();
void DidDraw(bool used_new_active_tree,
base::TimeTicks impl_frame_time,
size_t composited_animations_count,
size_t main_thread_animations_count,
size_t main_thread_compositable_animations_count,
bool current_frame_had_raf,
bool next_frame_has_pending_raf);
void DidSubmitCompositorFrame();
void DidReceiveCompositorFrameAck();
void WillInvalidateOnImplSide();
void SetTreePriority(TreePriority priority);
base::TimeTicks begin_main_frame_sent_time() const {
return begin_main_frame_sent_time_;
}
void ClearHistoryOnNavigation();
size_t begin_main_frame_start_to_ready_to_commit_sample_count() const {
return begin_main_frame_start_to_ready_to_commit_duration_history_
.sample_count();
}
size_t commit_to_ready_to_activate_sample_count() const {
return commit_to_ready_to_activate_duration_history_.sample_count();
}
protected:
void DidBeginMainFrame(base::TimeTicks begin_main_frame_end_time);
void SetBeginMainFrameNeededContinuously(bool active);
void SetBeginMainFrameCommittingContinuously(bool active);
void SetCompositorDrawingContinuously(bool active);
static std::unique_ptr<UMAReporter> CreateUMAReporter(UMACategory category);
virtual base::TimeTicks Now() const;
bool using_synchronous_renderer_compositor_;
bool enabled_;
// Used to calculate frame rates of Main and Impl threads.
bool did_send_begin_main_frame_;
bool begin_main_frame_needed_continuously_;
bool begin_main_frame_committing_continuously_;
bool compositor_drawing_continuously_;
base::TimeTicks begin_main_frame_end_time_prev_;
base::TimeTicks new_active_tree_draw_end_time_prev_;
base::TimeTicks new_active_tree_draw_end_time_prev_committing_continuously_;
base::TimeTicks draw_end_time_prev_;
// If you add any history here, please remember to reset it in
// ClearHistoryOnNavigation.
RollingTimeDeltaHistory begin_main_frame_queue_duration_history_;
RollingTimeDeltaHistory begin_main_frame_queue_duration_critical_history_;
RollingTimeDeltaHistory begin_main_frame_queue_duration_not_critical_history_;
RollingTimeDeltaHistory
begin_main_frame_start_to_ready_to_commit_duration_history_;
RollingTimeDeltaHistory commit_duration_history_;
RollingTimeDeltaHistory commit_to_ready_to_activate_duration_history_;
RollingTimeDeltaHistory prepare_tiles_duration_history_;
RollingTimeDeltaHistory activate_duration_history_;
RollingTimeDeltaHistory draw_duration_history_;
bool begin_main_frame_on_critical_path_;
base::TimeTicks begin_main_frame_frame_time_;
base::TimeTicks begin_main_frame_sent_time_;
base::TimeTicks begin_main_frame_start_time_;
base::TimeTicks commit_start_time_;
base::TimeTicks pending_tree_main_frame_time_;
base::TimeTicks pending_tree_creation_time_;
base::TimeTicks pending_tree_ready_to_activate_time_;
base::TimeTicks prepare_tiles_start_time_;
base::TimeTicks activate_start_time_;
base::TimeTicks active_tree_main_frame_time_;
base::TimeTicks draw_start_time_;
base::TimeTicks submit_start_time_;
bool pending_tree_is_impl_side_;
// Watchdog timers.
bool submit_ack_watchdog_enabled_;
std::unique_ptr<UMAReporter> uma_reporter_;
RenderingStatsInstrumentation* rendering_stats_instrumentation_;
// Used only for reporting animation targeted UMA.
bool previous_frame_had_composited_animations_ = false;
bool previous_frame_had_main_thread_animations_ = false;
bool previous_frame_had_main_thread_compositable_animations_ = false;
bool previous_frame_had_raf_ = false;
TreePriority tree_priority_ = SAME_PRIORITY_FOR_BOTH_TREES;
private:
DISALLOW_COPY_AND_ASSIGN(CompositorTimingHistory);
};
} // namespace cc
#endif // CC_SCHEDULER_COMPOSITOR_TIMING_HISTORY_H_