| 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 return true; | 811 return true; |
| 812 | 812 |
| 813 // If the last commit was aborted because of early out (no updates), we should | 813 // If the last commit was aborted because of early out (no updates), we should |
| 814 // still want a begin frame in case there is a commit coming again. | 814 // still want a begin frame in case there is a commit coming again. |
| 815 if (last_commit_had_no_updates_) | 815 if (last_commit_had_no_updates_) |
| 816 return true; | 816 return true; |
| 817 | 817 |
| 818 return false; | 818 return false; |
| 819 } | 819 } |
| 820 | 820 |
| 821 void SchedulerStateMachine::DidSkipBeginImplFrameToReduceLatency() { |
| 822 last_swap_ack_came_after_begin_impl_frame_ = false; |
| 823 } |
| 824 |
| 821 void SchedulerStateMachine::OnBeginImplFrame() { | 825 void SchedulerStateMachine::OnBeginImplFrame() { |
| 822 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; | 826 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; |
| 823 current_frame_number_++; | 827 current_frame_number_++; |
| 824 | 828 |
| 825 last_commit_had_no_updates_ = false; | 829 last_commit_had_no_updates_ = false; |
| 826 did_request_swap_in_last_frame_ = false; | 830 did_request_swap_in_last_frame_ = false; |
| 827 | 831 |
| 828 // Clear funnels for any actions we perform during the frame. | 832 // Clear funnels for any actions we perform during the frame. |
| 829 animate_funnel_ = false; | 833 animate_funnel_ = false; |
| 830 send_begin_main_frame_funnel_ = false; | 834 send_begin_main_frame_funnel_ = false; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 } else { | 879 } else { |
| 876 // The impl thread doesn't have anything it wants to draw and we are just | 880 // The impl thread doesn't have anything it wants to draw and we are just |
| 877 // waiting for a new active tree or we are swap throttled. In short we are | 881 // waiting for a new active tree or we are swap throttled. In short we are |
| 878 // blocked. | 882 // blocked. |
| 879 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; | 883 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; |
| 880 } | 884 } |
| 881 } | 885 } |
| 882 | 886 |
| 883 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() | 887 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() |
| 884 const { | 888 const { |
| 885 // TODO(brianderson): This should take into account multiple commit sources. | |
| 886 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) | 889 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) |
| 887 return false; | 890 return false; |
| 888 | 891 |
| 889 // If we just forced activation, we should end the deadline right now. | 892 // If we just forced activation, we should end the deadline right now. |
| 890 if (PendingActivationsShouldBeForced() && !has_pending_tree_) | 893 if (PendingActivationsShouldBeForced() && !has_pending_tree_) |
| 891 return true; | 894 return true; |
| 892 | 895 |
| 893 // SwapAck throttle the deadline since we wont draw and swap anyway. | 896 // SwapAck throttle the deadline since we wont draw and swap anyway. |
| 894 if (pending_swaps_ >= max_pending_swaps_) | 897 if (pending_swaps_ >= max_pending_swaps_) |
| 895 return false; | 898 return false; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 pending_swaps_++; | 989 pending_swaps_++; |
| 987 DCHECK_LE(pending_swaps_, max_pending_swaps_); | 990 DCHECK_LE(pending_swaps_, max_pending_swaps_); |
| 988 | 991 |
| 989 did_perform_swap_in_last_draw_ = true; | 992 did_perform_swap_in_last_draw_ = true; |
| 990 last_frame_number_swap_performed_ = current_frame_number_; | 993 last_frame_number_swap_performed_ = current_frame_number_; |
| 991 } | 994 } |
| 992 | 995 |
| 993 void SchedulerStateMachine::DidSwapBuffersComplete() { | 996 void SchedulerStateMachine::DidSwapBuffersComplete() { |
| 994 DCHECK_GT(pending_swaps_, 0); | 997 DCHECK_GT(pending_swaps_, 0); |
| 995 pending_swaps_--; | 998 pending_swaps_--; |
| 999 last_swap_ack_came_after_begin_impl_frame_ = |
| 1000 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE; |
| 996 } | 1001 } |
| 997 | 1002 |
| 998 void SchedulerStateMachine::SetImplLatencyTakesPriority( | 1003 void SchedulerStateMachine::SetImplLatencyTakesPriority( |
| 999 bool impl_latency_takes_priority) { | 1004 bool impl_latency_takes_priority) { |
| 1000 impl_latency_takes_priority_ = impl_latency_takes_priority; | 1005 impl_latency_takes_priority_ = impl_latency_takes_priority; |
| 1001 } | 1006 } |
| 1002 | 1007 |
| 1003 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { | 1008 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { |
| 1004 switch (result) { | 1009 switch (result) { |
| 1005 case INVALID_RESULT: | 1010 case INVALID_RESULT: |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 static_cast<int>(begin_impl_frame_state_), | 1143 static_cast<int>(begin_impl_frame_state_), |
| 1139 static_cast<int>(commit_state_), | 1144 static_cast<int>(commit_state_), |
| 1140 has_pending_tree_ ? 'T' : 'F', | 1145 has_pending_tree_ ? 'T' : 'F', |
| 1141 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1146 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
| 1142 active_tree_needs_first_draw_ ? 'T' : 'F', | 1147 active_tree_needs_first_draw_ ? 'T' : 'F', |
| 1143 max_pending_swaps_, | 1148 max_pending_swaps_, |
| 1144 pending_swaps_); | 1149 pending_swaps_); |
| 1145 } | 1150 } |
| 1146 | 1151 |
| 1147 } // namespace cc | 1152 } // namespace cc |
| OLD | NEW |