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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 void Scheduler::SetupNextBeginFrameIfNeeded() { | 272 void Scheduler::SetupNextBeginFrameIfNeeded() { |
273 // Never call SetNeedsBeginFrames if the frame source already has the right | 273 // Never call SetNeedsBeginFrames if the frame source already has the right |
274 // value. | 274 // value. |
275 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) { | 275 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) { |
276 if (state_machine_.BeginFrameNeeded()) { | 276 if (state_machine_.BeginFrameNeeded()) { |
277 // Call SetNeedsBeginFrames(true) as soon as possible. | 277 // Call SetNeedsBeginFrames(true) as soon as possible. |
278 frame_source_->SetNeedsBeginFrames(true); | 278 frame_source_->SetNeedsBeginFrames(true); |
279 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, | 279 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, |
280 true); | 280 true); |
281 UpdateCompositorTimingHistoryRecordingEnabled(); | |
282 } else if (state_machine_.begin_impl_frame_state() == | 281 } else if (state_machine_.begin_impl_frame_state() == |
283 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { | 282 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { |
284 // Call SetNeedsBeginFrames(false) in between frames only. | 283 // Call SetNeedsBeginFrames(false) in between frames only. |
285 frame_source_->SetNeedsBeginFrames(false); | 284 frame_source_->SetNeedsBeginFrames(false); |
286 client_->SendBeginMainFrameNotExpectedSoon(); | 285 client_->SendBeginMainFrameNotExpectedSoon(); |
287 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, | 286 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, |
288 false); | 287 false); |
289 UpdateCompositorTimingHistoryRecordingEnabled(); | |
290 } | 288 } |
291 } | 289 } |
292 | 290 |
293 PostBeginRetroFrameIfNeeded(); | 291 PostBeginRetroFrameIfNeeded(); |
294 } | 292 } |
295 | 293 |
296 // BeginFrame is the mechanism that tells us that now is a good time to start | 294 // BeginFrame is the mechanism that tells us that now is a good time to start |
297 // making a frame. Usually this means that user input for the frame is complete. | 295 // making a frame. Usually this means that user input for the frame is complete. |
298 // If the scheduler is busy, we queue the BeginFrame to be handled later as | 296 // If the scheduler is busy, we queue the BeginFrame to be handled later as |
299 // a BeginRetroFrame. | 297 // a BeginRetroFrame. |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 &frame_tracing_enabled); | 732 &frame_tracing_enabled); |
735 if (frame_tracing_enabled) { | 733 if (frame_tracing_enabled) { |
736 state->BeginDictionary("frame_source_"); | 734 state->BeginDictionary("frame_source_"); |
737 frame_source_->AsValueInto(state); | 735 frame_source_->AsValueInto(state); |
738 state->EndDictionary(); | 736 state->EndDictionary(); |
739 } | 737 } |
740 | 738 |
741 state->BeginDictionary("scheduler_state"); | 739 state->BeginDictionary("scheduler_state"); |
742 state->SetDouble("estimated_parent_draw_time_ms", | 740 state->SetDouble("estimated_parent_draw_time_ms", |
743 estimated_parent_draw_time_.InMillisecondsF()); | 741 estimated_parent_draw_time_.InMillisecondsF()); |
| 742 state->SetBoolean("last_set_needs_begin_frame_", |
| 743 frame_source_->NeedsBeginFrames()); |
744 state->SetInteger("begin_retro_frame_args", | 744 state->SetInteger("begin_retro_frame_args", |
745 static_cast<int>(begin_retro_frame_args_.size())); | 745 static_cast<int>(begin_retro_frame_args_.size())); |
746 state->SetBoolean("begin_retro_frame_task", | 746 state->SetBoolean("begin_retro_frame_task", |
747 !begin_retro_frame_task_.IsCancelled()); | 747 !begin_retro_frame_task_.IsCancelled()); |
748 state->SetBoolean("begin_impl_frame_deadline_task", | 748 state->SetBoolean("begin_impl_frame_deadline_task", |
749 !begin_impl_frame_deadline_task_.IsCancelled()); | 749 !begin_impl_frame_deadline_task_.IsCancelled()); |
750 state->SetString("inside_action", | 750 state->SetString("inside_action", |
751 SchedulerStateMachine::ActionToString(inside_action_)); | 751 SchedulerStateMachine::ActionToString(inside_action_)); |
752 | 752 |
753 state->BeginDictionary("begin_impl_frame_args"); | 753 state->BeginDictionary("begin_impl_frame_args"); |
754 begin_impl_frame_tracker_.AsValueInto(now, state); | 754 begin_impl_frame_tracker_.AsValueInto(now, state); |
755 state->EndDictionary(); | 755 state->EndDictionary(); |
756 | 756 |
757 state->SetString("begin_impl_frame_deadline_mode_", | 757 state->SetString("begin_impl_frame_deadline_mode_", |
758 SchedulerStateMachine::BeginImplFrameDeadlineModeToString( | 758 SchedulerStateMachine::BeginImplFrameDeadlineModeToString( |
759 begin_impl_frame_deadline_mode_)); | 759 begin_impl_frame_deadline_mode_)); |
760 state->EndDictionary(); | 760 state->EndDictionary(); |
761 | 761 |
762 state->BeginDictionary("compositor_timing_history"); | 762 state->BeginDictionary("compositor_timing_history"); |
763 compositor_timing_history_->AsValueInto(state); | 763 compositor_timing_history_->AsValueInto(state); |
764 state->EndDictionary(); | 764 state->EndDictionary(); |
765 } | 765 } |
766 | 766 |
767 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() { | 767 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() { |
768 compositor_timing_history_->SetRecordingEnabled( | 768 compositor_timing_history_->SetRecordingEnabled( |
769 state_machine_.HasInitializedOutputSurface() && | 769 state_machine_.HasInitializedOutputSurface() && state_machine_.visible()); |
770 state_machine_.visible() && frame_source_->NeedsBeginFrames()); | |
771 } | 770 } |
772 | 771 |
773 bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const { | 772 bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const { |
774 DCHECK(!settings_.using_synchronous_renderer_compositor); | 773 DCHECK(!settings_.using_synchronous_renderer_compositor); |
775 | 774 |
776 if (!state_machine_.main_thread_missed_last_deadline()) | 775 if (!state_machine_.main_thread_missed_last_deadline()) |
777 return false; | 776 return false; |
778 | 777 |
779 // When prioritizing impl thread latency, we currently put the | 778 // When prioritizing impl thread latency, we currently put the |
780 // main thread in a high latency mode. Don't try to fight it. | 779 // main thread in a high latency mode. Don't try to fight it. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 } | 832 } |
834 | 833 |
835 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 834 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
836 return (state_machine_.begin_main_frame_state() == | 835 return (state_machine_.begin_main_frame_state() == |
837 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 836 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
838 state_machine_.begin_main_frame_state() == | 837 state_machine_.begin_main_frame_state() == |
839 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 838 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
840 } | 839 } |
841 | 840 |
842 } // namespace cc | 841 } // namespace cc |
OLD | NEW |