| 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/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "cc/scheduler/scheduler.h" | 8 #include "cc/scheduler/scheduler.h" |
| 9 #include "cc/test/begin_frame_args_test.h" | 9 #include "cc/test/begin_frame_args_test.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 // Begin the frame while visible. | 1226 // Begin the frame while visible. |
| 1227 state.OnBeginImplFrame(); | 1227 state.OnBeginImplFrame(); |
| 1228 EXPECT_ACTION_UPDATE_STATE( | 1228 EXPECT_ACTION_UPDATE_STATE( |
| 1229 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1229 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1230 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); | 1230 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); |
| 1231 EXPECT_FALSE(state.NeedsCommit()); | 1231 EXPECT_FALSE(state.NeedsCommit()); |
| 1232 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1232 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1233 | 1233 |
| 1234 // Become invisible and abort BeginMainFrame. | 1234 // Become invisible and abort BeginMainFrame. |
| 1235 state.SetVisible(false); | 1235 state.SetVisible(false); |
| 1236 state.NotifyBeginMainFrameStarted(); |
| 1236 state.BeginMainFrameAborted(CommitEarlyOutReason::ABORTED_NOT_VISIBLE); | 1237 state.BeginMainFrameAborted(CommitEarlyOutReason::ABORTED_NOT_VISIBLE); |
| 1237 | 1238 |
| 1238 // NeedsCommit should now be true again because we never actually did a | 1239 // NeedsCommit should now be true again because we never actually did a |
| 1239 // commit. | 1240 // commit. |
| 1240 EXPECT_TRUE(state.NeedsCommit()); | 1241 EXPECT_TRUE(state.NeedsCommit()); |
| 1241 | 1242 |
| 1242 // We should now be back in the idle state as if we never started the frame. | 1243 // We should now be back in the idle state as if we never started the frame. |
| 1243 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); | 1244 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); |
| 1244 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1245 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1245 | 1246 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 state.SetNeedsBeginMainFrame(); | 1282 state.SetNeedsBeginMainFrame(); |
| 1282 state.OnBeginImplFrame(); | 1283 state.OnBeginImplFrame(); |
| 1283 EXPECT_ACTION_UPDATE_STATE( | 1284 EXPECT_ACTION_UPDATE_STATE( |
| 1284 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1285 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1285 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); | 1286 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); |
| 1286 EXPECT_FALSE(state.NeedsCommit()); | 1287 EXPECT_FALSE(state.NeedsCommit()); |
| 1287 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); | 1288 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); |
| 1288 | 1289 |
| 1289 // Abort the commit, true means that the BeginMainFrame was sent but there | 1290 // Abort the commit, true means that the BeginMainFrame was sent but there |
| 1290 // was no work to do on the main thread. | 1291 // was no work to do on the main thread. |
| 1292 state.NotifyBeginMainFrameStarted(); |
| 1291 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); | 1293 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 1292 | 1294 |
| 1293 // NeedsCommit should now be false because the commit was actually handled. | 1295 // NeedsCommit should now be false because the commit was actually handled. |
| 1294 EXPECT_FALSE(state.NeedsCommit()); | 1296 EXPECT_FALSE(state.NeedsCommit()); |
| 1295 | 1297 |
| 1296 // Since the commit was aborted, we don't need to try and draw. | 1298 // Since the commit was aborted, we don't need to try and draw. |
| 1297 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1299 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1298 state.OnBeginImplFrameDeadline(); | 1300 state.OnBeginImplFrameDeadline(); |
| 1299 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1301 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1300 | 1302 |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 state.SetNeedsBeginMainFrame(); | 1844 state.SetNeedsBeginMainFrame(); |
| 1843 | 1845 |
| 1844 // We should start the commit normally. | 1846 // We should start the commit normally. |
| 1845 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); | 1847 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
| 1846 EXPECT_ACTION_UPDATE_STATE( | 1848 EXPECT_ACTION_UPDATE_STATE( |
| 1847 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1849 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1848 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1850 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1849 | 1851 |
| 1850 // Since only the scroll offset changed, the main thread will abort the | 1852 // Since only the scroll offset changed, the main thread will abort the |
| 1851 // commit. | 1853 // commit. |
| 1854 state.NotifyBeginMainFrameStarted(); |
| 1852 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); | 1855 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 1853 | 1856 |
| 1854 // Since the commit was aborted, we should draw right away instead of waiting | 1857 // Since the commit was aborted, we should draw right away instead of waiting |
| 1855 // for the deadline. | 1858 // for the deadline. |
| 1856 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | 1859 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
| 1857 } | 1860 } |
| 1858 | 1861 |
| 1859 void FinishPreviousCommitAndDrawWithoutExitingDeadline( | 1862 void FinishPreviousCommitAndDrawWithoutExitingDeadline( |
| 1860 StateMachine* state_ptr) { | 1863 StateMachine* state_ptr) { |
| 1861 // Gross, but allows us to use macros below. | 1864 // Gross, but allows us to use macros below. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2126 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 2129 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
| 2127 bool commit_has_no_updates = true; | 2130 bool commit_has_no_updates = true; |
| 2128 state.WillCommit(commit_has_no_updates); | 2131 state.WillCommit(commit_has_no_updates); |
| 2129 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); | 2132 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); |
| 2130 state.OnBeginImplFrame(); | 2133 state.OnBeginImplFrame(); |
| 2131 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 2134 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
| 2132 } | 2135 } |
| 2133 | 2136 |
| 2134 } // namespace | 2137 } // namespace |
| 2135 } // namespace cc | 2138 } // namespace cc |
| OLD | NEW |