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/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 return; | 509 return; |
510 | 510 |
511 begin_retro_frame_posted_ = true; | 511 begin_retro_frame_posted_ = true; |
512 task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_); | 512 task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_); |
513 } | 513 } |
514 | 514 |
515 // BeginImplFrame starts a compositor frame that will wait up until a deadline | 515 // BeginImplFrame starts a compositor frame that will wait up until a deadline |
516 // for a BeginMainFrame+activation to complete before it times out and draws | 516 // for a BeginMainFrame+activation to complete before it times out and draws |
517 // any asynchronous animation and scroll/pinch updates. | 517 // any asynchronous animation and scroll/pinch updates. |
518 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 518 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
519 TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", args.AsValue()); | 519 bool main_thread_is_in_high_latency_mode = |
| 520 state_machine_.MainThreadIsInHighLatencyMode(); |
| 521 TRACE_EVENT2("cc", |
| 522 "Scheduler::BeginImplFrame", |
| 523 "args", |
| 524 args.AsValue(), |
| 525 "main_thread_is_high_latency", |
| 526 main_thread_is_in_high_latency_mode); |
| 527 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 528 "MainThreadLatency", |
| 529 main_thread_is_in_high_latency_mode); |
520 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 530 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
521 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 531 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
522 DCHECK(state_machine_.HasInitializedOutputSurface()); | 532 DCHECK(state_machine_.HasInitializedOutputSurface()); |
523 | 533 |
524 advance_commit_state_task_.Cancel(); | 534 advance_commit_state_task_.Cancel(); |
525 | 535 |
526 base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate(); | 536 base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate(); |
527 begin_impl_frame_args_ = args; | 537 begin_impl_frame_args_ = args; |
528 begin_impl_frame_args_.deadline -= draw_duration_estimate; | 538 begin_impl_frame_args_.deadline -= draw_duration_estimate; |
529 | 539 |
530 if (!state_machine_.impl_latency_takes_priority() && | 540 if (!state_machine_.impl_latency_takes_priority() && |
531 state_machine_.MainThreadIsInHighLatencyMode() && | 541 main_thread_is_in_high_latency_mode && |
532 CanCommitAndActivateBeforeDeadline()) { | 542 CanCommitAndActivateBeforeDeadline()) { |
533 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); | 543 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); |
534 } | 544 } |
535 | 545 |
536 client_->WillBeginImplFrame(begin_impl_frame_args_); | 546 client_->WillBeginImplFrame(begin_impl_frame_args_); |
537 state_machine_.OnBeginImplFrame(begin_impl_frame_args_); | 547 state_machine_.OnBeginImplFrame(begin_impl_frame_args_); |
538 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); | 548 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); |
539 | 549 |
540 ProcessScheduledActions(); | 550 ProcessScheduledActions(); |
541 | 551 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 } | 783 } |
774 | 784 |
775 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 785 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
776 return (state_machine_.commit_state() == | 786 return (state_machine_.commit_state() == |
777 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 787 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
778 state_machine_.commit_state() == | 788 state_machine_.commit_state() == |
779 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 789 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
780 } | 790 } |
781 | 791 |
782 } // namespace cc | 792 } // namespace cc |
OLD | NEW |