| 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 26 matching lines...) Expand all Loading... |
| 37 client_(client), | 37 client_(client), |
| 38 layer_tree_host_id_(layer_tree_host_id), | 38 layer_tree_host_id_(layer_tree_host_id), |
| 39 task_runner_(task_runner), | 39 task_runner_(task_runner), |
| 40 compositor_timing_history_(std::move(compositor_timing_history)), | 40 compositor_timing_history_(std::move(compositor_timing_history)), |
| 41 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | 41 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
| 42 state_machine_(settings), | 42 state_machine_(settings), |
| 43 weak_factory_(this) { | 43 weak_factory_(this) { |
| 44 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); | 44 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); |
| 45 DCHECK(client_); | 45 DCHECK(client_); |
| 46 DCHECK(!state_machine_.BeginFrameNeeded()); | 46 DCHECK(!state_machine_.BeginFrameNeeded()); |
| 47 |
| 48 begin_impl_frame_deadline_closure_ = base::Bind( |
| 49 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); |
| 50 |
| 47 ProcessScheduledActions(); | 51 ProcessScheduledActions(); |
| 48 } | 52 } |
| 49 | 53 |
| 50 Scheduler::~Scheduler() { | 54 Scheduler::~Scheduler() { |
| 51 SetBeginFrameSource(nullptr); | 55 SetBeginFrameSource(nullptr); |
| 52 } | 56 } |
| 53 | 57 |
| 54 void Scheduler::Stop() { | 58 void Scheduler::Stop() { |
| 55 stopped_ = true; | 59 stopped_ = true; |
| 56 } | 60 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 218 } |
| 215 | 219 |
| 216 void Scheduler::SetupNextBeginFrameIfNeeded() { | 220 void Scheduler::SetupNextBeginFrameIfNeeded() { |
| 217 if (state_machine_.begin_impl_frame_state() != | 221 if (state_machine_.begin_impl_frame_state() != |
| 218 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { | 222 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { |
| 219 return; | 223 return; |
| 220 } | 224 } |
| 221 | 225 |
| 222 bool needs_begin_frames = state_machine_.BeginFrameNeeded(); | 226 bool needs_begin_frames = state_machine_.BeginFrameNeeded(); |
| 223 if (needs_begin_frames && !observing_begin_frame_source_) { | 227 if (needs_begin_frames && !observing_begin_frame_source_) { |
| 224 StartObservingBeginFrameSource(); | 228 observing_begin_frame_source_ = true; |
| 229 if (begin_frame_source_) |
| 230 begin_frame_source_->AddObserver(this); |
| 231 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, true); |
| 225 } else if (!needs_begin_frames && observing_begin_frame_source_) { | 232 } else if (!needs_begin_frames && observing_begin_frame_source_) { |
| 226 StopObservingBeginFrameSource(); | 233 observing_begin_frame_source_ = false; |
| 227 } | 234 if (begin_frame_source_) |
| 228 | 235 begin_frame_source_->RemoveObserver(this); |
| 229 if (missed_begin_frame_args_.IsValid()) { | 236 missed_begin_frame_task_.Cancel(); |
| 230 DCHECK(observing_begin_frame_source_); | 237 BeginImplFrameNotExpectedSoon(); |
| 231 DCHECK(missed_begin_frame_task_.IsCancelled()); | 238 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, |
| 232 missed_begin_frame_task_.Reset(base::Bind(&Scheduler::BeginImplFrameMissed, | 239 false); |
| 233 weak_factory_.GetWeakPtr(), | |
| 234 missed_begin_frame_args_)); | |
| 235 missed_begin_frame_args_ = BeginFrameArgs(); | |
| 236 task_runner_->PostTask(FROM_HERE, missed_begin_frame_task_.callback()); | |
| 237 } | 240 } |
| 238 } | 241 } |
| 239 | 242 |
| 240 void Scheduler::StartObservingBeginFrameSource() { | |
| 241 observing_begin_frame_source_ = true; | |
| 242 | |
| 243 if (begin_frame_source_) | |
| 244 begin_frame_source_->AddObserver(this); | |
| 245 | |
| 246 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, true); | |
| 247 } | |
| 248 | |
| 249 void Scheduler::StopObservingBeginFrameSource() { | |
| 250 observing_begin_frame_source_ = false; | |
| 251 | |
| 252 if (begin_frame_source_) | |
| 253 begin_frame_source_->RemoveObserver(this); | |
| 254 | |
| 255 missed_begin_frame_task_.Cancel(); | |
| 256 | |
| 257 if (missed_begin_frame_args_.IsValid()) { | |
| 258 // We need to confirm the ignored BeginFrame, since we don't have updates. | |
| 259 // To persist the confirmation for future BeginFrameAcks, we let the state | |
| 260 // machine know about the BeginFrame. | |
| 261 state_machine_.OnBeginFrameDroppedNotObserving( | |
| 262 missed_begin_frame_args_.source_id, | |
| 263 missed_begin_frame_args_.sequence_number); | |
| 264 SendBeginFrameAck(missed_begin_frame_args_, kBeginFrameSkipped); | |
| 265 missed_begin_frame_args_ = BeginFrameArgs(); | |
| 266 } | |
| 267 | |
| 268 BeginImplFrameNotExpectedSoon(); | |
| 269 | |
| 270 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, false); | |
| 271 } | |
| 272 | |
| 273 void Scheduler::OnBeginFrameSourcePausedChanged(bool paused) { | 243 void Scheduler::OnBeginFrameSourcePausedChanged(bool paused) { |
| 274 if (state_machine_.begin_frame_source_paused() == paused) | 244 if (state_machine_.begin_frame_source_paused() == paused) |
| 275 return; | 245 return; |
| 276 TRACE_EVENT_INSTANT1("cc", "Scheduler::SetBeginFrameSourcePaused", | 246 TRACE_EVENT_INSTANT1("cc", "Scheduler::SetBeginFrameSourcePaused", |
| 277 TRACE_EVENT_SCOPE_THREAD, "paused", paused); | 247 TRACE_EVENT_SCOPE_THREAD, "paused", paused); |
| 278 state_machine_.SetBeginFrameSourcePaused(paused); | 248 state_machine_.SetBeginFrameSourcePaused(paused); |
| 279 ProcessScheduledActions(); | 249 ProcessScheduledActions(); |
| 280 } | 250 } |
| 281 | 251 |
| 282 // BeginFrame is the mechanism that tells us that now is a good time to start | 252 // BeginFrame is the mechanism that tells us that now is a good time to start |
| (...skipping 16 matching lines...) Expand all Loading... |
| 299 // Trace this begin frame time through the Chrome stack | 269 // Trace this begin frame time through the Chrome stack |
| 300 TRACE_EVENT_FLOW_BEGIN0( | 270 TRACE_EVENT_FLOW_BEGIN0( |
| 301 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", | 271 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", |
| 302 args.frame_time.ToInternalValue()); | 272 args.frame_time.ToInternalValue()); |
| 303 | 273 |
| 304 if (settings_.using_synchronous_renderer_compositor) { | 274 if (settings_.using_synchronous_renderer_compositor) { |
| 305 BeginImplFrameSynchronous(args); | 275 BeginImplFrameSynchronous(args); |
| 306 return true; | 276 return true; |
| 307 } | 277 } |
| 308 | 278 |
| 309 // Cancel any pending missed begin frame task because we're either handling | 279 if (inside_process_scheduled_actions_) { |
| 310 // this begin frame immediately or saving it as a missed frame for which we | 280 // The BFS can send a missed begin frame inside AddObserver. We can't handle |
| 311 // will post a new task. | 281 // a begin frame inside ProcessScheduledActions so post a task. |
| 312 missed_begin_frame_task_.Cancel(); | 282 DCHECK_EQ(args.type, BeginFrameArgs::MISSED); |
| 313 | 283 DCHECK(missed_begin_frame_task_.IsCancelled()); |
| 314 // Save args if we're inside ProcessScheduledActions or the middle of a frame. | 284 missed_begin_frame_task_.Reset(base::Bind( |
| 315 // At the end of ProcessScheduledActions and at the end of the current frame, | 285 &Scheduler::BeginImplFrameWithDeadline, base::Unretained(this), args)); |
| 316 // we will post a task to handle the missed begin frame. | 286 task_runner_->PostTask(FROM_HERE, missed_begin_frame_task_.callback()); |
| 317 bool inside_begin_frame = | |
| 318 state_machine_.begin_impl_frame_state() == | |
| 319 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; | |
| 320 if (inside_process_scheduled_actions_ || inside_begin_frame) { | |
| 321 missed_begin_frame_args_ = args; | |
| 322 missed_begin_frame_args_.type = BeginFrameArgs::MISSED; | |
| 323 return true; | 287 return true; |
| 324 } | 288 } |
| 325 | 289 |
| 326 BeginImplFrameWithDeadline(args); | 290 BeginImplFrameWithDeadline(args); |
| 327 return true; | 291 return true; |
| 328 } | 292 } |
| 329 | 293 |
| 330 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { | 294 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { |
| 331 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); | 295 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); |
| 332 ProcessScheduledActions(); | 296 ProcessScheduledActions(); |
| 333 } | 297 } |
| 334 | 298 |
| 335 void Scheduler::OnDrawForCompositorFrameSink(bool resourceless_software_draw) { | 299 void Scheduler::OnDrawForCompositorFrameSink(bool resourceless_software_draw) { |
| 336 DCHECK(settings_.using_synchronous_renderer_compositor); | 300 DCHECK(settings_.using_synchronous_renderer_compositor); |
| 337 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 301 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 338 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 302 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 339 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); | 303 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); |
| 340 | 304 |
| 341 state_machine_.SetResourcelessSoftwareDraw(resourceless_software_draw); | 305 state_machine_.SetResourcelessSoftwareDraw(resourceless_software_draw); |
| 342 state_machine_.OnBeginImplFrameDeadline(); | 306 state_machine_.OnBeginImplFrameDeadline(); |
| 343 ProcessScheduledActions(); | 307 ProcessScheduledActions(); |
| 344 | 308 |
| 345 state_machine_.OnBeginImplFrameIdle(); | 309 state_machine_.OnBeginImplFrameIdle(); |
| 346 ProcessScheduledActions(); | 310 ProcessScheduledActions(); |
| 347 state_machine_.SetResourcelessSoftwareDraw(false); | 311 state_machine_.SetResourcelessSoftwareDraw(false); |
| 348 } | 312 } |
| 349 | 313 |
| 350 void Scheduler::BeginImplFrameMissed(const BeginFrameArgs& args) { | 314 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { |
| 351 // The storage for the args is owned by the task so copy them before canceling | 315 // The storage for |args| is owned by the missed begin frame task. Therefore |
| 352 // the task. | 316 // save |args| before cancelling the task either here or in the deadline. |
| 353 BeginFrameArgs copy_args = args; | 317 BeginFrameArgs adjusted_args = args; |
| 318 // Cancel the missed begin frame task in case the BFS sends a begin frame |
| 319 // before the missed frame task runs. |
| 354 missed_begin_frame_task_.Cancel(); | 320 missed_begin_frame_task_.Cancel(); |
| 355 BeginImplFrameWithDeadline(copy_args); | |
| 356 } | |
| 357 | |
| 358 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { | |
| 359 DCHECK(!inside_process_scheduled_actions_); | |
| 360 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | |
| 361 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | |
| 362 | 321 |
| 363 base::TimeTicks now = Now(); | 322 base::TimeTicks now = Now(); |
| 364 | 323 |
| 365 // Discard missed begin frames if they are too late. | 324 // Discard missed begin frames if they are too late. |
| 366 if (args.type == BeginFrameArgs::MISSED && now > args.deadline) { | 325 if (adjusted_args.type == BeginFrameArgs::MISSED && |
| 326 now > adjusted_args.deadline) { |
| 367 skipped_last_frame_missed_exceeded_deadline_ = true; | 327 skipped_last_frame_missed_exceeded_deadline_ = true; |
| 368 SendBeginFrameAck(args, kBeginFrameSkipped); | 328 SendBeginFrameAck(adjusted_args, kBeginFrameSkipped); |
| 369 return; | 329 return; |
| 370 } | 330 } |
| 371 | 331 |
| 372 skipped_last_frame_missed_exceeded_deadline_ = false; | 332 skipped_last_frame_missed_exceeded_deadline_ = false; |
| 373 | 333 |
| 334 // Run the previous deadline if any. |
| 335 if (state_machine_.begin_impl_frame_state() == |
| 336 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) { |
| 337 OnBeginImplFrameDeadline(); |
| 338 // We may not need begin frames any longer. |
| 339 if (!observing_begin_frame_source_) { |
| 340 // We need to confirm the ignored BeginFrame, since we don't have updates. |
| 341 // To persist the confirmation for future BeginFrameAcks, we let the state |
| 342 // machine know about the BeginFrame. |
| 343 state_machine_.OnBeginFrameDroppedNotObserving(args.source_id, |
| 344 args.sequence_number); |
| 345 SendBeginFrameAck(adjusted_args, kBeginFrameSkipped); |
| 346 return; |
| 347 } |
| 348 } |
| 349 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 350 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 351 |
| 374 bool main_thread_is_in_high_latency_mode = | 352 bool main_thread_is_in_high_latency_mode = |
| 375 state_machine_.main_thread_missed_last_deadline(); | 353 state_machine_.main_thread_missed_last_deadline(); |
| 376 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", | 354 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", |
| 377 args.AsValue(), "main_thread_missed_last_deadline", | 355 adjusted_args.AsValue(), "main_thread_missed_last_deadline", |
| 378 main_thread_is_in_high_latency_mode); | 356 main_thread_is_in_high_latency_mode); |
| 379 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 357 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 380 "MainThreadLatency", main_thread_is_in_high_latency_mode); | 358 "MainThreadLatency", main_thread_is_in_high_latency_mode); |
| 381 | 359 |
| 382 BeginFrameArgs adjusted_args = args; | 360 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 361 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 362 |
| 383 adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate(); | 363 adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate(); |
| 384 adjusted_args.deadline -= kDeadlineFudgeFactor; | 364 adjusted_args.deadline -= kDeadlineFudgeFactor; |
| 385 | 365 |
| 386 base::TimeDelta bmf_start_to_activate = | 366 base::TimeDelta bmf_start_to_activate = |
| 387 compositor_timing_history_ | 367 compositor_timing_history_ |
| 388 ->BeginMainFrameStartToCommitDurationEstimate() + | 368 ->BeginMainFrameStartToCommitDurationEstimate() + |
| 389 compositor_timing_history_->CommitToReadyToActivateDurationEstimate() + | 369 compositor_timing_history_->CommitToReadyToActivateDurationEstimate() + |
| 390 compositor_timing_history_->ActivateDurationEstimate(); | 370 compositor_timing_history_->ActivateDurationEstimate(); |
| 391 | 371 |
| 392 base::TimeDelta bmf_to_activate_estimate_critical = | 372 base::TimeDelta bmf_to_activate_estimate_critical = |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 begin_main_frame_args_.on_critical_path = !ImplLatencyTakesPriority(); | 421 begin_main_frame_args_.on_critical_path = !ImplLatencyTakesPriority(); |
| 442 | 422 |
| 443 BeginImplFrame(args, Now()); | 423 BeginImplFrame(args, Now()); |
| 444 compositor_timing_history_->WillFinishImplFrame( | 424 compositor_timing_history_->WillFinishImplFrame( |
| 445 state_machine_.needs_redraw()); | 425 state_machine_.needs_redraw()); |
| 446 FinishImplFrame(); | 426 FinishImplFrame(); |
| 447 } | 427 } |
| 448 | 428 |
| 449 void Scheduler::FinishImplFrame() { | 429 void Scheduler::FinishImplFrame() { |
| 450 state_machine_.OnBeginImplFrameIdle(); | 430 state_machine_.OnBeginImplFrameIdle(); |
| 451 | |
| 452 // Call this before ProcessScheduledActions because we might send an ack for | |
| 453 // missed begin frame there. | |
| 454 SendBeginFrameAck(begin_impl_frame_tracker_.Current(), kBeginFrameFinished); | |
| 455 | |
| 456 ProcessScheduledActions(); | 431 ProcessScheduledActions(); |
| 457 | 432 |
| 458 client_->DidFinishImplFrame(); | 433 client_->DidFinishImplFrame(); |
| 434 SendBeginFrameAck(begin_main_frame_args_, kBeginFrameFinished); |
| 459 begin_impl_frame_tracker_.Finish(); | 435 begin_impl_frame_tracker_.Finish(); |
| 460 } | 436 } |
| 461 | 437 |
| 462 void Scheduler::SendBeginFrameAck(const BeginFrameArgs& args, | 438 void Scheduler::SendBeginFrameAck(const BeginFrameArgs& args, |
| 463 BeginFrameResult result) { | 439 BeginFrameResult result) { |
| 464 if (!begin_frame_source_) | 440 if (!begin_frame_source_) |
| 465 return; | 441 return; |
| 466 | 442 |
| 467 uint64_t latest_confirmed_sequence_number = | 443 uint64_t latest_confirmed_sequence_number = |
| 468 BeginFrameArgs::kInvalidFrameNumber; | 444 BeginFrameArgs::kInvalidFrameNumber; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 499 state_machine_.NewActiveTreeLikely(), args.frame_time, args.type, now); | 475 state_machine_.NewActiveTreeLikely(), args.frame_time, args.type, now); |
| 500 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current()); | 476 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current()); |
| 501 | 477 |
| 502 ProcessScheduledActions(); | 478 ProcessScheduledActions(); |
| 503 } | 479 } |
| 504 | 480 |
| 505 void Scheduler::ScheduleBeginImplFrameDeadline() { | 481 void Scheduler::ScheduleBeginImplFrameDeadline() { |
| 506 // The synchronous compositor does not post a deadline task. | 482 // The synchronous compositor does not post a deadline task. |
| 507 DCHECK(!settings_.using_synchronous_renderer_compositor); | 483 DCHECK(!settings_.using_synchronous_renderer_compositor); |
| 508 | 484 |
| 509 begin_impl_frame_deadline_task_.Reset(base::Bind( | 485 begin_impl_frame_deadline_task_.Cancel(); |
| 510 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr())); | 486 begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_); |
| 511 | 487 |
| 512 begin_impl_frame_deadline_mode_ = | 488 begin_impl_frame_deadline_mode_ = |
| 513 state_machine_.CurrentBeginImplFrameDeadlineMode(); | 489 state_machine_.CurrentBeginImplFrameDeadlineMode(); |
| 514 switch (begin_impl_frame_deadline_mode_) { | 490 switch (begin_impl_frame_deadline_mode_) { |
| 515 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE: | 491 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE: |
| 516 // No deadline. | 492 // No deadline. |
| 517 return; | 493 return; |
| 518 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: | 494 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: |
| 519 // We are ready to draw a new active tree immediately. | 495 // We are ready to draw a new active tree immediately. |
| 520 // We don't use Now() here because it's somewhat expensive to call. | 496 // We don't use Now() here because it's somewhat expensive to call. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 } | 679 } |
| 704 | 680 |
| 705 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 681 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 706 Scheduler::AsValue() const { | 682 Scheduler::AsValue() const { |
| 707 auto state = base::MakeUnique<base::trace_event::TracedValue>(); | 683 auto state = base::MakeUnique<base::trace_event::TracedValue>(); |
| 708 AsValueInto(state.get()); | 684 AsValueInto(state.get()); |
| 709 return std::move(state); | 685 return std::move(state); |
| 710 } | 686 } |
| 711 | 687 |
| 712 void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const { | 688 void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const { |
| 689 base::TimeTicks now = Now(); |
| 690 |
| 713 state->BeginDictionary("state_machine"); | 691 state->BeginDictionary("state_machine"); |
| 714 state_machine_.AsValueInto(state); | 692 state_machine_.AsValueInto(state); |
| 715 state->EndDictionary(); | 693 state->EndDictionary(); |
| 716 | 694 |
| 717 state->SetBoolean("observing_begin_frame_source", | 695 state->SetBoolean("observing_begin_frame_source", |
| 718 observing_begin_frame_source_); | 696 observing_begin_frame_source_); |
| 719 state->SetBoolean("begin_impl_frame_deadline_task", | 697 state->SetBoolean("begin_impl_frame_deadline_task", |
| 720 !begin_impl_frame_deadline_task_.IsCancelled()); | 698 !begin_impl_frame_deadline_task_.IsCancelled()); |
| 721 state->SetBoolean("missed_begin_frame_task", | 699 state->SetBoolean("missed_begin_frame_task", |
| 722 !missed_begin_frame_task_.IsCancelled()); | 700 !missed_begin_frame_task_.IsCancelled()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 735 state->SetDouble( | 713 state->SetDouble( |
| 736 "deadline_scheduled_at_ms", | 714 "deadline_scheduled_at_ms", |
| 737 (deadline_scheduled_at_ - base::TimeTicks()).InMillisecondsF()); | 715 (deadline_scheduled_at_ - base::TimeTicks()).InMillisecondsF()); |
| 738 | 716 |
| 739 state->SetDouble("now_ms", (Now() - base::TimeTicks()).InMillisecondsF()); | 717 state->SetDouble("now_ms", (Now() - base::TimeTicks()).InMillisecondsF()); |
| 740 state->SetDouble("now_to_deadline_ms", (deadline_ - Now()).InMillisecondsF()); | 718 state->SetDouble("now_to_deadline_ms", (deadline_ - Now()).InMillisecondsF()); |
| 741 state->SetDouble("now_to_deadline_scheduled_at_ms", | 719 state->SetDouble("now_to_deadline_scheduled_at_ms", |
| 742 (deadline_scheduled_at_ - Now()).InMillisecondsF()); | 720 (deadline_scheduled_at_ - Now()).InMillisecondsF()); |
| 743 | 721 |
| 744 state->BeginDictionary("begin_impl_frame_tracker"); | 722 state->BeginDictionary("begin_impl_frame_tracker"); |
| 745 begin_impl_frame_tracker_.AsValueInto(state); | 723 begin_impl_frame_tracker_.AsValueInto(now, state); |
| 746 state->EndDictionary(); | 724 state->EndDictionary(); |
| 747 | 725 |
| 748 state->BeginDictionary("missed_begin_frame_args"); | 726 state->BeginDictionary("begin_impl_frame_args"); |
| 749 missed_begin_frame_args_.AsValueInto(state); | 727 begin_impl_frame_tracker_.AsValueInto(now, state); |
| 750 state->EndDictionary(); | 728 state->EndDictionary(); |
| 751 | 729 |
| 752 state->BeginDictionary("begin_frame_observer_state"); | 730 state->BeginDictionary("begin_frame_observer_state"); |
| 753 BeginFrameObserverBase::AsValueInto(state); | 731 BeginFrameObserverBase::AsValueInto(state); |
| 754 state->EndDictionary(); | 732 state->EndDictionary(); |
| 755 | 733 |
| 756 if (begin_frame_source_) { | 734 if (begin_frame_source_) { |
| 757 state->BeginDictionary("begin_frame_source_state"); | 735 state->BeginDictionary("begin_frame_source_state"); |
| 758 begin_frame_source_->AsValueInto(state); | 736 begin_frame_source_->AsValueInto(state); |
| 759 state->EndDictionary(); | 737 state->EndDictionary(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 } | 827 } |
| 850 | 828 |
| 851 BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const { | 829 BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const { |
| 852 return BeginFrameAck( | 830 return BeginFrameAck( |
| 853 begin_main_frame_args_.source_id, begin_main_frame_args_.sequence_number, | 831 begin_main_frame_args_.source_id, begin_main_frame_args_.sequence_number, |
| 854 state_machine_.last_begin_frame_sequence_number_active_tree_was_fresh(), | 832 state_machine_.last_begin_frame_sequence_number_active_tree_was_fresh(), |
| 855 true); | 833 true); |
| 856 } | 834 } |
| 857 | 835 |
| 858 } // namespace cc | 836 } // namespace cc |
| OLD | NEW |