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/debug/trace_event.h" | 7 #include "base/debug/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 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); | 1740 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
1741 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1741 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1742 | 1742 |
1743 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1743 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1744 state.OnBeginImplFrameDeadline(); | 1744 state.OnBeginImplFrameDeadline(); |
1745 EXPECT_ACTION_UPDATE_STATE( | 1745 EXPECT_ACTION_UPDATE_STATE( |
1746 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1746 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
1747 state.DidSwapBuffers(); | 1747 state.DidSwapBuffers(); |
1748 } | 1748 } |
1749 | 1749 |
1750 TEST(SchedulerStateMachineTest, TestSmoothnessTakesPriority) { | 1750 TEST(SchedulerStateMachineTest, TestImplLatencyTakesPriority) { |
1751 SchedulerSettings settings; | 1751 SchedulerSettings settings; |
1752 settings.impl_side_painting = true; | 1752 settings.impl_side_painting = true; |
1753 StateMachine state(settings); | 1753 StateMachine state(settings); |
1754 state.SetCanStart(); | 1754 state.SetCanStart(); |
1755 state.UpdateState(state.NextAction()); | 1755 state.UpdateState(state.NextAction()); |
1756 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1756 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1757 state.SetVisible(true); | 1757 state.SetVisible(true); |
1758 state.SetCanDraw(true); | 1758 state.SetCanDraw(true); |
1759 | 1759 |
1760 // This test ensures that impl-draws are prioritized over main thread updates | 1760 // This test ensures that impl-draws are prioritized over main thread updates |
1761 // in prefer smoothness mode. | 1761 // in prefer impl latency mode. |
1762 state.SetNeedsRedraw(true); | 1762 state.SetNeedsRedraw(true); |
1763 state.SetNeedsCommit(); | 1763 state.SetNeedsCommit(); |
1764 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); | 1764 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); |
1765 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); | 1765 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
1766 EXPECT_ACTION_UPDATE_STATE( | 1766 EXPECT_ACTION_UPDATE_STATE( |
1767 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1767 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1768 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1768 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1769 | 1769 |
1770 // Verify the deadline is not triggered early until we enter | 1770 // Verify the deadline is not triggered early until we enter |
1771 // prefer smoothness mode. | 1771 // prefer impl latency mode. |
1772 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1772 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1773 state.SetSmoothnessTakesPriority(true); | 1773 state.SetImplLatencyTakesPriority(true); |
1774 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1774 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1775 | 1775 |
1776 // Trigger the deadline. | 1776 // Trigger the deadline. |
1777 state.OnBeginImplFrameDeadline(); | 1777 state.OnBeginImplFrameDeadline(); |
1778 EXPECT_ACTION_UPDATE_STATE( | 1778 EXPECT_ACTION_UPDATE_STATE( |
1779 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1779 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
1780 state.DidSwapBuffers(); | 1780 state.DidSwapBuffers(); |
1781 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1781 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1782 state.DidSwapBuffersComplete(); | 1782 state.DidSwapBuffersComplete(); |
1783 | 1783 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 state.SetNeedsAnimate(); | 1902 state.SetNeedsAnimate(); |
1903 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1903 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1904 | 1904 |
1905 state.OnBeginImplFrameDeadline(); | 1905 state.OnBeginImplFrameDeadline(); |
1906 EXPECT_ACTION_UPDATE_STATE( | 1906 EXPECT_ACTION_UPDATE_STATE( |
1907 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1907 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
1908 } | 1908 } |
1909 | 1909 |
1910 } // namespace | 1910 } // namespace |
1911 } // namespace cc | 1911 } // namespace cc |
OLD | NEW |