| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/scheduler/scheduler.h" | 10 #include "cc/scheduler/scheduler.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 active_tree_needs_first_draw_ = needs_first_draw; | 138 active_tree_needs_first_draw_ = needs_first_draw; |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool CanDraw() const { return can_draw_; } | 141 bool CanDraw() const { return can_draw_; } |
| 142 bool Visible() const { return visible_; } | 142 bool Visible() const { return visible_; } |
| 143 | 143 |
| 144 bool PendingActivationsShouldBeForced() const { | 144 bool PendingActivationsShouldBeForced() const { |
| 145 return SchedulerStateMachine::PendingActivationsShouldBeForced(); | 145 return SchedulerStateMachine::PendingActivationsShouldBeForced(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool has_pending_tree() const { return has_pending_tree_; } |
| 148 void SetHasPendingTree(bool has_pending_tree) { | 149 void SetHasPendingTree(bool has_pending_tree) { |
| 149 has_pending_tree_ = has_pending_tree; | 150 has_pending_tree_ = has_pending_tree; |
| 150 } | 151 } |
| 151 | 152 |
| 152 using SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately; | 153 using SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately; |
| 153 using SchedulerStateMachine::ProactiveBeginFrameWanted; | 154 using SchedulerStateMachine::ProactiveBeginFrameWanted; |
| 154 using SchedulerStateMachine::WillCommit; | 155 using SchedulerStateMachine::WillCommit; |
| 155 | 156 |
| 156 protected: | 157 protected: |
| 157 DrawResult draw_result_for_test_; | 158 DrawResult draw_result_for_test_; |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 state.NotifyReadyToActivate(); | 1037 state.NotifyReadyToActivate(); |
| 1037 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); | 1038 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); |
| 1038 | 1039 |
| 1039 // Try to make a new main frame before drawing, but since we would clobber the | 1040 // Try to make a new main frame before drawing, but since we would clobber the |
| 1040 // active tree, we will not do so. | 1041 // active tree, we will not do so. |
| 1041 state.SetNeedsBeginMainFrame(); | 1042 state.SetNeedsBeginMainFrame(); |
| 1042 state.OnBeginImplFrame(); | 1043 state.OnBeginImplFrame(); |
| 1043 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1044 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1044 } | 1045 } |
| 1045 | 1046 |
| 1047 TEST(SchedulerStateMachineTest, AbortedMainFrameDoesNotResetPendingTree) { |
| 1048 SchedulerSettings scheduler_settings; |
| 1049 scheduler_settings.main_frame_before_activation_enabled = true; |
| 1050 StateMachine state(scheduler_settings); |
| 1051 SET_UP_STATE(state); |
| 1052 |
| 1053 // Perform a commit so that we have an active tree. |
| 1054 state.SetNeedsBeginMainFrame(); |
| 1055 state.OnBeginImplFrame(); |
| 1056 EXPECT_ACTION_UPDATE_STATE( |
| 1057 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1058 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1059 state.NotifyBeginMainFrameStarted(); |
| 1060 state.NotifyReadyToCommit(); |
| 1061 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1062 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1063 EXPECT_TRUE(state.has_pending_tree()); |
| 1064 state.OnBeginImplFrameDeadline(); |
| 1065 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1066 |
| 1067 // Ask for another commit but abort it. Verify that we didn't reset pending |
| 1068 // tree state. |
| 1069 state.SetNeedsBeginMainFrame(); |
| 1070 state.OnBeginImplFrame(); |
| 1071 EXPECT_ACTION_UPDATE_STATE( |
| 1072 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1073 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1074 EXPECT_TRUE(state.has_pending_tree()); |
| 1075 state.NotifyBeginMainFrameStarted(); |
| 1076 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 1077 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1078 EXPECT_TRUE(state.has_pending_tree()); |
| 1079 state.OnBeginImplFrameDeadline(); |
| 1080 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1081 |
| 1082 // Ask for another commit that doesn't abort. |
| 1083 state.SetNeedsBeginMainFrame(); |
| 1084 state.OnBeginImplFrame(); |
| 1085 EXPECT_ACTION_UPDATE_STATE( |
| 1086 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1087 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1088 state.NotifyBeginMainFrameStarted(); |
| 1089 state.NotifyReadyToCommit(); |
| 1090 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1091 EXPECT_TRUE(state.has_pending_tree()); |
| 1092 |
| 1093 // Verify that commit is delayed until the pending tree is activated. |
| 1094 state.NotifyReadyToActivate(); |
| 1095 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); |
| 1096 EXPECT_FALSE(state.has_pending_tree()); |
| 1097 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1098 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1099 EXPECT_TRUE(state.has_pending_tree()); |
| 1100 } |
| 1101 |
| 1046 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitToActive) { | 1102 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitToActive) { |
| 1047 SchedulerSettings scheduler_settings; | 1103 SchedulerSettings scheduler_settings; |
| 1048 scheduler_settings.commit_to_active_tree = true; | 1104 scheduler_settings.commit_to_active_tree = true; |
| 1049 StateMachine state(scheduler_settings); | 1105 StateMachine state(scheduler_settings); |
| 1050 SET_UP_STATE(state) | 1106 SET_UP_STATE(state) |
| 1051 | 1107 |
| 1052 // Start clean and set commit. | 1108 // Start clean and set commit. |
| 1053 state.SetNeedsBeginMainFrame(); | 1109 state.SetNeedsBeginMainFrame(); |
| 1054 | 1110 |
| 1055 // Begin the frame. | 1111 // Begin the frame. |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 state.OnBeginImplFrameDeadline(); | 2176 state.OnBeginImplFrameDeadline(); |
| 2121 state.OnBeginImplFrameIdle(); | 2177 state.OnBeginImplFrameIdle(); |
| 2122 | 2178 |
| 2123 // The scheduler should begin the output surface creation now. | 2179 // The scheduler should begin the output surface creation now. |
| 2124 EXPECT_ACTION_UPDATE_STATE( | 2180 EXPECT_ACTION_UPDATE_STATE( |
| 2125 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); | 2181 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); |
| 2126 } | 2182 } |
| 2127 | 2183 |
| 2128 } // namespace | 2184 } // namespace |
| 2129 } // namespace cc | 2185 } // namespace cc |
| OLD | NEW |