Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: cc/scheduler/scheduler.h

Issue 1192663005: cc: Measure compositor timing with finer granularity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@modeTimingHistory3
Patch Set: fixes Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_SCHEDULER_SCHEDULER_H_ 5 #ifndef CC_SCHEDULER_SCHEDULER_H_
6 #define CC_SCHEDULER_SCHEDULER_H_ 6 #define CC_SCHEDULER_SCHEDULER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/cancelable_callback.h" 12 #include "base/cancelable_callback.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
16 #include "cc/output/begin_frame_args.h" 16 #include "cc/output/begin_frame_args.h"
17 #include "cc/output/vsync_parameter_observer.h" 17 #include "cc/output/vsync_parameter_observer.h"
18 #include "cc/scheduler/begin_frame_source.h" 18 #include "cc/scheduler/begin_frame_source.h"
19 #include "cc/scheduler/begin_frame_tracker.h" 19 #include "cc/scheduler/begin_frame_tracker.h"
20 #include "cc/scheduler/compositor_timing_history.h"
20 #include "cc/scheduler/delay_based_time_source.h" 21 #include "cc/scheduler/delay_based_time_source.h"
21 #include "cc/scheduler/draw_result.h" 22 #include "cc/scheduler/draw_result.h"
22 #include "cc/scheduler/scheduler_settings.h" 23 #include "cc/scheduler/scheduler_settings.h"
23 #include "cc/scheduler/scheduler_state_machine.h" 24 #include "cc/scheduler/scheduler_state_machine.h"
24 25
25 namespace base { 26 namespace base {
26 namespace trace_event { 27 namespace trace_event {
27 class ConvertableToTraceFormat; 28 class ConvertableToTraceFormat;
28 } 29 }
29 class SingleThreadTaskRunner; 30 class SingleThreadTaskRunner;
30 } 31 }
31 32
32 namespace cc { 33 namespace cc {
33 34
35 class RenderingStatsInstrumentation;
36
34 class SchedulerClient { 37 class SchedulerClient {
35 public: 38 public:
36 virtual void WillBeginImplFrame(const BeginFrameArgs& args) = 0; 39 virtual void WillBeginImplFrame(const BeginFrameArgs& args) = 0;
37 virtual void ScheduledActionSendBeginMainFrame() = 0; 40 virtual void ScheduledActionSendBeginMainFrame() = 0;
38 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() = 0; 41 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() = 0;
39 virtual DrawResult ScheduledActionDrawAndSwapForced() = 0; 42 virtual DrawResult ScheduledActionDrawAndSwapForced() = 0;
40 virtual void ScheduledActionAnimate() = 0; 43 virtual void ScheduledActionAnimate() = 0;
41 virtual void ScheduledActionCommit() = 0; 44 virtual void ScheduledActionCommit() = 0;
42 virtual void ScheduledActionActivateSyncTree() = 0; 45 virtual void ScheduledActionActivateSyncTree() = 0;
43 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; 46 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0;
44 virtual void ScheduledActionPrepareTiles() = 0; 47 virtual void ScheduledActionPrepareTiles() = 0;
45 virtual void ScheduledActionInvalidateOutputSurface() = 0; 48 virtual void ScheduledActionInvalidateOutputSurface() = 0;
46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; 49 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0;
47 virtual base::TimeDelta DrawDurationEstimate() = 0;
48 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0;
49 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0;
50 virtual void DidFinishImplFrame() = 0; 50 virtual void DidFinishImplFrame() = 0;
51 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; 51 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0;
52 virtual void SendBeginMainFrameNotExpectedSoon() = 0; 52 virtual void SendBeginMainFrameNotExpectedSoon() = 0;
53 53
54 protected: 54 protected:
55 virtual ~SchedulerClient() {} 55 virtual ~SchedulerClient() {}
56 }; 56 };
57 57
58 class Scheduler; 58 class Scheduler;
59 // This class exists to allow tests to override the frame source construction. 59 // This class exists to allow tests to override the frame source construction.
(...skipping 13 matching lines...) Expand all
73 friend class Scheduler; 73 friend class Scheduler;
74 }; 74 };
75 75
76 class CC_EXPORT Scheduler : public BeginFrameObserverBase { 76 class CC_EXPORT Scheduler : public BeginFrameObserverBase {
77 public: 77 public:
78 static scoped_ptr<Scheduler> Create( 78 static scoped_ptr<Scheduler> Create(
79 SchedulerClient* client, 79 SchedulerClient* client,
80 const SchedulerSettings& scheduler_settings, 80 const SchedulerSettings& scheduler_settings,
81 int layer_tree_host_id, 81 int layer_tree_host_id,
82 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 82 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
83 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 83 scoped_ptr<BeginFrameSource> external_begin_frame_source,
84 RenderingStatsInstrumentation* rendering_stats_instrumentation) {
84 SchedulerFrameSourcesConstructor frame_sources_constructor; 85 SchedulerFrameSourcesConstructor frame_sources_constructor;
85 return make_scoped_ptr(new Scheduler(client, 86 return make_scoped_ptr(new Scheduler(
86 scheduler_settings, 87 client, scheduler_settings, layer_tree_host_id, task_runner,
87 layer_tree_host_id, 88 external_begin_frame_source.Pass(), rendering_stats_instrumentation,
88 task_runner, 89 &frame_sources_constructor));
89 external_begin_frame_source.Pass(),
90 &frame_sources_constructor));
91 } 90 }
92 91
93 ~Scheduler() override; 92 ~Scheduler() override;
94 93
95 // BeginFrameObserverBase 94 // BeginFrameObserverBase
96 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; 95 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override;
97 96
98 void OnDrawForOutputSurface(); 97 void OnDrawForOutputSurface();
99 98
100 const SchedulerSettings& settings() const { return settings_; } 99 const SchedulerSettings& settings() const { return settings_; }
(...skipping 21 matching lines...) Expand all
122 void SetWaitForReadyToDraw(); 121 void SetWaitForReadyToDraw();
123 122
124 void SetMaxSwapsPending(int max); 123 void SetMaxSwapsPending(int max);
125 void DidSwapBuffers(); 124 void DidSwapBuffers();
126 void DidSwapBuffersComplete(); 125 void DidSwapBuffersComplete();
127 126
128 void SetImplLatencyTakesPriority(bool impl_latency_takes_priority); 127 void SetImplLatencyTakesPriority(bool impl_latency_takes_priority);
129 128
130 void NotifyReadyToCommit(); 129 void NotifyReadyToCommit();
131 void BeginMainFrameAborted(CommitEarlyOutReason reason); 130 void BeginMainFrameAborted(CommitEarlyOutReason reason);
131 void DidCommit();
132 132
133 void WillPrepareTiles();
133 void DidPrepareTiles(); 134 void DidPrepareTiles();
134 void DidLoseOutputSurface(); 135 void DidLoseOutputSurface();
135 void DidCreateAndInitializeOutputSurface(); 136 void DidCreateAndInitializeOutputSurface();
136 137
137 // Tests do not want to shut down until all possible BeginMainFrames have 138 // Tests do not want to shut down until all possible BeginMainFrames have
138 // occured to prevent flakiness. 139 // occured to prevent flakiness.
139 bool MainFrameForTestingWillHappen() const { 140 bool MainFrameForTestingWillHappen() const {
140 return state_machine_.CommitPending() || 141 return state_machine_.CommitPending() ||
141 state_machine_.CouldSendBeginMainFrame(); 142 state_machine_.CouldSendBeginMainFrame();
142 } 143 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); 176 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames);
176 177
177 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval); 178 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval);
178 179
179 protected: 180 protected:
180 Scheduler(SchedulerClient* client, 181 Scheduler(SchedulerClient* client,
181 const SchedulerSettings& scheduler_settings, 182 const SchedulerSettings& scheduler_settings,
182 int layer_tree_host_id, 183 int layer_tree_host_id,
183 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 184 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
184 scoped_ptr<BeginFrameSource> external_begin_frame_source, 185 scoped_ptr<BeginFrameSource> external_begin_frame_source,
186 RenderingStatsInstrumentation* rendering_stats_instrumentation,
185 SchedulerFrameSourcesConstructor* frame_sources_constructor); 187 SchedulerFrameSourcesConstructor* frame_sources_constructor);
186 188
187 // virtual for testing - Don't call these in the constructor or 189 // virtual for testing - Don't call these in the constructor or
188 // destructor! 190 // destructor!
189 virtual base::TimeTicks Now() const; 191 virtual base::TimeTicks Now() const;
192 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() const;
193 virtual base::TimeDelta PrepareTilesDurationEstimate() const;
194 virtual base::TimeDelta PrepareTilesToReadyToActivateDurationEstimate() const;
195 virtual base::TimeDelta ActivateDurationEstimate() const;
196 virtual base::TimeDelta DrawDurationEstimate() const;
190 197
191 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; 198 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_;
192 BeginFrameSource* primary_frame_source_; 199 BeginFrameSource* primary_frame_source_;
193 BeginFrameSource* unthrottled_frame_source_; 200 BeginFrameSource* unthrottled_frame_source_;
194 201
195 // Storage when frame sources are internal 202 // Storage when frame sources are internal
196 scoped_ptr<BeginFrameSource> primary_frame_source_internal_; 203 scoped_ptr<BeginFrameSource> primary_frame_source_internal_;
197 scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_; 204 scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_;
198 205
199 VSyncParameterObserver* vsync_observer_; 206 VSyncParameterObserver* vsync_observer_;
200 base::TimeDelta authoritative_vsync_interval_; 207 base::TimeDelta authoritative_vsync_interval_;
201 base::TimeTicks last_vsync_timebase_; 208 base::TimeTicks last_vsync_timebase_;
202 209
203 bool throttle_frame_production_; 210 bool throttle_frame_production_;
204 211
205 const SchedulerSettings settings_; 212 const SchedulerSettings settings_;
206 SchedulerClient* client_; 213 SchedulerClient* client_;
207 int layer_tree_host_id_; 214 int layer_tree_host_id_;
208 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 215 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
209 216
217 CompositorTimingHistory compositor_timing_history_;
210 base::TimeDelta estimated_parent_draw_time_; 218 base::TimeDelta estimated_parent_draw_time_;
211 219
212 std::deque<BeginFrameArgs> begin_retro_frame_args_; 220 std::deque<BeginFrameArgs> begin_retro_frame_args_;
213 SchedulerStateMachine::BeginImplFrameDeadlineMode 221 SchedulerStateMachine::BeginImplFrameDeadlineMode
214 begin_impl_frame_deadline_mode_; 222 begin_impl_frame_deadline_mode_;
215 BeginFrameTracker begin_impl_frame_tracker_; 223 BeginFrameTracker begin_impl_frame_tracker_;
216 224
217 base::Closure begin_retro_frame_closure_; 225 base::Closure begin_retro_frame_closure_;
218 base::Closure begin_impl_frame_deadline_closure_; 226 base::Closure begin_impl_frame_deadline_closure_;
219 base::Closure advance_commit_state_closure_; 227 base::Closure advance_commit_state_closure_;
220 base::CancelableClosure begin_retro_frame_task_; 228 base::CancelableClosure begin_retro_frame_task_;
221 base::CancelableClosure begin_impl_frame_deadline_task_; 229 base::CancelableClosure begin_impl_frame_deadline_task_;
222 base::CancelableClosure advance_commit_state_task_; 230 base::CancelableClosure advance_commit_state_task_;
223 231
224 SchedulerStateMachine state_machine_; 232 SchedulerStateMachine state_machine_;
225 bool inside_process_scheduled_actions_; 233 bool inside_process_scheduled_actions_;
226 SchedulerStateMachine::Action inside_action_; 234 SchedulerStateMachine::Action inside_action_;
227 235
228 private: 236 private:
229 void ScheduleBeginImplFrameDeadline(); 237 void ScheduleBeginImplFrameDeadline();
230 void ScheduleBeginImplFrameDeadlineIfNeeded(); 238 void ScheduleBeginImplFrameDeadlineIfNeeded();
231 void SetupNextBeginFrameIfNeeded(); 239 void SetupNextBeginFrameIfNeeded();
232 void PostBeginRetroFrameIfNeeded(); 240 void PostBeginRetroFrameIfNeeded();
233 void SetupPollingMechanisms(); 241 void SetupPollingMechanisms();
234 void DrawAndSwapIfPossible(); 242 void DrawAndSwapIfPossible();
243 void DrawAndSwapForced();
235 void ProcessScheduledActions(); 244 void ProcessScheduledActions();
236 bool CanCommitAndActivateBeforeDeadline() const; 245 bool CanCommitAndActivateBeforeDeadline() const;
237 void AdvanceCommitStateIfPossible(); 246 void AdvanceCommitStateIfPossible();
238 bool IsBeginMainFrameSentOrStarted() const; 247 bool IsBeginMainFrameSentOrStarted() const;
239 void BeginRetroFrame(); 248 void BeginRetroFrame();
240 void BeginImplFrameWithDeadline(const BeginFrameArgs& args); 249 void BeginImplFrameWithDeadline(const BeginFrameArgs& args);
241 void BeginImplFrameSynchronous(const BeginFrameArgs& args); 250 void BeginImplFrameSynchronous(const BeginFrameArgs& args);
242 void BeginImplFrame(const BeginFrameArgs& args); 251 void BeginImplFrame(const BeginFrameArgs& args);
243 void FinishImplFrame(); 252 void FinishImplFrame();
244 void OnBeginImplFrameDeadline(); 253 void OnBeginImplFrameDeadline();
(...skipping 11 matching lines...) Expand all
256 265
257 friend class SchedulerFrameSourcesConstructor; 266 friend class SchedulerFrameSourcesConstructor;
258 friend class TestSchedulerFrameSourcesConstructor; 267 friend class TestSchedulerFrameSourcesConstructor;
259 268
260 DISALLOW_COPY_AND_ASSIGN(Scheduler); 269 DISALLOW_COPY_AND_ASSIGN(Scheduler);
261 }; 270 };
262 271
263 } // namespace cc 272 } // namespace cc
264 273
265 #endif // CC_SCHEDULER_SCHEDULER_H_ 274 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698