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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 has_pending_tree_(false), | 41 has_pending_tree_(false), |
42 pending_tree_is_ready_for_activation_(false), | 42 pending_tree_is_ready_for_activation_(false), |
43 active_tree_needs_first_draw_(false), | 43 active_tree_needs_first_draw_(false), |
44 did_commit_after_animating_(false), | 44 did_commit_after_animating_(false), |
45 did_create_and_initialize_first_output_surface_(false), | 45 did_create_and_initialize_first_output_surface_(false), |
46 impl_latency_takes_priority_(false), | 46 impl_latency_takes_priority_(false), |
47 skip_next_begin_main_frame_to_reduce_latency_(false), | 47 skip_next_begin_main_frame_to_reduce_latency_(false), |
48 skip_begin_main_frame_to_reduce_latency_(false), | 48 skip_begin_main_frame_to_reduce_latency_(false), |
49 continuous_painting_(false), | 49 continuous_painting_(false), |
50 impl_latency_takes_priority_on_battery_(false), | 50 impl_latency_takes_priority_on_battery_(false), |
51 children_need_begin_frames_(false) { | 51 children_need_begin_frames_(false), |
| 52 defer_commits_(false) { |
52 } | 53 } |
53 | 54 |
54 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 55 const char* SchedulerStateMachine::OutputSurfaceStateToString( |
55 OutputSurfaceState state) { | 56 OutputSurfaceState state) { |
56 switch (state) { | 57 switch (state) { |
57 case OUTPUT_SURFACE_ACTIVE: | 58 case OUTPUT_SURFACE_ACTIVE: |
58 return "OUTPUT_SURFACE_ACTIVE"; | 59 return "OUTPUT_SURFACE_ACTIVE"; |
59 case OUTPUT_SURFACE_LOST: | 60 case OUTPUT_SURFACE_LOST: |
60 return "OUTPUT_SURFACE_LOST"; | 61 return "OUTPUT_SURFACE_LOST"; |
61 case OUTPUT_SURFACE_CREATING: | 62 case OUTPUT_SURFACE_CREATING: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 state->SetBoolean("main_thread_is_in_high_latency_mode", | 230 state->SetBoolean("main_thread_is_in_high_latency_mode", |
230 MainThreadIsInHighLatencyMode()); | 231 MainThreadIsInHighLatencyMode()); |
231 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", | 232 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", |
232 skip_begin_main_frame_to_reduce_latency_); | 233 skip_begin_main_frame_to_reduce_latency_); |
233 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 234 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
234 skip_next_begin_main_frame_to_reduce_latency_); | 235 skip_next_begin_main_frame_to_reduce_latency_); |
235 state->SetBoolean("continuous_painting", continuous_painting_); | 236 state->SetBoolean("continuous_painting", continuous_painting_); |
236 state->SetBoolean("impl_latency_takes_priority_on_battery", | 237 state->SetBoolean("impl_latency_takes_priority_on_battery", |
237 impl_latency_takes_priority_on_battery_); | 238 impl_latency_takes_priority_on_battery_); |
238 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); | 239 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); |
| 240 state->SetBoolean("defer_commits", defer_commits_); |
239 state->EndDictionary(); | 241 state->EndDictionary(); |
240 } | 242 } |
241 | 243 |
242 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { | 244 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { |
243 current_frame_number_++; | 245 current_frame_number_++; |
244 | 246 |
245 // "Drain" the ManageTiles funnel. | 247 // "Drain" the ManageTiles funnel. |
246 if (manage_tiles_funnel_ > 0) | 248 if (manage_tiles_funnel_ > 0) |
247 manage_tiles_funnel_--; | 249 manage_tiles_funnel_--; |
248 | 250 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 399 } |
398 | 400 |
399 bool SchedulerStateMachine::CouldSendBeginMainFrame() const { | 401 bool SchedulerStateMachine::CouldSendBeginMainFrame() const { |
400 if (!needs_commit_) | 402 if (!needs_commit_) |
401 return false; | 403 return false; |
402 | 404 |
403 // We can not perform commits if we are not visible. | 405 // We can not perform commits if we are not visible. |
404 if (!visible_) | 406 if (!visible_) |
405 return false; | 407 return false; |
406 | 408 |
| 409 // We do not need new commits if it is deferred. |
| 410 if (defer_commits_) |
| 411 return false; |
| 412 |
407 return true; | 413 return true; |
408 } | 414 } |
409 | 415 |
410 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { | 416 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { |
411 if (!CouldSendBeginMainFrame()) | 417 if (!CouldSendBeginMainFrame()) |
412 return false; | 418 return false; |
413 | 419 |
414 // Only send BeginMainFrame when there isn't another commit pending already. | 420 // Only send BeginMainFrame when there isn't another commit pending already. |
415 if (commit_state_ != COMMIT_STATE_IDLE) | 421 if (commit_state_ != COMMIT_STATE_IDLE) |
416 return false; | 422 return false; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // BeginFrame, which could cause duplicate draws. | 726 // BeginFrame, which could cause duplicate draws. |
721 return !settings_.using_synchronous_renderer_compositor; | 727 return !settings_.using_synchronous_renderer_compositor; |
722 } | 728 } |
723 | 729 |
724 void SchedulerStateMachine::SetChildrenNeedBeginFrames( | 730 void SchedulerStateMachine::SetChildrenNeedBeginFrames( |
725 bool children_need_begin_frames) { | 731 bool children_need_begin_frames) { |
726 DCHECK(settings_.forward_begin_frames_to_children); | 732 DCHECK(settings_.forward_begin_frames_to_children); |
727 children_need_begin_frames_ = children_need_begin_frames; | 733 children_need_begin_frames_ = children_need_begin_frames; |
728 } | 734 } |
729 | 735 |
| 736 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { |
| 737 defer_commits_ = defer_commits; |
| 738 } |
| 739 |
730 // These are the cases where we definitely (or almost definitely) have a | 740 // These are the cases where we definitely (or almost definitely) have a |
731 // new frame to animate and/or draw and can draw. | 741 // new frame to animate and/or draw and can draw. |
732 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { | 742 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { |
733 // The output surface is the provider of BeginImplFrames, so we are not going | 743 // The output surface is the provider of BeginImplFrames, so we are not going |
734 // to get them even if we ask for them. | 744 // to get them even if we ask for them. |
735 if (!HasInitializedOutputSurface()) | 745 if (!HasInitializedOutputSurface()) |
736 return false; | 746 return false; |
737 | 747 |
738 // The forced draw respects our normal draw scheduling, so we need to | 748 // The forced draw respects our normal draw scheduling, so we need to |
739 // request a BeginImplFrame for it. | 749 // request a BeginImplFrame for it. |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 static_cast<int>(begin_impl_frame_state_), | 1073 static_cast<int>(begin_impl_frame_state_), |
1064 static_cast<int>(commit_state_), | 1074 static_cast<int>(commit_state_), |
1065 has_pending_tree_ ? 'T' : 'F', | 1075 has_pending_tree_ ? 'T' : 'F', |
1066 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1076 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1067 active_tree_needs_first_draw_ ? 'T' : 'F', | 1077 active_tree_needs_first_draw_ ? 'T' : 'F', |
1068 max_pending_swaps_, | 1078 max_pending_swaps_, |
1069 pending_swaps_); | 1079 pending_swaps_); |
1070 } | 1080 } |
1071 | 1081 |
1072 } // namespace cc | 1082 } // namespace cc |
OLD | NEW |