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 26 matching lines...) Expand all Loading... |
37 swap_used_incomplete_tile_(false), | 37 swap_used_incomplete_tile_(false), |
38 needs_commit_(false), | 38 needs_commit_(false), |
39 inside_poll_for_anticipated_draw_triggers_(false), | 39 inside_poll_for_anticipated_draw_triggers_(false), |
40 visible_(false), | 40 visible_(false), |
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_create_and_initialize_first_output_surface_(false), | 46 did_create_and_initialize_first_output_surface_(false), |
47 smoothness_takes_priority_(false), | 47 impl_latency_takes_priority_(false), |
48 skip_next_begin_main_frame_to_reduce_latency_(false), | 48 skip_next_begin_main_frame_to_reduce_latency_(false), |
49 skip_begin_main_frame_to_reduce_latency_(false), | 49 skip_begin_main_frame_to_reduce_latency_(false), |
50 continuous_painting_(false) { | 50 continuous_painting_(false) { |
51 } | 51 } |
52 | 52 |
53 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 53 const char* SchedulerStateMachine::OutputSurfaceStateToString( |
54 OutputSurfaceState state) { | 54 OutputSurfaceState state) { |
55 switch (state) { | 55 switch (state) { |
56 case OUTPUT_SURFACE_ACTIVE: | 56 case OUTPUT_SURFACE_ACTIVE: |
57 return "OUTPUT_SURFACE_ACTIVE"; | 57 return "OUTPUT_SURFACE_ACTIVE"; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 state->SetBoolean("visible", visible_); | 222 state->SetBoolean("visible", visible_); |
223 state->SetBoolean("can_start", can_start_); | 223 state->SetBoolean("can_start", can_start_); |
224 state->SetBoolean("can_draw", can_draw_); | 224 state->SetBoolean("can_draw", can_draw_); |
225 state->SetBoolean("has_pending_tree", has_pending_tree_); | 225 state->SetBoolean("has_pending_tree", has_pending_tree_); |
226 state->SetBoolean("pending_tree_is_ready_for_activation", | 226 state->SetBoolean("pending_tree_is_ready_for_activation", |
227 pending_tree_is_ready_for_activation_); | 227 pending_tree_is_ready_for_activation_); |
228 state->SetBoolean("active_tree_needs_first_draw", | 228 state->SetBoolean("active_tree_needs_first_draw", |
229 active_tree_needs_first_draw_); | 229 active_tree_needs_first_draw_); |
230 state->SetBoolean("did_create_and_initialize_first_output_surface", | 230 state->SetBoolean("did_create_and_initialize_first_output_surface", |
231 did_create_and_initialize_first_output_surface_); | 231 did_create_and_initialize_first_output_surface_); |
232 state->SetBoolean("smoothness_takes_priority", smoothness_takes_priority_); | 232 state->SetBoolean("impl_latency_takes_priority", |
| 233 impl_latency_takes_priority_); |
233 state->SetBoolean("main_thread_is_in_high_latency_mode", | 234 state->SetBoolean("main_thread_is_in_high_latency_mode", |
234 MainThreadIsInHighLatencyMode()); | 235 MainThreadIsInHighLatencyMode()); |
235 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", | 236 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", |
236 skip_begin_main_frame_to_reduce_latency_); | 237 skip_begin_main_frame_to_reduce_latency_); |
237 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 238 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
238 skip_next_begin_main_frame_to_reduce_latency_); | 239 skip_next_begin_main_frame_to_reduce_latency_); |
239 state->SetBoolean("continuous_painting", continuous_painting_); | 240 state->SetBoolean("continuous_painting", continuous_painting_); |
240 state->EndDictionary(); | 241 state->EndDictionary(); |
241 } | 242 } |
242 | 243 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 432 |
432 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { | 433 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { |
433 if (!CouldSendBeginMainFrame()) | 434 if (!CouldSendBeginMainFrame()) |
434 return false; | 435 return false; |
435 | 436 |
436 // Only send BeginMainFrame when there isn't another commit pending already. | 437 // Only send BeginMainFrame when there isn't another commit pending already. |
437 if (commit_state_ != COMMIT_STATE_IDLE) | 438 if (commit_state_ != COMMIT_STATE_IDLE) |
438 return false; | 439 return false; |
439 | 440 |
440 // Don't send BeginMainFrame early if we are prioritizing the active tree | 441 // Don't send BeginMainFrame early if we are prioritizing the active tree |
441 // because of smoothness_takes_priority. | 442 // because of impl_latency_takes_priority_. |
442 if (smoothness_takes_priority_ && | 443 if (impl_latency_takes_priority_ && |
443 (has_pending_tree_ || active_tree_needs_first_draw_)) { | 444 (has_pending_tree_ || active_tree_needs_first_draw_)) { |
444 return false; | 445 return false; |
445 } | 446 } |
446 | 447 |
447 // We want to start the first commit after we get a new output surface ASAP. | 448 // We want to start the first commit after we get a new output surface ASAP. |
448 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) | 449 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) |
449 return true; | 450 return true; |
450 | 451 |
451 // We should not send BeginMainFrame while we are in | 452 // We should not send BeginMainFrame while we are in |
452 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new | 453 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 return false; | 863 return false; |
863 | 864 |
864 // This is used to prioritize impl-thread draws when the main thread isn't | 865 // This is used to prioritize impl-thread draws when the main thread isn't |
865 // producing anything, e.g., after an aborted commit. We also check that we | 866 // producing anything, e.g., after an aborted commit. We also check that we |
866 // don't have a pending tree -- otherwise we should give it a chance to | 867 // don't have a pending tree -- otherwise we should give it a chance to |
867 // activate. | 868 // activate. |
868 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. | 869 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. |
869 if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_) | 870 if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_) |
870 return true; | 871 return true; |
871 | 872 |
872 // Prioritize impl-thread draws in smoothness mode. | 873 // Prioritize impl-thread draws in impl_latency_takes_priority_ mode. |
873 if (smoothness_takes_priority_) | 874 if (impl_latency_takes_priority_) |
874 return true; | 875 return true; |
875 | 876 |
876 return false; | 877 return false; |
877 } | 878 } |
878 | 879 |
879 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { | 880 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { |
880 // If a commit is pending before the previous commit has been drawn, we | 881 // If a commit is pending before the previous commit has been drawn, we |
881 // are definitely in a high latency mode. | 882 // are definitely in a high latency mode. |
882 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) | 883 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) |
883 return true; | 884 return true; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 void SchedulerStateMachine::SetSwapUsedIncompleteTile( | 959 void SchedulerStateMachine::SetSwapUsedIncompleteTile( |
959 bool used_incomplete_tile) { | 960 bool used_incomplete_tile) { |
960 swap_used_incomplete_tile_ = used_incomplete_tile; | 961 swap_used_incomplete_tile_ = used_incomplete_tile; |
961 } | 962 } |
962 | 963 |
963 void SchedulerStateMachine::DidSwapBuffersComplete() { | 964 void SchedulerStateMachine::DidSwapBuffersComplete() { |
964 DCHECK_GT(pending_swaps_, 0); | 965 DCHECK_GT(pending_swaps_, 0); |
965 pending_swaps_--; | 966 pending_swaps_--; |
966 } | 967 } |
967 | 968 |
968 void SchedulerStateMachine::SetSmoothnessTakesPriority( | 969 void SchedulerStateMachine::SetImplLatencyTakesPriority( |
969 bool smoothness_takes_priority) { | 970 bool impl_latency_takes_priority) { |
970 smoothness_takes_priority_ = smoothness_takes_priority; | 971 impl_latency_takes_priority_ = impl_latency_takes_priority; |
971 } | 972 } |
972 | 973 |
973 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { | 974 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { |
974 switch (result) { | 975 switch (result) { |
975 case INVALID_RESULT: | 976 case INVALID_RESULT: |
976 NOTREACHED() << "Uninitialized DrawResult."; | 977 NOTREACHED() << "Uninitialized DrawResult."; |
977 break; | 978 break; |
978 case DRAW_ABORTED_CANT_DRAW: | 979 case DRAW_ABORTED_CANT_DRAW: |
979 case DRAW_ABORTED_CONTEXT_LOST: | 980 case DRAW_ABORTED_CONTEXT_LOST: |
980 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" | 981 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 static_cast<int>(begin_impl_frame_state_), | 1094 static_cast<int>(begin_impl_frame_state_), |
1094 static_cast<int>(commit_state_), | 1095 static_cast<int>(commit_state_), |
1095 has_pending_tree_ ? 'T' : 'F', | 1096 has_pending_tree_ ? 'T' : 'F', |
1096 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1097 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1097 active_tree_needs_first_draw_ ? 'T' : 'F', | 1098 active_tree_needs_first_draw_ ? 'T' : 'F', |
1098 max_pending_swaps_, | 1099 max_pending_swaps_, |
1099 pending_swaps_); | 1100 pending_swaps_); |
1100 } | 1101 } |
1101 | 1102 |
1102 } // namespace cc | 1103 } // namespace cc |
OLD | NEW |