| 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 602 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 603 } | 603 } |
| 604 | 604 |
| 605 EXPECT_TRUE(state.BeginFrameNeeded()); | 605 EXPECT_TRUE(state.BeginFrameNeeded()); |
| 606 EXPECT_TRUE(state.RedrawPending()); | 606 EXPECT_TRUE(state.RedrawPending()); |
| 607 // But the commit is ongoing. | 607 // But the commit is ongoing. |
| 608 EXPECT_TRUE(state.CommitPending()); | 608 EXPECT_TRUE(state.CommitPending()); |
| 609 EXPECT_TRUE(state.ForcedRedrawState() == | 609 EXPECT_TRUE(state.ForcedRedrawState() == |
| 610 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_COMMIT); | 610 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_COMMIT); |
| 611 | 611 |
| 612 state.NotifyBeginMainFrameStarted(); | |
| 613 state.NotifyReadyToCommit(); | |
| 614 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | |
| 615 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
| 616 EXPECT_TRUE(state.RedrawPending()); | |
| 617 EXPECT_FALSE(state.CommitPending()); | |
| 618 | |
| 619 // Now force redraw should be in waiting for activation | |
| 620 EXPECT_TRUE(state.ForcedRedrawState() == | |
| 621 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); | |
| 622 | |
| 623 // After failing additional draws, we should still be in a forced | 612 // After failing additional draws, we should still be in a forced |
| 624 // redraw, but not back in WAITING_FOR_COMMIT. | 613 // redraw, but not back in IDLE. |
| 625 for (int i = 0; i < draw_limit; ++i) { | 614 for (int i = 0; i < draw_limit; ++i) { |
| 626 state.SetNeedsRedraw(true); | 615 state.SetNeedsRedraw(true); |
| 627 state.OnBeginImplFrame(); | 616 state.OnBeginImplFrame(); |
| 628 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 617 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 629 state.OnBeginImplFrameDeadline(); | 618 state.OnBeginImplFrameDeadline(); |
| 630 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); | 619 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
| 631 EXPECT_ACTION_UPDATE_STATE( | 620 EXPECT_ACTION_UPDATE_STATE( |
| 632 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 621 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 633 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 622 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 634 state.OnBeginImplFrameIdle(); | 623 state.OnBeginImplFrameIdle(); |
| 635 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 624 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 636 } | 625 } |
| 637 EXPECT_TRUE(state.RedrawPending()); | 626 EXPECT_TRUE(state.RedrawPending()); |
| 638 EXPECT_TRUE(state.ForcedRedrawState() == | 627 EXPECT_TRUE(state.ForcedRedrawState() == |
| 639 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); | 628 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_COMMIT); |
| 640 } | 629 } |
| 641 | 630 |
| 642 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { | 631 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { |
| 643 SchedulerSettings default_scheduler_settings; | 632 SchedulerSettings default_scheduler_settings; |
| 644 StateMachine state(default_scheduler_settings); | 633 StateMachine state(default_scheduler_settings); |
| 645 SET_UP_STATE(state) | 634 SET_UP_STATE(state) |
| 646 | 635 |
| 647 // Start a draw. | 636 // Start a draw. |
| 648 state.SetNeedsRedraw(true); | 637 state.SetNeedsRedraw(true); |
| 649 EXPECT_TRUE(state.BeginFrameNeeded()); | 638 EXPECT_TRUE(state.BeginFrameNeeded()); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 EXPECT_ACTION_UPDATE_STATE( | 1003 EXPECT_ACTION_UPDATE_STATE( |
| 1015 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1004 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1016 state.NotifyBeginMainFrameStarted(); | 1005 state.NotifyBeginMainFrameStarted(); |
| 1017 state.NotifyReadyToCommit(); | 1006 state.NotifyReadyToCommit(); |
| 1018 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1007 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1019 } | 1008 } |
| 1020 | 1009 |
| 1021 TEST(SchedulerStateMachineTest, DontCommitWithoutDrawWithoutPendingTree) { | 1010 TEST(SchedulerStateMachineTest, DontCommitWithoutDrawWithoutPendingTree) { |
| 1022 SchedulerSettings scheduler_settings; | 1011 SchedulerSettings scheduler_settings; |
| 1023 scheduler_settings.commit_to_active_tree = true; | 1012 scheduler_settings.commit_to_active_tree = true; |
| 1013 scheduler_settings.main_frame_before_activation_enabled = false; |
| 1024 StateMachine state(scheduler_settings); | 1014 StateMachine state(scheduler_settings); |
| 1025 SET_UP_STATE(state) | 1015 SET_UP_STATE(state) |
| 1026 | 1016 |
| 1027 // Start clean and set commit. | 1017 // Start clean and set commit. |
| 1028 state.SetNeedsBeginMainFrame(); | 1018 state.SetNeedsBeginMainFrame(); |
| 1029 | 1019 |
| 1030 // Make a main frame, commit and activate it. But don't draw it. | 1020 // Make a main frame, commit and activate it. But don't draw it. |
| 1031 state.OnBeginImplFrame(); | 1021 state.OnBeginImplFrame(); |
| 1032 EXPECT_ACTION_UPDATE_STATE( | 1022 EXPECT_ACTION_UPDATE_STATE( |
| 1033 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1023 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); | 1085 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); |
| 1096 EXPECT_FALSE(state.has_pending_tree()); | 1086 EXPECT_FALSE(state.has_pending_tree()); |
| 1097 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1087 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1098 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1088 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1099 EXPECT_TRUE(state.has_pending_tree()); | 1089 EXPECT_TRUE(state.has_pending_tree()); |
| 1100 } | 1090 } |
| 1101 | 1091 |
| 1102 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitToActive) { | 1092 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitToActive) { |
| 1103 SchedulerSettings scheduler_settings; | 1093 SchedulerSettings scheduler_settings; |
| 1104 scheduler_settings.commit_to_active_tree = true; | 1094 scheduler_settings.commit_to_active_tree = true; |
| 1095 scheduler_settings.main_frame_before_activation_enabled = false; |
| 1105 StateMachine state(scheduler_settings); | 1096 StateMachine state(scheduler_settings); |
| 1106 SET_UP_STATE(state) | 1097 SET_UP_STATE(state) |
| 1107 | 1098 |
| 1108 // Start clean and set commit. | 1099 // Start clean and set commit. |
| 1109 state.SetNeedsBeginMainFrame(); | 1100 state.SetNeedsBeginMainFrame(); |
| 1110 | 1101 |
| 1111 // Begin the frame. | 1102 // Begin the frame. |
| 1112 state.OnBeginImplFrame(); | 1103 state.OnBeginImplFrame(); |
| 1113 EXPECT_ACTION_UPDATE_STATE( | 1104 EXPECT_ACTION_UPDATE_STATE( |
| 1114 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1105 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 state.OnBeginImplFrameDeadline(); | 2167 state.OnBeginImplFrameDeadline(); |
| 2177 state.OnBeginImplFrameIdle(); | 2168 state.OnBeginImplFrameIdle(); |
| 2178 | 2169 |
| 2179 // The scheduler should begin the output surface creation now. | 2170 // The scheduler should begin the output surface creation now. |
| 2180 EXPECT_ACTION_UPDATE_STATE( | 2171 EXPECT_ACTION_UPDATE_STATE( |
| 2181 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); | 2172 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); |
| 2182 } | 2173 } |
| 2183 | 2174 |
| 2184 } // namespace | 2175 } // namespace |
| 2185 } // namespace cc | 2176 } // namespace cc |
| OLD | NEW |