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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) | 445 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) |
446 return; | 446 return; |
447 | 447 |
448 begin_retro_frame_task_.Reset(begin_retro_frame_closure_); | 448 begin_retro_frame_task_.Reset(begin_retro_frame_closure_); |
449 | 449 |
450 task_runner_->PostTask(FROM_HERE, begin_retro_frame_task_.callback()); | 450 task_runner_->PostTask(FROM_HERE, begin_retro_frame_task_.callback()); |
451 } | 451 } |
452 | 452 |
453 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { | 453 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { |
454 bool main_thread_is_in_high_latency_mode = | 454 bool main_thread_is_in_high_latency_mode = |
455 state_machine_.MainThreadIsInHighLatencyMode(); | 455 state_machine_.main_thread_missed_last_deadline(); |
456 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", | 456 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", |
457 args.AsValue(), "main_thread_is_high_latency", | 457 args.AsValue(), "main_thread_missed_last_deadline", |
458 main_thread_is_in_high_latency_mode); | 458 main_thread_is_in_high_latency_mode); |
459 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 459 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
460 "MainThreadLatency", main_thread_is_in_high_latency_mode); | 460 "MainThreadLatency", main_thread_is_in_high_latency_mode); |
461 | 461 |
462 BeginFrameArgs adjusted_args = args; | 462 BeginFrameArgs adjusted_args = args; |
463 adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate(); | 463 adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate(); |
464 | 464 |
465 if (ShouldRecoverMainLatency(adjusted_args)) { | 465 if (ShouldRecoverMainLatency(adjusted_args)) { |
466 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", | 466 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", |
467 TRACE_EVENT_SCOPE_THREAD); | 467 TRACE_EVENT_SCOPE_THREAD); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 // The CompositorTimingHistory will discard the first two recordings | 756 // The CompositorTimingHistory will discard the first two recordings |
757 // just after being enabled. | 757 // just after being enabled. |
758 compositor_timing_history_->SetRecordingEnabled( | 758 compositor_timing_history_->SetRecordingEnabled( |
759 state_machine_.HasInitializedOutputSurface() && | 759 state_machine_.HasInitializedOutputSurface() && |
760 state_machine_.visible() && frame_source_->NeedsBeginFrames()); | 760 state_machine_.visible() && frame_source_->NeedsBeginFrames()); |
761 } | 761 } |
762 | 762 |
763 bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const { | 763 bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const { |
764 DCHECK(!settings_.using_synchronous_renderer_compositor); | 764 DCHECK(!settings_.using_synchronous_renderer_compositor); |
765 | 765 |
766 if (!state_machine_.MainThreadIsInHighLatencyMode()) | 766 if (!state_machine_.main_thread_missed_last_deadline()) |
767 return false; | 767 return false; |
768 | 768 |
769 // When prioritizing impl thread latency, we currently put the | 769 // When prioritizing impl thread latency, we currently put the |
770 // main thread in a high latency mode. Don't try to fight it. | 770 // main thread in a high latency mode. Don't try to fight it. |
771 if (state_machine_.impl_latency_takes_priority()) | 771 if (state_machine_.impl_latency_takes_priority()) |
772 return false; | 772 return false; |
773 | 773 |
774 return CanCommitAndActivateBeforeDeadline(args); | 774 return CanCommitAndActivateBeforeDeadline(args); |
775 } | 775 } |
776 | 776 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 } | 817 } |
818 | 818 |
819 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 819 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
820 return (state_machine_.commit_state() == | 820 return (state_machine_.commit_state() == |
821 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 821 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
822 state_machine_.commit_state() == | 822 state_machine_.commit_state() == |
823 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 823 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
824 } | 824 } |
825 | 825 |
826 } // namespace cc | 826 } // namespace cc |
OLD | NEW |