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 can_start_(false), | 41 can_start_(false), |
42 can_draw_(false), | 42 can_draw_(false), |
43 has_pending_tree_(false), | 43 has_pending_tree_(false), |
44 pending_tree_is_ready_for_activation_(false), | 44 pending_tree_is_ready_for_activation_(false), |
45 active_tree_needs_first_draw_(false), | 45 active_tree_needs_first_draw_(false), |
46 did_commit_after_animating_(false), | 46 did_commit_after_animating_(false), |
47 did_create_and_initialize_first_output_surface_(false), | 47 did_create_and_initialize_first_output_surface_(false), |
48 impl_latency_takes_priority_(false), | 48 impl_latency_takes_priority_(false), |
49 skip_next_begin_main_frame_to_reduce_latency_(false), | 49 skip_next_begin_main_frame_to_reduce_latency_(false), |
50 skip_begin_main_frame_to_reduce_latency_(false), | 50 skip_begin_main_frame_to_reduce_latency_(false), |
51 continuous_painting_(false) { | 51 continuous_painting_(false), |
| 52 impl_latency_takes_priority_on_battery_(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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 did_create_and_initialize_first_output_surface_); | 232 did_create_and_initialize_first_output_surface_); |
232 state->SetBoolean("impl_latency_takes_priority", | 233 state->SetBoolean("impl_latency_takes_priority", |
233 impl_latency_takes_priority_); | 234 impl_latency_takes_priority_); |
234 state->SetBoolean("main_thread_is_in_high_latency_mode", | 235 state->SetBoolean("main_thread_is_in_high_latency_mode", |
235 MainThreadIsInHighLatencyMode()); | 236 MainThreadIsInHighLatencyMode()); |
236 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", | 237 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", |
237 skip_begin_main_frame_to_reduce_latency_); | 238 skip_begin_main_frame_to_reduce_latency_); |
238 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 239 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
239 skip_next_begin_main_frame_to_reduce_latency_); | 240 skip_next_begin_main_frame_to_reduce_latency_); |
240 state->SetBoolean("continuous_painting", continuous_painting_); | 241 state->SetBoolean("continuous_painting", continuous_painting_); |
| 242 state->SetBoolean("impl_latency_takes_priority_on_battery", |
| 243 impl_latency_takes_priority_on_battery_); |
241 state->EndDictionary(); | 244 state->EndDictionary(); |
242 } | 245 } |
243 | 246 |
244 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { | 247 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { |
245 current_frame_number_++; | 248 current_frame_number_++; |
246 | 249 |
247 // "Drain" the ManageTiles funnel. | 250 // "Drain" the ManageTiles funnel. |
248 if (manage_tiles_funnel_ > 0) | 251 if (manage_tiles_funnel_ > 0) |
249 manage_tiles_funnel_--; | 252 manage_tiles_funnel_--; |
250 | 253 |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 // don't have a pending tree -- otherwise we should give it a chance to | 875 // don't have a pending tree -- otherwise we should give it a chance to |
873 // activate. | 876 // activate. |
874 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. | 877 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. |
875 if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_) | 878 if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_) |
876 return true; | 879 return true; |
877 | 880 |
878 // Prioritize impl-thread draws in impl_latency_takes_priority_ mode. | 881 // Prioritize impl-thread draws in impl_latency_takes_priority_ mode. |
879 if (impl_latency_takes_priority_) | 882 if (impl_latency_takes_priority_) |
880 return true; | 883 return true; |
881 | 884 |
| 885 // If we are on battery power and want to prioritize impl latency because |
| 886 // we don't trust deadline tasks to execute at the right time. |
| 887 if (impl_latency_takes_priority_on_battery_) |
| 888 return true; |
| 889 |
882 return false; | 890 return false; |
883 } | 891 } |
884 | 892 |
885 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { | 893 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { |
886 // If a commit is pending before the previous commit has been drawn, we | 894 // If a commit is pending before the previous commit has been drawn, we |
887 // are definitely in a high latency mode. | 895 // are definitely in a high latency mode. |
888 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) | 896 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) |
889 return true; | 897 return true; |
890 | 898 |
891 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main | 899 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 static_cast<int>(begin_impl_frame_state_), | 1107 static_cast<int>(begin_impl_frame_state_), |
1100 static_cast<int>(commit_state_), | 1108 static_cast<int>(commit_state_), |
1101 has_pending_tree_ ? 'T' : 'F', | 1109 has_pending_tree_ ? 'T' : 'F', |
1102 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1110 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1103 active_tree_needs_first_draw_ ? 'T' : 'F', | 1111 active_tree_needs_first_draw_ ? 'T' : 'F', |
1104 max_pending_swaps_, | 1112 max_pending_swaps_, |
1105 pending_swaps_); | 1113 pending_swaps_); |
1106 } | 1114 } |
1107 | 1115 |
1108 } // namespace cc | 1116 } // namespace cc |
OLD | NEW |