OLD | NEW |
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 #include "cc/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "cc/debug/devtools_instrumentation.h" | 11 #include "cc/debug/devtools_instrumentation.h" |
12 #include "cc/debug/traced_value.h" | 12 #include "cc/debug/traced_value.h" |
13 #include "ui/gfx/frame_time.h" | 13 #include "ui/gfx/frame_time.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 Scheduler::Scheduler( | 17 Scheduler::Scheduler( |
18 SchedulerClient* client, | 18 SchedulerClient* client, |
19 const SchedulerSettings& scheduler_settings, | 19 const SchedulerSettings& scheduler_settings, |
20 int layer_tree_host_id, | 20 int layer_tree_host_id, |
21 const scoped_refptr<base::SequencedTaskRunner>& impl_task_runner) | 21 const scoped_refptr<base::SequencedTaskRunner>& impl_task_runner) |
22 : settings_(scheduler_settings), | 22 : settings_(scheduler_settings), |
23 client_(client), | 23 client_(client), |
24 layer_tree_host_id_(layer_tree_host_id), | 24 layer_tree_host_id_(layer_tree_host_id), |
25 impl_task_runner_(impl_task_runner), | 25 impl_task_runner_(impl_task_runner), |
26 last_set_needs_begin_impl_frame_(false), | 26 last_set_needs_begin_frame_(false), |
| 27 begin_retro_frame_posted_(false), |
27 state_machine_(scheduler_settings), | 28 state_machine_(scheduler_settings), |
28 inside_process_scheduled_actions_(false), | 29 inside_process_scheduled_actions_(false), |
29 inside_action_(SchedulerStateMachine::ACTION_NONE), | 30 inside_action_(SchedulerStateMachine::ACTION_NONE), |
30 weak_factory_(this) { | 31 weak_factory_(this) { |
31 DCHECK(client_); | 32 DCHECK(client_); |
32 DCHECK(!state_machine_.BeginImplFrameNeeded()); | 33 DCHECK(!state_machine_.BeginFrameNeeded()); |
33 if (settings_.main_frame_before_activation_enabled) { | 34 if (settings_.main_frame_before_activation_enabled) { |
34 DCHECK(settings_.main_frame_before_draw_enabled); | 35 DCHECK(settings_.main_frame_before_draw_enabled); |
35 } | 36 } |
36 } | 37 } |
37 | 38 |
38 Scheduler::~Scheduler() {} | 39 Scheduler::~Scheduler() {} |
39 | 40 |
40 void Scheduler::SetCanStart() { | 41 void Scheduler::SetCanStart() { |
41 state_machine_.SetCanStart(); | 42 state_machine_.SetCanStart(); |
42 ProcessScheduledActions(); | 43 ProcessScheduledActions(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 ProcessScheduledActions(); | 110 ProcessScheduledActions(); |
110 } | 111 } |
111 | 112 |
112 void Scheduler::DidManageTiles() { | 113 void Scheduler::DidManageTiles() { |
113 state_machine_.DidManageTiles(); | 114 state_machine_.DidManageTiles(); |
114 } | 115 } |
115 | 116 |
116 void Scheduler::DidLoseOutputSurface() { | 117 void Scheduler::DidLoseOutputSurface() { |
117 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); | 118 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); |
118 state_machine_.DidLoseOutputSurface(); | 119 state_machine_.DidLoseOutputSurface(); |
119 last_set_needs_begin_impl_frame_ = false; | 120 last_set_needs_begin_frame_ = false; |
| 121 begin_retro_frame_args_.clear(); |
120 ProcessScheduledActions(); | 122 ProcessScheduledActions(); |
121 } | 123 } |
122 | 124 |
123 void Scheduler::DidCreateAndInitializeOutputSurface() { | 125 void Scheduler::DidCreateAndInitializeOutputSurface() { |
124 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); | 126 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); |
125 DCHECK(!last_set_needs_begin_impl_frame_); | 127 DCHECK(!last_set_needs_begin_frame_); |
126 DCHECK(begin_impl_frame_deadline_closure_.IsCancelled()); | 128 DCHECK(begin_impl_frame_deadline_closure_.IsCancelled()); |
127 state_machine_.DidCreateAndInitializeOutputSurface(); | 129 state_machine_.DidCreateAndInitializeOutputSurface(); |
128 ProcessScheduledActions(); | 130 ProcessScheduledActions(); |
129 } | 131 } |
130 | 132 |
131 void Scheduler::NotifyBeginMainFrameStarted() { | 133 void Scheduler::NotifyBeginMainFrameStarted() { |
132 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); | 134 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); |
133 state_machine_.NotifyBeginMainFrameStarted(); | 135 state_machine_.NotifyBeginMainFrameStarted(); |
134 } | 136 } |
135 | 137 |
136 base::TimeTicks Scheduler::AnticipatedDrawTime() const { | 138 base::TimeTicks Scheduler::AnticipatedDrawTime() const { |
137 if (!last_set_needs_begin_impl_frame_ || | 139 if (!last_set_needs_begin_frame_ || |
138 last_begin_impl_frame_args_.interval <= base::TimeDelta()) | 140 begin_impl_frame_args_.interval <= base::TimeDelta()) |
139 return base::TimeTicks(); | 141 return base::TimeTicks(); |
140 | 142 |
141 base::TimeTicks now = gfx::FrameTime::Now(); | 143 base::TimeTicks now = gfx::FrameTime::Now(); |
142 base::TimeTicks timebase = std::max(last_begin_impl_frame_args_.frame_time, | 144 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time, |
143 last_begin_impl_frame_args_.deadline); | 145 begin_impl_frame_args_.deadline); |
144 int64 intervals = | 146 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval); |
145 1 + ((now - timebase) / last_begin_impl_frame_args_.interval); | 147 return timebase + (begin_impl_frame_args_.interval * intervals); |
146 return timebase + (last_begin_impl_frame_args_.interval * intervals); | |
147 } | 148 } |
148 | 149 |
149 base::TimeTicks Scheduler::LastBeginImplFrameTime() { | 150 base::TimeTicks Scheduler::LastBeginImplFrameTime() { |
150 return last_begin_impl_frame_args_.frame_time; | 151 return begin_impl_frame_args_.frame_time; |
151 } | 152 } |
152 | 153 |
153 void Scheduler::SetupNextBeginImplFrameIfNeeded() { | 154 void Scheduler::SetupNextBeginFrameIfNeeded() { |
154 bool needs_begin_impl_frame = | 155 bool needs_begin_frame = state_machine_.BeginFrameNeeded(); |
155 state_machine_.BeginImplFrameNeeded(); | |
156 | 156 |
157 bool at_end_of_deadline = | 157 bool at_end_of_deadline = |
158 state_machine_.begin_impl_frame_state() == | 158 state_machine_.begin_impl_frame_state() == |
159 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; | 159 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; |
160 | 160 |
161 bool should_call_set_needs_begin_impl_frame = | 161 bool should_call_set_needs_begin_frame = |
162 // Always request the BeginImplFrame immediately if it wasn't needed | 162 // Always request the BeginFrame immediately if it wasn't needed before. |
163 // before. | 163 (needs_begin_frame && !last_set_needs_begin_frame_) || |
164 (needs_begin_impl_frame && !last_set_needs_begin_impl_frame_) || | 164 // We always need to explicitly request our next BeginFrame. |
165 // We always need to explicitly request our next BeginImplFrame. | |
166 at_end_of_deadline; | 165 at_end_of_deadline; |
167 | 166 |
168 if (should_call_set_needs_begin_impl_frame) { | 167 if (should_call_set_needs_begin_frame) { |
169 client_->SetNeedsBeginImplFrame(needs_begin_impl_frame); | 168 client_->SetNeedsBeginFrame(needs_begin_frame); |
170 last_set_needs_begin_impl_frame_ = needs_begin_impl_frame; | 169 last_set_needs_begin_frame_ = needs_begin_frame; |
| 170 } |
| 171 |
| 172 // Handle retroactive BeginFrames. |
| 173 if (needs_begin_frame && !begin_retro_frame_posted_ && |
| 174 !begin_retro_frame_args_.empty() && |
| 175 state_machine_.begin_impl_frame_state() == |
| 176 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { |
| 177 begin_retro_frame_posted_ = true; |
| 178 impl_task_runner_->PostTask( |
| 179 FROM_HERE, |
| 180 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr())); |
171 } | 181 } |
172 | 182 |
173 bool needs_advance_commit_state_timer = false; | 183 bool needs_advance_commit_state_timer = false; |
174 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but | 184 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but |
175 // aren't expecting any more BeginImplFrames. This should only be needed by | 185 // aren't expecting any more BeginFrames. This should only be needed by |
176 // the synchronous compositor when BeginImplFrameNeeded is false. | 186 // the synchronous compositor when BeginFrameNeeded is false. |
177 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { | 187 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { |
178 DCHECK(!state_machine_.SupportsProactiveBeginImplFrame()); | 188 DCHECK(!state_machine_.SupportsProactiveBeginFrame()); |
179 DCHECK(!needs_begin_impl_frame); | 189 DCHECK(!needs_begin_frame); |
180 if (poll_for_draw_triggers_closure_.IsCancelled()) { | 190 if (poll_for_draw_triggers_closure_.IsCancelled()) { |
181 poll_for_draw_triggers_closure_.Reset( | 191 poll_for_draw_triggers_closure_.Reset( |
182 base::Bind(&Scheduler::PollForAnticipatedDrawTriggers, | 192 base::Bind(&Scheduler::PollForAnticipatedDrawTriggers, |
183 weak_factory_.GetWeakPtr())); | 193 weak_factory_.GetWeakPtr())); |
184 impl_task_runner_->PostDelayedTask( | 194 impl_task_runner_->PostDelayedTask( |
185 FROM_HERE, | 195 FROM_HERE, |
186 poll_for_draw_triggers_closure_.callback(), | 196 poll_for_draw_triggers_closure_.callback(), |
187 last_begin_impl_frame_args_.interval); | 197 begin_impl_frame_args_.interval); |
188 } | 198 } |
189 } else { | 199 } else { |
190 poll_for_draw_triggers_closure_.Cancel(); | 200 poll_for_draw_triggers_closure_.Cancel(); |
191 | 201 |
192 // At this point we'd prefer to advance through the commit flow by | 202 // At this point we'd prefer to advance through the commit flow by |
193 // drawing a frame, however it's possible that the frame rate controller | 203 // drawing a frame, however it's possible that the frame rate controller |
194 // will not give us a BeginImplFrame until the commit completes. See | 204 // will not give us a BeginFrame until the commit completes. See |
195 // crbug.com/317430 for an example of a swap ack being held on commit. Thus | 205 // crbug.com/317430 for an example of a swap ack being held on commit. Thus |
196 // we set a repeating timer to poll on ProcessScheduledActions until we | 206 // we set a repeating timer to poll on ProcessScheduledActions until we |
197 // successfully reach BeginImplFrame. Synchronous compositor does not use | 207 // successfully reach BeginFrame. Synchronous compositor does not use |
198 // frame rate controller or have the circular wait in the bug. | 208 // frame rate controller or have the circular wait in the bug. |
199 if (IsBeginMainFrameSentOrStarted() && | 209 if (IsBeginMainFrameSentOrStarted() && |
200 !settings_.using_synchronous_renderer_compositor) { | 210 !settings_.using_synchronous_renderer_compositor) { |
201 needs_advance_commit_state_timer = true; | 211 needs_advance_commit_state_timer = true; |
202 } | 212 } |
203 } | 213 } |
204 if (needs_advance_commit_state_timer != | 214 if (needs_advance_commit_state_timer != |
205 advance_commit_state_timer_.IsRunning()) { | 215 advance_commit_state_timer_.IsRunning()) { |
206 if (needs_advance_commit_state_timer && | 216 if (needs_advance_commit_state_timer && begin_impl_frame_args_.IsValid()) { |
207 last_begin_impl_frame_args_.IsValid()) { | |
208 // Since we'd rather get a BeginImplFrame by the normal mechanism, we | 217 // Since we'd rather get a BeginImplFrame by the normal mechanism, we |
209 // set the interval to twice the interval from the previous frame. | 218 // set the interval to twice the interval from the previous frame. |
210 advance_commit_state_timer_.Start( | 219 advance_commit_state_timer_.Start( |
211 FROM_HERE, | 220 FROM_HERE, |
212 last_begin_impl_frame_args_.interval * 2, | 221 begin_impl_frame_args_.interval * 2, |
213 base::Bind(&Scheduler::ProcessScheduledActions, | 222 base::Bind(&Scheduler::ProcessScheduledActions, |
214 base::Unretained(this))); | 223 base::Unretained(this))); |
215 } else { | 224 } else { |
216 advance_commit_state_timer_.Stop(); | 225 advance_commit_state_timer_.Stop(); |
217 } | 226 } |
218 } | 227 } |
219 } | 228 } |
220 | 229 |
| 230 void Scheduler::BeginFrame(const BeginFrameArgs& args) { |
| 231 if (last_set_needs_begin_frame_ && begin_retro_frame_args_.empty() && |
| 232 state_machine_.begin_impl_frame_state() == |
| 233 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { |
| 234 BeginImplFrame(args); |
| 235 } else { |
| 236 begin_retro_frame_args_.push_back(args); |
| 237 TRACE_EVENT_INSTANT0( |
| 238 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); |
| 239 } |
| 240 } |
| 241 |
| 242 void Scheduler::BeginRetroFrame() { |
| 243 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); |
| 244 DCHECK(!begin_retro_frame_args_.empty()); |
| 245 |
| 246 // Discard expired BeginRetroFrames |
| 247 base::TimeTicks now = gfx::FrameTime::Now(); |
| 248 while (!begin_retro_frame_args_.empty() && |
| 249 now > |
| 250 AdjustedBeginImplFrameDeadline(begin_retro_frame_args_.front())) { |
| 251 begin_retro_frame_args_.pop_front(); |
| 252 } |
| 253 |
| 254 if (begin_retro_frame_args_.empty()) { |
| 255 TRACE_EVENT_INSTANT0( |
| 256 "cc", "Scheduler::BeginRetroFrames expired", TRACE_EVENT_SCOPE_THREAD); |
| 257 } else { |
| 258 BeginImplFrame(begin_retro_frame_args_.front()); |
| 259 begin_retro_frame_args_.pop_front(); |
| 260 } |
| 261 |
| 262 begin_retro_frame_posted_ = false; |
| 263 } |
| 264 |
221 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 265 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
222 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame"); | 266 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame"); |
223 DCHECK(state_machine_.begin_impl_frame_state() == | 267 DCHECK(state_machine_.begin_impl_frame_state() == |
224 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 268 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
225 DCHECK(state_machine_.HasInitializedOutputSurface()); | 269 DCHECK(state_machine_.HasInitializedOutputSurface()); |
226 | 270 |
227 last_begin_impl_frame_args_ = args; | |
228 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); | |
229 | |
230 if (!state_machine_.smoothness_takes_priority() && | 271 if (!state_machine_.smoothness_takes_priority() && |
231 state_machine_.MainThreadIsInHighLatencyMode() && | 272 state_machine_.MainThreadIsInHighLatencyMode() && |
232 CanCommitAndActivateBeforeDeadline()) { | 273 CanCommitAndActivateBeforeDeadline()) { |
233 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); | 274 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); |
234 } | 275 } |
235 | 276 |
236 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); | 277 begin_impl_frame_args_ = args; |
| 278 begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); |
| 279 |
| 280 client_->WillBeginImplFrame(begin_impl_frame_args_); |
| 281 state_machine_.OnBeginImplFrame(begin_impl_frame_args_); |
237 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); | 282 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); |
238 | 283 |
239 ProcessScheduledActions(); | 284 ProcessScheduledActions(); |
240 | 285 |
241 if (!state_machine_.HasInitializedOutputSurface()) | 286 if (!state_machine_.HasInitializedOutputSurface()) |
242 return; | 287 return; |
243 | 288 |
244 state_machine_.OnBeginImplFrameDeadlinePending(); | 289 state_machine_.OnBeginImplFrameDeadlinePending(); |
245 base::TimeTicks adjusted_deadline = AdjustedBeginImplFrameDeadline(); | 290 ScheduleBeginImplFrameDeadline(AdjustedBeginImplFrameDeadline(args)); |
246 ScheduleBeginImplFrameDeadline(adjusted_deadline); | |
247 } | 291 } |
248 | 292 |
249 base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline() const { | 293 base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline( |
| 294 const BeginFrameArgs& args) const { |
250 if (settings_.using_synchronous_renderer_compositor) { | 295 if (settings_.using_synchronous_renderer_compositor) { |
251 // The synchronous compositor needs to draw right away. | 296 // The synchronous compositor needs to draw right away. |
252 return base::TimeTicks(); | 297 return base::TimeTicks(); |
253 } else if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) { | 298 } else if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) { |
254 // We are ready to draw a new active tree immediately. | 299 // We are ready to draw a new active tree immediately. |
255 return base::TimeTicks(); | 300 return base::TimeTicks(); |
256 } else if (state_machine_.needs_redraw()) { | 301 } else if (state_machine_.needs_redraw()) { |
257 // We have an animation or fast input path on the impl thread that wants | 302 // We have an animation or fast input path on the impl thread that wants |
258 // to draw, so don't wait too long for a new active tree. | 303 // to draw, so don't wait too long for a new active tree. |
259 return last_begin_impl_frame_args_.deadline; | 304 return args.deadline - client_->DrawDurationEstimate(); |
260 } else { | 305 } else { |
261 // The impl thread doesn't have anything it wants to draw and we are just | 306 // The impl thread doesn't have anything it wants to draw and we are just |
262 // waiting for a new active tree, so post the deadline for the next | 307 // waiting for a new active tree, so post the deadline for the next |
263 // expected BeginImplFrame start. This allows us to draw immediately when | 308 // expected BeginImplFrame start. This allows us to draw immediately when |
264 // there is a new active tree, instead of waiting for the next | 309 // there is a new active tree, instead of waiting for the next |
265 // BeginImplFrame. | 310 // BeginImplFrame. |
266 // TODO(brianderson): Handle long deadlines (that are past the next frame's | 311 // TODO(brianderson): Handle long deadlines (that are past the next frame's |
267 // frame time) properly instead of using this hack. | 312 // frame time) properly instead of using this hack. |
268 return last_begin_impl_frame_args_.frame_time + | 313 return args.frame_time + args.interval; |
269 last_begin_impl_frame_args_.interval; | |
270 } | 314 } |
271 } | 315 } |
272 | 316 |
273 void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) { | 317 void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) { |
274 if (settings_.using_synchronous_renderer_compositor) { | 318 if (settings_.using_synchronous_renderer_compositor) { |
275 // The synchronous renderer compositor has to make its GL calls | 319 // The synchronous renderer compositor has to make its GL calls |
276 // within this call. | 320 // within this call. |
277 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks | 321 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks |
278 // so the sychronous renderer compositor can take advantage of splitting | 322 // so the sychronous renderer compositor can take advantage of splitting |
279 // up the BeginImplFrame and deadline as well. | 323 // up the BeginImplFrame and deadline as well. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 break; | 435 break; |
392 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: | 436 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: |
393 client_->ScheduledActionAcquireLayerTexturesForMainThread(); | 437 client_->ScheduledActionAcquireLayerTexturesForMainThread(); |
394 break; | 438 break; |
395 case SchedulerStateMachine::ACTION_MANAGE_TILES: | 439 case SchedulerStateMachine::ACTION_MANAGE_TILES: |
396 client_->ScheduledActionManageTiles(); | 440 client_->ScheduledActionManageTiles(); |
397 break; | 441 break; |
398 } | 442 } |
399 } while (action != SchedulerStateMachine::ACTION_NONE); | 443 } while (action != SchedulerStateMachine::ACTION_NONE); |
400 | 444 |
401 SetupNextBeginImplFrameIfNeeded(); | 445 SetupNextBeginFrameIfNeeded(); |
402 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); | 446 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); |
403 | 447 |
404 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) { | 448 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) { |
405 DCHECK(!settings_.using_synchronous_renderer_compositor); | 449 DCHECK(!settings_.using_synchronous_renderer_compositor); |
406 ScheduleBeginImplFrameDeadline(base::TimeTicks()); | 450 ScheduleBeginImplFrameDeadline(base::TimeTicks()); |
407 } | 451 } |
408 } | 452 } |
409 | 453 |
410 bool Scheduler::WillDrawIfNeeded() const { | 454 bool Scheduler::WillDrawIfNeeded() const { |
411 return !state_machine_.PendingDrawsShouldBeAborted(); | 455 return !state_machine_.PendingDrawsShouldBeAborted(); |
(...skipping 16 matching lines...) Expand all Loading... |
428 "commit_to_activate_duration_estimate_ms", | 472 "commit_to_activate_duration_estimate_ms", |
429 client_->CommitToActivateDurationEstimate().InMillisecondsF()); | 473 client_->CommitToActivateDurationEstimate().InMillisecondsF()); |
430 state->Set("client_state", client_state.release()); | 474 state->Set("client_state", client_state.release()); |
431 return state.PassAs<base::Value>(); | 475 return state.PassAs<base::Value>(); |
432 } | 476 } |
433 | 477 |
434 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { | 478 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { |
435 // Check if the main thread computation and commit can be finished before the | 479 // Check if the main thread computation and commit can be finished before the |
436 // impl thread's deadline. | 480 // impl thread's deadline. |
437 base::TimeTicks estimated_draw_time = | 481 base::TimeTicks estimated_draw_time = |
438 last_begin_impl_frame_args_.frame_time + | 482 begin_impl_frame_args_.frame_time + |
439 client_->BeginMainFrameToCommitDurationEstimate() + | 483 client_->BeginMainFrameToCommitDurationEstimate() + |
440 client_->CommitToActivateDurationEstimate(); | 484 client_->CommitToActivateDurationEstimate(); |
441 | 485 |
442 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 486 TRACE_EVENT2( |
443 "CanCommitAndActivateBeforeDeadline", | 487 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
444 "time_left_after_drawing_ms", | 488 "CanCommitAndActivateBeforeDeadline", |
445 (last_begin_impl_frame_args_.deadline - estimated_draw_time) | 489 "time_left_after_drawing_ms", |
446 .InMillisecondsF(), | 490 (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(), |
447 "state", | 491 "state", |
448 TracedValue::FromValue(StateAsValue().release())); | 492 TracedValue::FromValue(StateAsValue().release())); |
449 | 493 |
450 return estimated_draw_time < last_begin_impl_frame_args_.deadline; | 494 return estimated_draw_time < begin_impl_frame_args_.deadline; |
451 } | 495 } |
452 | 496 |
453 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 497 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
454 return (state_machine_.commit_state() == | 498 return (state_machine_.commit_state() == |
455 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 499 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
456 state_machine_.commit_state() == | 500 state_machine_.commit_state() == |
457 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 501 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
458 } | 502 } |
459 | 503 |
460 } // namespace cc | 504 } // namespace cc |
OLD | NEW |