| 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/values.h" | 10 #include "base/values.h" |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 begin_frame_state_ = BEGIN_FRAME_STATE_INSIDE_DEADLINE; | 868 begin_frame_state_ = BEGIN_FRAME_STATE_INSIDE_DEADLINE; |
| 869 } | 869 } |
| 870 | 870 |
| 871 void SchedulerStateMachine::OnBeginFrameIdle() { | 871 void SchedulerStateMachine::OnBeginFrameIdle() { |
| 872 DCHECK_EQ(begin_frame_state_, BEGIN_FRAME_STATE_INSIDE_DEADLINE) | 872 DCHECK_EQ(begin_frame_state_, BEGIN_FRAME_STATE_INSIDE_DEADLINE) |
| 873 << *AsValue(); | 873 << *AsValue(); |
| 874 begin_frame_state_ = BEGIN_FRAME_STATE_IDLE; | 874 begin_frame_state_ = BEGIN_FRAME_STATE_IDLE; |
| 875 } | 875 } |
| 876 | 876 |
| 877 bool SchedulerStateMachine::ShouldTriggerBeginFrameDeadlineEarly() const { | 877 bool SchedulerStateMachine::ShouldTriggerBeginFrameDeadlineEarly() const { |
| 878 // TODO(brianderson): This should take into account multiple commit sources. |
| 879 |
| 878 // If we are in the middle of the readback, we won't swap, so there is | 880 // If we are in the middle of the readback, we won't swap, so there is |
| 879 // no reason to trigger the deadline early. | 881 // no reason to trigger the deadline early. |
| 880 if (readback_state_ != READBACK_STATE_IDLE) | 882 if (readback_state_ != READBACK_STATE_IDLE) |
| 881 return false; | 883 return false; |
| 882 | 884 |
| 883 // TODO(brianderson): This should take into account multiple commit sources. | 885 if (begin_frame_state_ != BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME) |
| 884 return begin_frame_state_ == BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME && | 886 return false; |
| 885 active_tree_needs_first_draw_; | 887 |
| 888 if (active_tree_needs_first_draw_) |
| 889 return true; |
| 890 |
| 891 // This is used to prioritize impl-thread draws when the main thread isn't |
| 892 // producing anything, e.g., after an aborted commit. We also check that we |
| 893 // don't have a pending tree -- otherwise we should give it a chance to |
| 894 // activate. |
| 895 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. |
| 896 if (commit_state_ == COMMIT_STATE_IDLE && needs_redraw_ && !has_pending_tree_) |
| 897 return true; |
| 898 |
| 899 return false; |
| 886 } | 900 } |
| 887 | 901 |
| 888 void SchedulerStateMachine::DidEnterPollForAnticipatedDrawTriggers() { | 902 void SchedulerStateMachine::DidEnterPollForAnticipatedDrawTriggers() { |
| 889 current_frame_number_++; | 903 current_frame_number_++; |
| 890 inside_poll_for_anticipated_draw_triggers_ = true; | 904 inside_poll_for_anticipated_draw_triggers_ = true; |
| 891 } | 905 } |
| 892 | 906 |
| 893 void SchedulerStateMachine::DidLeavePollForAnticipatedDrawTriggers() { | 907 void SchedulerStateMachine::DidLeavePollForAnticipatedDrawTriggers() { |
| 894 inside_poll_for_anticipated_draw_triggers_ = false; | 908 inside_poll_for_anticipated_draw_triggers_ = false; |
| 895 } | 909 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 case OUTPUT_SURFACE_ACTIVE: | 1017 case OUTPUT_SURFACE_ACTIVE: |
| 1004 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1018 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
| 1005 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1019 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
| 1006 return true; | 1020 return true; |
| 1007 } | 1021 } |
| 1008 NOTREACHED(); | 1022 NOTREACHED(); |
| 1009 return false; | 1023 return false; |
| 1010 } | 1024 } |
| 1011 | 1025 |
| 1012 } // namespace cc | 1026 } // namespace cc |
| OLD | NEW |