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

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

Issue 1535833002: Delete CC. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-5
Patch Set: rebase Created 4 years, 10 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
« no previous file with comments | « cc/scheduler/draw_result.h ('k') | cc/scheduler/scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_SCHEDULER_SCHEDULER_H_
6 #define CC_SCHEDULER_SCHEDULER_H_
7
8 #include <deque>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/cancelable_callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h"
15 #include "cc/output/begin_frame_args.h"
16 #include "cc/output/vsync_parameter_observer.h"
17 #include "cc/scheduler/begin_frame_source.h"
18 #include "cc/scheduler/delay_based_time_source.h"
19 #include "cc/scheduler/draw_result.h"
20 #include "cc/scheduler/scheduler_settings.h"
21 #include "cc/scheduler/scheduler_state_machine.h"
22
23 namespace base {
24 namespace trace_event {
25 class ConvertableToTraceFormat;
26 }
27 class SingleThreadTaskRunner;
28 }
29
30 namespace cc {
31
32 class SchedulerClient {
33 public:
34 virtual void WillBeginImplFrame(const BeginFrameArgs& args) = 0;
35 virtual void ScheduledActionSendBeginMainFrame() = 0;
36 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() = 0;
37 virtual DrawResult ScheduledActionDrawAndSwapForced() = 0;
38 virtual void ScheduledActionAnimate() = 0;
39 virtual void ScheduledActionCommit() = 0;
40 virtual void ScheduledActionActivateSyncTree() = 0;
41 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0;
42 virtual void ScheduledActionPrepareTiles() = 0;
43 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0;
44 virtual base::TimeDelta DrawDurationEstimate() = 0;
45 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0;
46 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0;
47 virtual void DidBeginImplFrameDeadline() = 0;
48 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0;
49 virtual void SendBeginMainFrameNotExpectedSoon() = 0;
50
51 protected:
52 virtual ~SchedulerClient() {}
53 };
54
55 class Scheduler;
56 // This class exists to allow tests to override the frame source construction.
57 // A virtual method can't be used as this needs to happen in the constructor
58 // (see C++ FAQ / Section 23 - http://goo.gl/fnrwom for why).
59 // This class exists solely long enough to construct the frame sources.
60 class SchedulerFrameSourcesConstructor {
61 public:
62 virtual ~SchedulerFrameSourcesConstructor() {}
63 virtual BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler);
64 virtual BeginFrameSource* ConstructBackgroundFrameSource(
65 Scheduler* scheduler);
66 virtual BeginFrameSource* ConstructUnthrottledFrameSource(
67 Scheduler* scheduler);
68
69 protected:
70 SchedulerFrameSourcesConstructor() {}
71
72 friend class Scheduler;
73 };
74
75 class Scheduler : public BeginFrameObserverMixIn {
76 public:
77 static scoped_ptr<Scheduler> Create(
78 SchedulerClient* client,
79 const SchedulerSettings& scheduler_settings,
80 int layer_tree_host_id,
81 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
82 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
83 SchedulerFrameSourcesConstructor frame_sources_constructor;
84 return make_scoped_ptr(new Scheduler(client,
85 scheduler_settings,
86 layer_tree_host_id,
87 task_runner,
88 external_begin_frame_source.Pass(),
89 &frame_sources_constructor));
90 }
91
92 ~Scheduler() override;
93
94 // BeginFrameObserverMixin
95 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override;
96
97 const SchedulerSettings& settings() const { return settings_; }
98
99 void CommitVSyncParameters(base::TimeTicks timebase,
100 base::TimeDelta interval);
101 void SetEstimatedParentDrawTime(base::TimeDelta draw_time);
102
103 void SetCanStart();
104
105 void SetVisible(bool visible);
106 void SetCanDraw(bool can_draw);
107 void NotifyReadyToActivate();
108 void NotifyReadyToDraw();
109 void SetThrottleFrameProduction(bool throttle);
110
111 void SetNeedsCommit();
112
113 void SetNeedsRedraw();
114
115 void SetNeedsAnimate();
116
117 void SetNeedsPrepareTiles();
118
119 void SetMaxSwapsPending(int max);
120 void DidSwapBuffers();
121 void DidSwapBuffersComplete();
122
123 void SetImplLatencyTakesPriority(bool impl_latency_takes_priority);
124
125 void NotifyReadyToCommit();
126 void BeginMainFrameAborted(CommitEarlyOutReason reason);
127
128 void DidPrepareTiles();
129 void DidLoseOutputSurface();
130 void DidCreateAndInitializeOutputSurface();
131
132 // Tests do not want to shut down until all possible BeginMainFrames have
133 // occured to prevent flakiness.
134 bool MainFrameForTestingWillHappen() const {
135 return state_machine_.CommitPending() ||
136 state_machine_.CouldSendBeginMainFrame();
137 }
138
139 bool CommitPending() const { return state_machine_.CommitPending(); }
140 bool RedrawPending() const { return state_machine_.RedrawPending(); }
141 bool PrepareTilesPending() const {
142 return state_machine_.PrepareTilesPending();
143 }
144 bool MainThreadIsInHighLatencyMode() const {
145 return state_machine_.MainThreadIsInHighLatencyMode();
146 }
147 bool BeginImplFrameDeadlinePending() const {
148 return !begin_impl_frame_deadline_task_.IsCancelled();
149 }
150
151 base::TimeTicks AnticipatedDrawTime() const;
152
153 void NotifyBeginMainFrameStarted();
154
155 base::TimeTicks LastBeginImplFrameTime();
156
157 void SetDeferCommits(bool defer_commits);
158
159 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
160 void AsValueInto(base::trace_event::TracedValue* value) const override;
161
162 void SetContinuousPainting(bool continuous_painting) {
163 state_machine_.SetContinuousPainting(continuous_painting);
164 }
165
166 void SetChildrenNeedBeginFrames(bool children_need_begin_frames);
167
168 protected:
169 Scheduler(SchedulerClient* client,
170 const SchedulerSettings& scheduler_settings,
171 int layer_tree_host_id,
172 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
173 scoped_ptr<BeginFrameSource> external_begin_frame_source,
174 SchedulerFrameSourcesConstructor* frame_sources_constructor);
175
176 // virtual for testing - Don't call these in the constructor or
177 // destructor!
178 virtual base::TimeTicks Now() const;
179
180 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_;
181 BeginFrameSource* primary_frame_source_;
182 BeginFrameSource* background_frame_source_;
183 BeginFrameSource* unthrottled_frame_source_;
184
185 // Storage when frame sources are internal
186 scoped_ptr<BeginFrameSource> primary_frame_source_internal_;
187 scoped_ptr<SyntheticBeginFrameSource> background_frame_source_internal_;
188 scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_;
189
190 VSyncParameterObserver* vsync_observer_;
191 bool throttle_frame_production_;
192
193 const SchedulerSettings settings_;
194 SchedulerClient* client_;
195 int layer_tree_host_id_;
196 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
197
198 base::TimeDelta estimated_parent_draw_time_;
199
200 std::deque<BeginFrameArgs> begin_retro_frame_args_;
201 BeginFrameArgs begin_impl_frame_args_;
202 SchedulerStateMachine::BeginImplFrameDeadlineMode
203 begin_impl_frame_deadline_mode_;
204
205 base::Closure begin_retro_frame_closure_;
206 base::Closure begin_impl_frame_deadline_closure_;
207 base::Closure poll_for_draw_triggers_closure_;
208 base::Closure advance_commit_state_closure_;
209 base::CancelableClosure begin_retro_frame_task_;
210 base::CancelableClosure begin_impl_frame_deadline_task_;
211 base::CancelableClosure poll_for_draw_triggers_task_;
212 base::CancelableClosure advance_commit_state_task_;
213
214 SchedulerStateMachine state_machine_;
215 bool inside_process_scheduled_actions_;
216 SchedulerStateMachine::Action inside_action_;
217
218 private:
219 void ScheduleBeginImplFrameDeadline();
220 void RescheduleBeginImplFrameDeadlineIfNeeded();
221 void SetupNextBeginFrameIfNeeded();
222 void PostBeginRetroFrameIfNeeded();
223 void SetupPollingMechanisms();
224 void DrawAndSwapIfPossible();
225 void ProcessScheduledActions();
226 bool CanCommitAndActivateBeforeDeadline() const;
227 void AdvanceCommitStateIfPossible();
228 bool IsBeginMainFrameSentOrStarted() const;
229 void BeginRetroFrame();
230 void BeginImplFrame(const BeginFrameArgs& args);
231 void OnBeginImplFrameDeadline();
232 void PollForAnticipatedDrawTriggers();
233 void PollToAdvanceCommitState();
234 void UpdateActiveFrameSource();
235
236 base::TimeDelta EstimatedParentDrawTime() {
237 return estimated_parent_draw_time_;
238 }
239
240 bool IsInsideAction(SchedulerStateMachine::Action action) {
241 return inside_action_ == action;
242 }
243
244 base::WeakPtrFactory<Scheduler> weak_factory_;
245
246 friend class SchedulerFrameSourcesConstructor;
247 friend class TestSchedulerFrameSourcesConstructor;
248
249 DISALLOW_COPY_AND_ASSIGN(Scheduler);
250 };
251
252 } // namespace cc
253
254 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW
« no previous file with comments | « cc/scheduler/draw_result.h ('k') | cc/scheduler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698