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 29 matching lines...) Expand all Loading... |
40 can_draw_(false), | 40 can_draw_(false), |
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), | |
51 children_need_begin_frames_(false), | 50 children_need_begin_frames_(false), |
52 defer_commits_(false) { | 51 defer_commits_(false) { |
53 } | 52 } |
54 | 53 |
55 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 54 const char* SchedulerStateMachine::OutputSurfaceStateToString( |
56 OutputSurfaceState state) { | 55 OutputSurfaceState state) { |
57 switch (state) { | 56 switch (state) { |
58 case OUTPUT_SURFACE_ACTIVE: | 57 case OUTPUT_SURFACE_ACTIVE: |
59 return "OUTPUT_SURFACE_ACTIVE"; | 58 return "OUTPUT_SURFACE_ACTIVE"; |
60 case OUTPUT_SURFACE_LOST: | 59 case OUTPUT_SURFACE_LOST: |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 did_create_and_initialize_first_output_surface_); | 228 did_create_and_initialize_first_output_surface_); |
230 state->SetBoolean("impl_latency_takes_priority", | 229 state->SetBoolean("impl_latency_takes_priority", |
231 impl_latency_takes_priority_); | 230 impl_latency_takes_priority_); |
232 state->SetBoolean("main_thread_is_in_high_latency_mode", | 231 state->SetBoolean("main_thread_is_in_high_latency_mode", |
233 MainThreadIsInHighLatencyMode()); | 232 MainThreadIsInHighLatencyMode()); |
234 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", | 233 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", |
235 skip_begin_main_frame_to_reduce_latency_); | 234 skip_begin_main_frame_to_reduce_latency_); |
236 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 235 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
237 skip_next_begin_main_frame_to_reduce_latency_); | 236 skip_next_begin_main_frame_to_reduce_latency_); |
238 state->SetBoolean("continuous_painting", continuous_painting_); | 237 state->SetBoolean("continuous_painting", continuous_painting_); |
239 state->SetBoolean("impl_latency_takes_priority_on_battery", | |
240 impl_latency_takes_priority_on_battery_); | |
241 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); | 238 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); |
242 state->SetBoolean("defer_commits", defer_commits_); | 239 state->SetBoolean("defer_commits", defer_commits_); |
243 state->EndDictionary(); | 240 state->EndDictionary(); |
244 } | 241 } |
245 | 242 |
246 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { | 243 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { |
247 current_frame_number_++; | 244 current_frame_number_++; |
248 | 245 |
249 // "Drain" the PrepareTiles funnel. | 246 // "Drain" the PrepareTiles funnel. |
250 if (prepare_tiles_funnel_ > 0) | 247 if (prepare_tiles_funnel_ > 0) |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 // don't have a pending tree -- otherwise we should give it a chance to | 893 // don't have a pending tree -- otherwise we should give it a chance to |
897 // activate. | 894 // activate. |
898 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. | 895 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. |
899 if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_) | 896 if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_) |
900 return true; | 897 return true; |
901 | 898 |
902 // Prioritize impl-thread draws in impl_latency_takes_priority_ mode. | 899 // Prioritize impl-thread draws in impl_latency_takes_priority_ mode. |
903 if (impl_latency_takes_priority_) | 900 if (impl_latency_takes_priority_) |
904 return true; | 901 return true; |
905 | 902 |
906 // If we are on battery power and want to prioritize impl latency because | |
907 // we don't trust deadline tasks to execute at the right time. | |
908 if (impl_latency_takes_priority_on_battery_) | |
909 return true; | |
910 | |
911 return false; | 903 return false; |
912 } | 904 } |
913 | 905 |
914 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { | 906 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { |
915 // If a commit is pending before the previous commit has been drawn, we | 907 // If a commit is pending before the previous commit has been drawn, we |
916 // are definitely in a high latency mode. | 908 // are definitely in a high latency mode. |
917 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) | 909 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) |
918 return true; | 910 return true; |
919 | 911 |
920 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main | 912 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 static_cast<int>(begin_impl_frame_state_), | 1124 static_cast<int>(begin_impl_frame_state_), |
1133 static_cast<int>(commit_state_), | 1125 static_cast<int>(commit_state_), |
1134 has_pending_tree_ ? 'T' : 'F', | 1126 has_pending_tree_ ? 'T' : 'F', |
1135 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1127 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1136 active_tree_needs_first_draw_ ? 'T' : 'F', | 1128 active_tree_needs_first_draw_ ? 'T' : 'F', |
1137 max_pending_swaps_, | 1129 max_pending_swaps_, |
1138 pending_swaps_); | 1130 pending_swaps_); |
1139 } | 1131 } |
1140 | 1132 |
1141 } // namespace cc | 1133 } // namespace cc |
OLD | NEW |