| 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) | 443 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) |
| 444 return; | 444 return; |
| 445 | 445 |
| 446 begin_retro_frame_task_.Reset(begin_retro_frame_closure_); | 446 begin_retro_frame_task_.Reset(begin_retro_frame_closure_); |
| 447 | 447 |
| 448 task_runner_->PostTask(FROM_HERE, begin_retro_frame_task_.callback()); | 448 task_runner_->PostTask(FROM_HERE, begin_retro_frame_task_.callback()); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { | 451 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { |
| 452 bool main_thread_is_in_high_latency_mode = | 452 bool main_thread_is_in_high_latency_mode = |
| 453 state_machine_.MainThreadIsInHighLatencyMode(); | 453 state_machine_.main_thread_missed_last_deadline(); |
| 454 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", | 454 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", |
| 455 args.AsValue(), "main_thread_is_high_latency", | 455 args.AsValue(), "main_thread_missed_last_deadline", |
| 456 main_thread_is_in_high_latency_mode); | 456 main_thread_is_in_high_latency_mode); |
| 457 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 457 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 458 "MainThreadLatency", main_thread_is_in_high_latency_mode); | 458 "MainThreadLatency", main_thread_is_in_high_latency_mode); |
| 459 | 459 |
| 460 BeginFrameArgs adjusted_args = args; | 460 BeginFrameArgs adjusted_args = args; |
| 461 adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate(); | 461 adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate(); |
| 462 | 462 |
| 463 if (ShouldRecoverMainLatency(adjusted_args)) { | 463 if (ShouldRecoverMainLatency(adjusted_args)) { |
| 464 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", | 464 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", |
| 465 TRACE_EVENT_SCOPE_THREAD); | 465 TRACE_EVENT_SCOPE_THREAD); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 } | 747 } |
| 748 | 748 |
| 749 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() { | 749 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() { |
| 750 compositor_timing_history_->SetRecordingEnabled( | 750 compositor_timing_history_->SetRecordingEnabled( |
| 751 state_machine_.HasInitializedOutputSurface() && state_machine_.visible()); | 751 state_machine_.HasInitializedOutputSurface() && state_machine_.visible()); |
| 752 } | 752 } |
| 753 | 753 |
| 754 bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const { | 754 bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const { |
| 755 DCHECK(!settings_.using_synchronous_renderer_compositor); | 755 DCHECK(!settings_.using_synchronous_renderer_compositor); |
| 756 | 756 |
| 757 if (!state_machine_.MainThreadIsInHighLatencyMode()) | 757 if (!state_machine_.main_thread_missed_last_deadline()) |
| 758 return false; | 758 return false; |
| 759 | 759 |
| 760 // When prioritizing impl thread latency, we currently put the | 760 // When prioritizing impl thread latency, we currently put the |
| 761 // main thread in a high latency mode. Don't try to fight it. | 761 // main thread in a high latency mode. Don't try to fight it. |
| 762 if (state_machine_.impl_latency_takes_priority()) | 762 if (state_machine_.impl_latency_takes_priority()) |
| 763 return false; | 763 return false; |
| 764 | 764 |
| 765 return CanCommitAndActivateBeforeDeadline(args); | 765 return CanCommitAndActivateBeforeDeadline(args); |
| 766 } | 766 } |
| 767 | 767 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } | 814 } |
| 815 | 815 |
| 816 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 816 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 817 return (state_machine_.commit_state() == | 817 return (state_machine_.commit_state() == |
| 818 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 818 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 819 state_machine_.commit_state() == | 819 state_machine_.commit_state() == |
| 820 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 820 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 821 } | 821 } |
| 822 | 822 |
| 823 } // namespace cc | 823 } // namespace cc |
| OLD | NEW |