| 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_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 has_pending_tree_(false), | 45 has_pending_tree_(false), |
| 46 pending_tree_is_ready_for_activation_(false), | 46 pending_tree_is_ready_for_activation_(false), |
| 47 active_tree_needs_first_draw_(false), | 47 active_tree_needs_first_draw_(false), |
| 48 did_create_and_initialize_first_output_surface_(false), | 48 did_create_and_initialize_first_output_surface_(false), |
| 49 impl_latency_takes_priority_(false), | 49 impl_latency_takes_priority_(false), |
| 50 skip_next_begin_main_frame_to_reduce_latency_(false), | 50 skip_next_begin_main_frame_to_reduce_latency_(false), |
| 51 skip_begin_main_frame_to_reduce_latency_(false), | 51 skip_begin_main_frame_to_reduce_latency_(false), |
| 52 continuous_painting_(false), | 52 continuous_painting_(false), |
| 53 children_need_begin_frames_(false), | 53 children_need_begin_frames_(false), |
| 54 defer_commits_(false), | 54 defer_commits_(false), |
| 55 video_needs_begin_frames_(false), |
| 55 last_commit_had_no_updates_(false), | 56 last_commit_had_no_updates_(false), |
| 56 wait_for_active_tree_ready_to_draw_(false), | 57 wait_for_active_tree_ready_to_draw_(false), |
| 57 did_request_swap_in_last_frame_(false), | 58 did_request_swap_in_last_frame_(false), |
| 58 did_perform_swap_in_last_draw_(false) { | 59 did_perform_swap_in_last_draw_(false) { |
| 59 } | 60 } |
| 60 | 61 |
| 61 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 62 const char* SchedulerStateMachine::OutputSurfaceStateToString( |
| 62 OutputSurfaceState state) { | 63 OutputSurfaceState state) { |
| 63 switch (state) { | 64 switch (state) { |
| 64 case OUTPUT_SURFACE_ACTIVE: | 65 case OUTPUT_SURFACE_ACTIVE: |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 state->SetBoolean("impl_latency_takes_priority", | 237 state->SetBoolean("impl_latency_takes_priority", |
| 237 impl_latency_takes_priority_); | 238 impl_latency_takes_priority_); |
| 238 state->SetBoolean("main_thread_is_in_high_latency_mode", | 239 state->SetBoolean("main_thread_is_in_high_latency_mode", |
| 239 MainThreadIsInHighLatencyMode()); | 240 MainThreadIsInHighLatencyMode()); |
| 240 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", | 241 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", |
| 241 skip_begin_main_frame_to_reduce_latency_); | 242 skip_begin_main_frame_to_reduce_latency_); |
| 242 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 243 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
| 243 skip_next_begin_main_frame_to_reduce_latency_); | 244 skip_next_begin_main_frame_to_reduce_latency_); |
| 244 state->SetBoolean("continuous_painting", continuous_painting_); | 245 state->SetBoolean("continuous_painting", continuous_painting_); |
| 245 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); | 246 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); |
| 247 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); |
| 246 state->SetBoolean("defer_commits", defer_commits_); | 248 state->SetBoolean("defer_commits", defer_commits_); |
| 247 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); | 249 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); |
| 248 state->SetBoolean("did_request_swap_in_last_frame", | 250 state->SetBoolean("did_request_swap_in_last_frame", |
| 249 did_request_swap_in_last_frame_); | 251 did_request_swap_in_last_frame_); |
| 250 state->SetBoolean("did_perform_swap_in_last_draw", | 252 state->SetBoolean("did_perform_swap_in_last_draw", |
| 251 did_perform_swap_in_last_draw_); | 253 did_perform_swap_in_last_draw_); |
| 252 state->EndDictionary(); | 254 state->EndDictionary(); |
| 253 } | 255 } |
| 254 | 256 |
| 255 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { | 257 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { | 718 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { |
| 717 TRACE_EVENT_INSTANT0("cc", | 719 TRACE_EVENT_INSTANT0("cc", |
| 718 "Scheduler: SkipNextBeginMainFrameToReduceLatency", | 720 "Scheduler: SkipNextBeginMainFrameToReduceLatency", |
| 719 TRACE_EVENT_SCOPE_THREAD); | 721 TRACE_EVENT_SCOPE_THREAD); |
| 720 skip_next_begin_main_frame_to_reduce_latency_ = true; | 722 skip_next_begin_main_frame_to_reduce_latency_ = true; |
| 721 } | 723 } |
| 722 | 724 |
| 723 bool SchedulerStateMachine::BeginFrameRequiredForChildren() const { | 725 bool SchedulerStateMachine::BeginFrameRequiredForChildren() const { |
| 724 return children_need_begin_frames_; | 726 return children_need_begin_frames_; |
| 725 } | 727 } |
| 728 bool SchedulerStateMachine::BeginFrameNeededForVideo() const { |
| 729 return video_needs_begin_frames_; |
| 730 } |
| 726 | 731 |
| 727 bool SchedulerStateMachine::BeginFrameNeeded() const { | 732 bool SchedulerStateMachine::BeginFrameNeeded() const { |
| 728 // We can't handle BeginFrames when output surface isn't initialized. | 733 // We can't handle BeginFrames when output surface isn't initialized. |
| 729 // TODO(brianderson): Support output surface creation inside a BeginFrame. | 734 // TODO(brianderson): Support output surface creation inside a BeginFrame. |
| 730 if (!HasInitializedOutputSurface()) | 735 if (!HasInitializedOutputSurface()) |
| 731 return false; | 736 return false; |
| 732 | 737 |
| 733 // If we are not visible, we don't need BeginFrame messages. | 738 // If we are not visible, we don't need BeginFrame messages. |
| 734 if (!visible_) | 739 if (!visible_) |
| 735 return false; | 740 return false; |
| 736 | 741 |
| 737 return (BeginFrameRequiredForAction() || BeginFrameRequiredForChildren() || | 742 return (BeginFrameRequiredForAction() || BeginFrameRequiredForChildren() || |
| 738 ProactiveBeginFrameWanted()); | 743 BeginFrameNeededForVideo() || ProactiveBeginFrameWanted()); |
| 739 } | 744 } |
| 740 | 745 |
| 741 void SchedulerStateMachine::SetChildrenNeedBeginFrames( | 746 void SchedulerStateMachine::SetChildrenNeedBeginFrames( |
| 742 bool children_need_begin_frames) { | 747 bool children_need_begin_frames) { |
| 743 children_need_begin_frames_ = children_need_begin_frames; | 748 children_need_begin_frames_ = children_need_begin_frames; |
| 744 } | 749 } |
| 745 | 750 |
| 751 void SchedulerStateMachine::SetVideoNeedsBeginFrames( |
| 752 bool video_needs_begin_frames) { |
| 753 video_needs_begin_frames_ = video_needs_begin_frames; |
| 754 } |
| 755 |
| 746 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { | 756 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { |
| 747 defer_commits_ = defer_commits; | 757 defer_commits_ = defer_commits; |
| 748 } | 758 } |
| 749 | 759 |
| 750 // These are the cases where we require a BeginFrame message to make progress | 760 // These are the cases where we require a BeginFrame message to make progress |
| 751 // on requested actions. | 761 // on requested actions. |
| 752 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { | 762 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { |
| 753 // The forced draw respects our normal draw scheduling, so we need to | 763 // The forced draw respects our normal draw scheduling, so we need to |
| 754 // request a BeginImplFrame for it. | 764 // request a BeginImplFrame for it. |
| 755 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 765 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 static_cast<int>(begin_impl_frame_state_), | 1134 static_cast<int>(begin_impl_frame_state_), |
| 1125 static_cast<int>(commit_state_), | 1135 static_cast<int>(commit_state_), |
| 1126 has_pending_tree_ ? 'T' : 'F', | 1136 has_pending_tree_ ? 'T' : 'F', |
| 1127 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1137 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
| 1128 active_tree_needs_first_draw_ ? 'T' : 'F', | 1138 active_tree_needs_first_draw_ ? 'T' : 'F', |
| 1129 max_pending_swaps_, | 1139 max_pending_swaps_, |
| 1130 pending_swaps_); | 1140 pending_swaps_); |
| 1131 } | 1141 } |
| 1132 | 1142 |
| 1133 } // namespace cc | 1143 } // namespace cc |
| OLD | NEW |