Chromium Code Reviews| 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 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 // for message latency and kernel scheduling variability. | 24 // for message latency and kernel scheduling variability. |
| 25 const base::TimeDelta kDeadlineFudgeFactor = | 25 const base::TimeDelta kDeadlineFudgeFactor = |
| 26 base::TimeDelta::FromMicroseconds(1000); | 26 base::TimeDelta::FromMicroseconds(1000); |
| 27 } | 27 } |
| 28 | 28 |
| 29 scoped_ptr<Scheduler> Scheduler::Create( | 29 scoped_ptr<Scheduler> Scheduler::Create( |
| 30 SchedulerClient* client, | 30 SchedulerClient* client, |
| 31 const SchedulerSettings& settings, | 31 const SchedulerSettings& settings, |
| 32 int layer_tree_host_id, | 32 int layer_tree_host_id, |
| 33 base::SingleThreadTaskRunner* task_runner, | 33 base::SingleThreadTaskRunner* task_runner, |
| 34 BeginFrameSource* external_frame_source, | 34 BeginFrameSource* begin_frame_source, |
| 35 scoped_ptr<CompositorTimingHistory> compositor_timing_history) { | 35 scoped_ptr<CompositorTimingHistory> compositor_timing_history) { |
| 36 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source; | 36 return make_scoped_ptr(new Scheduler(client, settings, layer_tree_host_id, |
| 37 if (!settings.use_external_begin_frame_source) { | 37 task_runner, begin_frame_source, |
| 38 synthetic_frame_source = SyntheticBeginFrameSource::Create( | 38 std::move(compositor_timing_history))); |
| 39 task_runner, BeginFrameArgs::DefaultInterval()); | |
| 40 } | |
| 41 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source = | |
| 42 BackToBackBeginFrameSource::Create(task_runner); | |
| 43 return make_scoped_ptr(new Scheduler( | |
| 44 client, settings, layer_tree_host_id, task_runner, external_frame_source, | |
| 45 std::move(synthetic_frame_source), std::move(unthrottled_frame_source), | |
| 46 std::move(compositor_timing_history))); | |
| 47 } | 39 } |
| 48 | 40 |
| 49 Scheduler::Scheduler( | 41 Scheduler::Scheduler( |
| 50 SchedulerClient* client, | 42 SchedulerClient* client, |
| 51 const SchedulerSettings& settings, | 43 const SchedulerSettings& settings, |
| 52 int layer_tree_host_id, | 44 int layer_tree_host_id, |
| 53 base::SingleThreadTaskRunner* task_runner, | 45 base::SingleThreadTaskRunner* task_runner, |
| 54 BeginFrameSource* external_frame_source, | 46 BeginFrameSource* begin_frame_source, |
| 55 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source, | |
| 56 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source, | |
| 57 scoped_ptr<CompositorTimingHistory> compositor_timing_history) | 47 scoped_ptr<CompositorTimingHistory> compositor_timing_history) |
| 58 : settings_(settings), | 48 : settings_(settings), |
| 59 client_(client), | 49 client_(client), |
| 60 layer_tree_host_id_(layer_tree_host_id), | 50 layer_tree_host_id_(layer_tree_host_id), |
| 61 task_runner_(task_runner), | 51 task_runner_(task_runner), |
| 62 external_frame_source_(external_frame_source), | 52 begin_frame_source_(begin_frame_source), |
| 63 synthetic_frame_source_(std::move(synthetic_frame_source)), | 53 observing_begin_frame_source_(false), |
| 64 unthrottled_frame_source_(std::move(unthrottled_frame_source)), | |
| 65 frame_source_(BeginFrameSourceMultiplexer::Create()), | |
| 66 observing_frame_source_(false), | |
| 67 compositor_timing_history_(std::move(compositor_timing_history)), | 54 compositor_timing_history_(std::move(compositor_timing_history)), |
| 68 begin_impl_frame_deadline_mode_( | 55 begin_impl_frame_deadline_mode_( |
| 69 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), | 56 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), |
| 70 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | 57 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
| 71 state_machine_(settings), | 58 state_machine_(settings), |
| 72 inside_process_scheduled_actions_(false), | 59 inside_process_scheduled_actions_(false), |
| 73 inside_action_(SchedulerStateMachine::ACTION_NONE), | 60 inside_action_(SchedulerStateMachine::ACTION_NONE), |
| 74 weak_factory_(this) { | 61 weak_factory_(this) { |
| 75 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); | 62 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); |
| 76 DCHECK(client_); | 63 DCHECK(client_); |
| 77 DCHECK(!state_machine_.BeginFrameNeeded()); | 64 DCHECK(!state_machine_.BeginFrameNeeded()); |
| 78 DCHECK(!settings_.use_external_begin_frame_source || external_frame_source_); | |
| 79 DCHECK(settings_.use_external_begin_frame_source || synthetic_frame_source_); | |
| 80 DCHECK(unthrottled_frame_source_); | |
| 81 | 65 |
| 82 begin_retro_frame_closure_ = | 66 begin_retro_frame_closure_ = |
| 83 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr()); | 67 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr()); |
| 84 begin_impl_frame_deadline_closure_ = base::Bind( | 68 begin_impl_frame_deadline_closure_ = base::Bind( |
| 85 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); | 69 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); |
| 86 | 70 |
| 87 frame_source_->AddSource(primary_frame_source()); | 71 begin_frame_source_->SetClientReady(); |
| 88 primary_frame_source()->SetClientReady(); | |
| 89 | |
| 90 frame_source_->AddSource(unthrottled_frame_source_.get()); | |
| 91 unthrottled_frame_source_->SetClientReady(); | |
| 92 | |
| 93 if (settings_.throttle_frame_production) { | |
| 94 frame_source_->SetActiveSource(primary_frame_source()); | |
| 95 } else { | |
| 96 frame_source_->SetActiveSource(unthrottled_frame_source_.get()); | |
| 97 } | |
| 98 ProcessScheduledActions(); | 72 ProcessScheduledActions(); |
| 99 } | 73 } |
| 100 | 74 |
| 101 Scheduler::~Scheduler() { | 75 Scheduler::~Scheduler() { |
| 102 if (observing_frame_source_) | 76 if (observing_begin_frame_source_) |
| 103 frame_source_->RemoveObserver(this); | 77 begin_frame_source_->RemoveObserver(this); |
| 104 frame_source_->SetActiveSource(nullptr); | |
| 105 } | 78 } |
| 106 | 79 |
| 107 base::TimeTicks Scheduler::Now() const { | 80 base::TimeTicks Scheduler::Now() const { |
| 108 base::TimeTicks now = base::TimeTicks::Now(); | 81 base::TimeTicks now = base::TimeTicks::Now(); |
| 109 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), | 82 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), |
| 110 "Scheduler::Now", | 83 "Scheduler::Now", |
| 111 "now", | 84 "now", |
| 112 now); | 85 now); |
| 113 return now; | 86 return now; |
| 114 } | 87 } |
| 115 | 88 |
| 116 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, | |
| 117 base::TimeDelta interval) { | |
| 118 if (authoritative_vsync_interval_ != base::TimeDelta()) { | |
| 119 interval = authoritative_vsync_interval_; | |
| 120 } else if (interval == base::TimeDelta()) { | |
| 121 // TODO(brianderson): We should not be receiving 0 intervals. | |
| 122 interval = BeginFrameArgs::DefaultInterval(); | |
| 123 } | |
| 124 | |
| 125 last_vsync_timebase_ = timebase; | |
| 126 | |
| 127 if (synthetic_frame_source_) | |
| 128 synthetic_frame_source_->OnUpdateVSyncParameters(timebase, interval); | |
| 129 } | |
| 130 | |
| 131 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 89 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
| 132 DCHECK_GE(draw_time.ToInternalValue(), 0); | 90 DCHECK_GE(draw_time.ToInternalValue(), 0); |
| 133 estimated_parent_draw_time_ = draw_time; | 91 estimated_parent_draw_time_ = draw_time; |
| 134 } | 92 } |
| 135 | 93 |
| 136 void Scheduler::SetVisible(bool visible) { | 94 void Scheduler::SetVisible(bool visible) { |
| 137 state_machine_.SetVisible(visible); | 95 state_machine_.SetVisible(visible); |
| 138 UpdateCompositorTimingHistoryRecordingEnabled(); | 96 UpdateCompositorTimingHistoryRecordingEnabled(); |
| 139 ProcessScheduledActions(); | 97 ProcessScheduledActions(); |
| 140 } | 98 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); | 192 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); |
| 235 begin_retro_frame_args_.clear(); | 193 begin_retro_frame_args_.clear(); |
| 236 begin_retro_frame_task_.Cancel(); | 194 begin_retro_frame_task_.Cancel(); |
| 237 state_machine_.DidLoseOutputSurface(); | 195 state_machine_.DidLoseOutputSurface(); |
| 238 UpdateCompositorTimingHistoryRecordingEnabled(); | 196 UpdateCompositorTimingHistoryRecordingEnabled(); |
| 239 ProcessScheduledActions(); | 197 ProcessScheduledActions(); |
| 240 } | 198 } |
| 241 | 199 |
| 242 void Scheduler::DidCreateAndInitializeOutputSurface() { | 200 void Scheduler::DidCreateAndInitializeOutputSurface() { |
| 243 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); | 201 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); |
| 244 DCHECK(!observing_frame_source_); | 202 DCHECK(!observing_begin_frame_source_); |
| 245 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); | 203 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); |
| 246 state_machine_.DidCreateAndInitializeOutputSurface(); | 204 state_machine_.DidCreateAndInitializeOutputSurface(); |
| 247 compositor_timing_history_->DidCreateAndInitializeOutputSurface(); | 205 compositor_timing_history_->DidCreateAndInitializeOutputSurface(); |
| 248 UpdateCompositorTimingHistoryRecordingEnabled(); | 206 UpdateCompositorTimingHistoryRecordingEnabled(); |
| 249 ProcessScheduledActions(); | 207 ProcessScheduledActions(); |
| 250 } | 208 } |
| 251 | 209 |
| 252 void Scheduler::NotifyBeginMainFrameStarted( | 210 void Scheduler::NotifyBeginMainFrameStarted( |
| 253 base::TimeTicks main_thread_start_time) { | 211 base::TimeTicks main_thread_start_time) { |
| 254 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); | 212 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 265 | 223 |
| 266 // Tying this to SendBeginMainFrameNotExpectedSoon will have some | 224 // Tying this to SendBeginMainFrameNotExpectedSoon will have some |
| 267 // false negatives, but we want to avoid running long idle tasks when | 225 // false negatives, but we want to avoid running long idle tasks when |
| 268 // we are actually active. | 226 // we are actually active. |
| 269 client_->SendBeginMainFrameNotExpectedSoon(); | 227 client_->SendBeginMainFrameNotExpectedSoon(); |
| 270 } | 228 } |
| 271 | 229 |
| 272 void Scheduler::SetupNextBeginFrameIfNeeded() { | 230 void Scheduler::SetupNextBeginFrameIfNeeded() { |
| 273 // Never call SetNeedsBeginFrames if the frame source already has the right | 231 // Never call SetNeedsBeginFrames if the frame source already has the right |
| 274 // value. | 232 // value. |
| 275 if (observing_frame_source_ != state_machine_.BeginFrameNeeded()) { | 233 if (observing_begin_frame_source_ != state_machine_.BeginFrameNeeded()) { |
| 276 if (state_machine_.BeginFrameNeeded()) { | 234 if (state_machine_.BeginFrameNeeded()) { |
| 277 // Call AddObserver as soon as possible. | 235 // Call AddObserver as soon as possible. |
| 278 observing_frame_source_ = true; | 236 observing_begin_frame_source_ = true; |
| 279 frame_source_->AddObserver(this); | 237 begin_frame_source_->AddObserver(this); |
| 280 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, | 238 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, |
| 281 true); | 239 true); |
| 282 } else if (state_machine_.begin_impl_frame_state() == | 240 } else if (state_machine_.begin_impl_frame_state() == |
| 283 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { | 241 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { |
| 284 // Call RemoveObserver in between frames only. | 242 // Call RemoveObserver in between frames only. |
| 285 observing_frame_source_ = false; | 243 observing_begin_frame_source_ = false; |
| 286 frame_source_->RemoveObserver(this); | 244 begin_frame_source_->RemoveObserver(this); |
| 287 BeginImplFrameNotExpectedSoon(); | 245 BeginImplFrameNotExpectedSoon(); |
| 288 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, | 246 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, |
| 289 false); | 247 false); |
| 290 } | 248 } |
| 291 } | 249 } |
| 292 | 250 |
| 293 PostBeginRetroFrameIfNeeded(); | 251 PostBeginRetroFrameIfNeeded(); |
| 294 } | 252 } |
| 295 | 253 |
| 296 void Scheduler::OnBeginFrameSourcePausedChanged(bool paused) { | 254 void Scheduler::OnBeginFrameSourcePausedChanged(bool paused) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 // actually make rendering for this call, handle it like a "retro frame". | 291 // actually make rendering for this call, handle it like a "retro frame". |
| 334 // TODO(brainderson): Add a test for this functionality ASAP! | 292 // TODO(brainderson): Add a test for this functionality ASAP! |
| 335 if (adjusted_args.type == BeginFrameArgs::MISSED) { | 293 if (adjusted_args.type == BeginFrameArgs::MISSED) { |
| 336 begin_retro_frame_args_.push_back(adjusted_args); | 294 begin_retro_frame_args_.push_back(adjusted_args); |
| 337 PostBeginRetroFrameIfNeeded(); | 295 PostBeginRetroFrameIfNeeded(); |
| 338 return true; | 296 return true; |
| 339 } | 297 } |
| 340 | 298 |
| 341 bool should_defer_begin_frame = | 299 bool should_defer_begin_frame = |
| 342 !begin_retro_frame_args_.empty() || | 300 !begin_retro_frame_args_.empty() || |
| 343 !begin_retro_frame_task_.IsCancelled() || !observing_frame_source_ || | 301 !begin_retro_frame_task_.IsCancelled() || |
| 302 !observing_begin_frame_source_ || | |
| 344 (state_machine_.begin_impl_frame_state() != | 303 (state_machine_.begin_impl_frame_state() != |
| 345 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 304 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 346 | 305 |
| 347 if (should_defer_begin_frame) { | 306 if (should_defer_begin_frame) { |
| 348 begin_retro_frame_args_.push_back(adjusted_args); | 307 begin_retro_frame_args_.push_back(adjusted_args); |
| 349 TRACE_EVENT_INSTANT0( | 308 TRACE_EVENT_INSTANT0( |
| 350 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); | 309 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); |
| 351 // Queuing the frame counts as "using it", so we need to return true. | 310 // Queuing the frame counts as "using it", so we need to return true. |
| 352 } else { | 311 } else { |
| 353 BeginImplFrameWithDeadline(adjusted_args); | 312 BeginImplFrameWithDeadline(adjusted_args); |
| 354 } | 313 } |
| 355 return true; | 314 return true; |
| 356 } | 315 } |
| 357 | 316 |
| 358 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 317 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 359 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | 318 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 360 ProcessScheduledActions(); | 319 ProcessScheduledActions(); |
| 361 } | 320 } |
| 362 | 321 |
| 363 void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) { | |
| 364 authoritative_vsync_interval_ = interval; | |
| 365 if (synthetic_frame_source_) { | |
| 366 synthetic_frame_source_->OnUpdateVSyncParameters(last_vsync_timebase_, | |
| 367 interval); | |
| 368 } | |
| 369 } | |
| 370 | |
| 371 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { | 322 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { |
| 372 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); | 323 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); |
| 373 ProcessScheduledActions(); | 324 ProcessScheduledActions(); |
| 374 } | 325 } |
| 375 | 326 |
| 376 void Scheduler::OnDrawForOutputSurface(bool resourceless_software_draw) { | 327 void Scheduler::OnDrawForOutputSurface(bool resourceless_software_draw) { |
| 377 DCHECK(settings_.using_synchronous_renderer_compositor); | 328 DCHECK(settings_.using_synchronous_renderer_compositor); |
| 378 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 329 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 379 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 330 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 380 DCHECK(!BeginImplFrameDeadlinePending()); | 331 DCHECK(!BeginImplFrameDeadlinePending()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 while (!begin_retro_frame_args_.empty()) { | 363 while (!begin_retro_frame_args_.empty()) { |
| 413 const BeginFrameArgs& args = begin_retro_frame_args_.front(); | 364 const BeginFrameArgs& args = begin_retro_frame_args_.front(); |
| 414 base::TimeTicks expiration_time = args.deadline; | 365 base::TimeTicks expiration_time = args.deadline; |
| 415 if (now <= expiration_time) | 366 if (now <= expiration_time) |
| 416 break; | 367 break; |
| 417 TRACE_EVENT_INSTANT2( | 368 TRACE_EVENT_INSTANT2( |
| 418 "cc", "Scheduler::BeginRetroFrame discarding", TRACE_EVENT_SCOPE_THREAD, | 369 "cc", "Scheduler::BeginRetroFrame discarding", TRACE_EVENT_SCOPE_THREAD, |
| 419 "expiration_time - now", (expiration_time - now).InMillisecondsF(), | 370 "expiration_time - now", (expiration_time - now).InMillisecondsF(), |
| 420 "BeginFrameArgs", begin_retro_frame_args_.front().AsValue()); | 371 "BeginFrameArgs", begin_retro_frame_args_.front().AsValue()); |
| 421 begin_retro_frame_args_.pop_front(); | 372 begin_retro_frame_args_.pop_front(); |
| 422 frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); | 373 begin_frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); |
| 423 } | 374 } |
| 424 | 375 |
| 425 if (begin_retro_frame_args_.empty()) { | 376 if (begin_retro_frame_args_.empty()) { |
| 426 TRACE_EVENT_INSTANT0("cc", | 377 TRACE_EVENT_INSTANT0("cc", |
| 427 "Scheduler::BeginRetroFrames all expired", | 378 "Scheduler::BeginRetroFrames all expired", |
| 428 TRACE_EVENT_SCOPE_THREAD); | 379 TRACE_EVENT_SCOPE_THREAD); |
| 429 } else { | 380 } else { |
| 430 BeginFrameArgs front = begin_retro_frame_args_.front(); | 381 BeginFrameArgs front = begin_retro_frame_args_.front(); |
| 431 begin_retro_frame_args_.pop_front(); | 382 begin_retro_frame_args_.pop_front(); |
| 432 BeginImplFrameWithDeadline(front); | 383 BeginImplFrameWithDeadline(front); |
| 433 } | 384 } |
| 434 } | 385 } |
| 435 | 386 |
| 436 // There could be a race between the posted BeginRetroFrame and a new | 387 // There could be a race between the posted BeginRetroFrame and a new |
| 437 // BeginFrame arriving via the normal mechanism. Scheduler::BeginFrame | 388 // BeginFrame arriving via the normal mechanism. Scheduler::BeginFrame |
| 438 // will check if there is a pending BeginRetroFrame to ensure we handle | 389 // will check if there is a pending BeginRetroFrame to ensure we handle |
| 439 // BeginFrames in FIFO order. | 390 // BeginFrames in FIFO order. |
| 440 void Scheduler::PostBeginRetroFrameIfNeeded() { | 391 void Scheduler::PostBeginRetroFrameIfNeeded() { |
| 441 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 392 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 442 "Scheduler::PostBeginRetroFrameIfNeeded", | 393 "Scheduler::PostBeginRetroFrameIfNeeded", |
| 443 "state", | 394 "state", |
| 444 AsValue()); | 395 AsValue()); |
| 445 if (!observing_frame_source_) | 396 if (!observing_begin_frame_source_) |
| 446 return; | 397 return; |
| 447 | 398 |
| 448 if (begin_retro_frame_args_.empty() || !begin_retro_frame_task_.IsCancelled()) | 399 if (begin_retro_frame_args_.empty() || !begin_retro_frame_task_.IsCancelled()) |
| 449 return; | 400 return; |
| 450 | 401 |
| 451 // begin_retro_frame_args_ should always be empty for the | 402 // begin_retro_frame_args_ should always be empty for the |
| 452 // synchronous compositor. | 403 // synchronous compositor. |
| 453 DCHECK(!settings_.using_synchronous_renderer_compositor); | 404 DCHECK(!settings_.using_synchronous_renderer_compositor); |
| 454 | 405 |
| 455 if (state_machine_.begin_impl_frame_state() != | 406 if (state_machine_.begin_impl_frame_state() != |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 bmf_to_activate_estimate); | 456 bmf_to_activate_estimate); |
| 506 | 457 |
| 507 if (ShouldRecoverMainLatency(adjusted_args, can_activate_before_deadline)) { | 458 if (ShouldRecoverMainLatency(adjusted_args, can_activate_before_deadline)) { |
| 508 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", | 459 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", |
| 509 TRACE_EVENT_SCOPE_THREAD); | 460 TRACE_EVENT_SCOPE_THREAD); |
| 510 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); | 461 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); |
| 511 } else if (ShouldRecoverImplLatency(adjusted_args, | 462 } else if (ShouldRecoverImplLatency(adjusted_args, |
| 512 can_activate_before_deadline)) { | 463 can_activate_before_deadline)) { |
| 513 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency", | 464 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency", |
| 514 TRACE_EVENT_SCOPE_THREAD); | 465 TRACE_EVENT_SCOPE_THREAD); |
| 515 frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); | 466 begin_frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); |
| 516 return; | 467 return; |
| 517 } | 468 } |
| 518 | 469 |
| 519 BeginImplFrame(adjusted_args); | 470 BeginImplFrame(adjusted_args); |
| 520 | 471 |
| 521 // The deadline will be scheduled in ProcessScheduledActions. | 472 // The deadline will be scheduled in ProcessScheduledActions. |
| 522 state_machine_.OnBeginImplFrameDeadlinePending(); | 473 state_machine_.OnBeginImplFrameDeadlinePending(); |
| 523 ProcessScheduledActions(); | 474 ProcessScheduledActions(); |
| 524 } | 475 } |
| 525 | 476 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 537 compositor_timing_history_->WillFinishImplFrame( | 488 compositor_timing_history_->WillFinishImplFrame( |
| 538 state_machine_.needs_redraw()); | 489 state_machine_.needs_redraw()); |
| 539 FinishImplFrame(); | 490 FinishImplFrame(); |
| 540 } | 491 } |
| 541 | 492 |
| 542 void Scheduler::FinishImplFrame() { | 493 void Scheduler::FinishImplFrame() { |
| 543 state_machine_.OnBeginImplFrameIdle(); | 494 state_machine_.OnBeginImplFrameIdle(); |
| 544 ProcessScheduledActions(); | 495 ProcessScheduledActions(); |
| 545 | 496 |
| 546 client_->DidFinishImplFrame(); | 497 client_->DidFinishImplFrame(); |
| 547 frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); | 498 begin_frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); |
| 548 begin_impl_frame_tracker_.Finish(); | 499 begin_impl_frame_tracker_.Finish(); |
| 549 } | 500 } |
| 550 | 501 |
| 551 // BeginImplFrame starts a compositor frame that will wait up until a deadline | 502 // BeginImplFrame starts a compositor frame that will wait up until a deadline |
| 552 // for a BeginMainFrame+activation to complete before it times out and draws | 503 // for a BeginMainFrame+activation to complete before it times out and draws |
| 553 // any asynchronous animation and scroll/pinch updates. | 504 // any asynchronous animation and scroll/pinch updates. |
| 554 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 505 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
| 555 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 506 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 556 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 507 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 557 DCHECK(!BeginImplFrameDeadlinePending()); | 508 DCHECK(!BeginImplFrameDeadlinePending()); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 state->BeginDictionary("state_machine"); | 739 state->BeginDictionary("state_machine"); |
| 789 state_machine_.AsValueInto(state); | 740 state_machine_.AsValueInto(state); |
| 790 state->EndDictionary(); | 741 state->EndDictionary(); |
| 791 | 742 |
| 792 // Only trace frame sources when explicitly enabled - http://crbug.com/420607 | 743 // Only trace frame sources when explicitly enabled - http://crbug.com/420607 |
| 793 bool frame_tracing_enabled = false; | 744 bool frame_tracing_enabled = false; |
| 794 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 745 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 795 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), | 746 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), |
| 796 &frame_tracing_enabled); | 747 &frame_tracing_enabled); |
| 797 if (frame_tracing_enabled) { | 748 if (frame_tracing_enabled) { |
| 798 state->BeginDictionary("frame_source_"); | 749 state->BeginDictionary("begin_frame_source_"); |
| 799 frame_source_->AsValueInto(state); | 750 begin_frame_source_->AsValueInto(state); |
| 800 state->EndDictionary(); | 751 state->EndDictionary(); |
| 801 } | 752 } |
| 802 | 753 |
| 803 state->BeginDictionary("scheduler_state"); | 754 state->BeginDictionary("scheduler_state"); |
| 804 state->SetBoolean("external_frame_source_", !!external_frame_source_); | |
| 805 state->SetBoolean("throttle_frame_production_", | 755 state->SetBoolean("throttle_frame_production_", |
| 806 settings_.throttle_frame_production); | 756 settings_.throttle_frame_production); |
| 807 state->SetDouble("authoritative_vsync_interval_ms", | |
| 808 authoritative_vsync_interval_.InMillisecondsF()); | |
| 809 state->SetDouble( | |
| 810 "last_vsync_timebase_ms", | |
| 811 (last_vsync_timebase_ - base::TimeTicks()).InMillisecondsF()); | |
| 812 state->SetDouble("estimated_parent_draw_time_ms", | 757 state->SetDouble("estimated_parent_draw_time_ms", |
| 813 estimated_parent_draw_time_.InMillisecondsF()); | 758 estimated_parent_draw_time_.InMillisecondsF()); |
| 814 state->SetBoolean("observing_frame_source", observing_frame_source_); | 759 state->SetBoolean("observing_frame_source", observing_begin_frame_source_); |
|
Sami
2016/03/09 14:36:23
nit: please update the string to match the new nam
| |
| 815 state->SetInteger("begin_retro_frame_args", | 760 state->SetInteger("begin_retro_frame_args", |
| 816 static_cast<int>(begin_retro_frame_args_.size())); | 761 static_cast<int>(begin_retro_frame_args_.size())); |
| 817 state->SetBoolean("begin_retro_frame_task", | 762 state->SetBoolean("begin_retro_frame_task", |
| 818 !begin_retro_frame_task_.IsCancelled()); | 763 !begin_retro_frame_task_.IsCancelled()); |
| 819 state->SetBoolean("begin_impl_frame_deadline_task", | 764 state->SetBoolean("begin_impl_frame_deadline_task", |
| 820 !begin_impl_frame_deadline_task_.IsCancelled()); | 765 !begin_impl_frame_deadline_task_.IsCancelled()); |
| 821 state->SetString("inside_action", | 766 state->SetString("inside_action", |
| 822 SchedulerStateMachine::ActionToString(inside_action_)); | 767 SchedulerStateMachine::ActionToString(inside_action_)); |
| 823 | 768 |
| 824 state->BeginDictionary("begin_impl_frame_args"); | 769 state->BeginDictionary("begin_impl_frame_args"); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 } | 851 } |
| 907 | 852 |
| 908 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 853 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 909 return (state_machine_.begin_main_frame_state() == | 854 return (state_machine_.begin_main_frame_state() == |
| 910 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 855 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
| 911 state_machine_.begin_main_frame_state() == | 856 state_machine_.begin_main_frame_state() == |
| 912 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 857 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
| 913 } | 858 } |
| 914 | 859 |
| 915 } // namespace cc | 860 } // namespace cc |
| OLD | NEW |