Chromium Code Reviews| 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 "cc/scheduler/scheduler.h" | 7 #include "cc/scheduler/scheduler.h" |
| 8 #include "cc/test/begin_frame_args_test.h" | 8 #include "cc/test/begin_frame_args_test.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1716 | 1716 |
| 1717 // Since only the scroll offset changed, the main thread will abort the | 1717 // Since only the scroll offset changed, the main thread will abort the |
| 1718 // commit. | 1718 // commit. |
| 1719 state.BeginMainFrameAborted(true); | 1719 state.BeginMainFrameAborted(true); |
| 1720 | 1720 |
| 1721 // Since the commit was aborted, we should draw right away instead of waiting | 1721 // Since the commit was aborted, we should draw right away instead of waiting |
| 1722 // for the deadline. | 1722 // for the deadline. |
| 1723 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1723 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyForSmoothness) { | 1726 TEST(SchedulerStateMachineTest, TestSmoothnessTakesPriority) { |
| 1727 SchedulerSettings settings; | 1727 SchedulerSettings settings; |
| 1728 settings.impl_side_painting = true; | 1728 settings.impl_side_painting = true; |
| 1729 StateMachine state(settings); | 1729 StateMachine state(settings); |
| 1730 state.SetCanStart(); | 1730 state.SetCanStart(); |
| 1731 state.UpdateState(state.NextAction()); | 1731 state.UpdateState(state.NextAction()); |
| 1732 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1732 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1733 state.SetVisible(true); | 1733 state.SetVisible(true); |
| 1734 state.SetCanDraw(true); | 1734 state.SetCanDraw(true); |
| 1735 | 1735 |
| 1736 // This test ensures that impl-draws are prioritized over main thread updates | 1736 // This test ensures that impl-draws are prioritized over main thread updates |
| 1737 // in prefer smoothness mode. | 1737 // in prefer smoothness mode. |
| 1738 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); | |
| 1739 state.SetNeedsRedraw(true); | 1738 state.SetNeedsRedraw(true); |
| 1740 state.SetNeedsCommit(); | 1739 state.SetNeedsCommit(); |
| 1740 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); | |
| 1741 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); | 1741 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
| 1742 EXPECT_ACTION_UPDATE_STATE( | 1742 EXPECT_ACTION_UPDATE_STATE( |
| 1743 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1743 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1744 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1744 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1745 | 1745 |
| 1746 // The deadline is not triggered early until we enter prefer smoothness mode. | 1746 // Verify the deadline is not triggered early until we enter |
| 1747 // prefer smoothness mode. | |
| 1747 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1748 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
| 1748 state.SetSmoothnessTakesPriority(true); | 1749 state.SetSmoothnessTakesPriority(true); |
| 1749 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1750 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
| 1751 | |
| 1752 // Trigger the deadline. | |
| 1753 state.OnBeginImplFrameDeadline(); | |
| 1754 EXPECT_ACTION_UPDATE_STATE( | |
| 1755 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | |
| 1756 state.DidSwapBuffers(); | |
| 1757 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
| 1758 state.DidSwapBuffersComplete(); | |
| 1759 | |
| 1760 // Finish the previous commit.and initiate another one. | |
|
simonhong
2014/06/06 11:12:00
nit: there is a point "commit.and"
| |
| 1761 state.SetNeedsCommit(); | |
| 1762 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
| 1763 state.NotifyBeginMainFrameStarted(); | |
| 1764 state.NotifyReadyToCommit(); | |
| 1765 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | |
| 1766 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
| 1767 state.NotifyReadyToActivate(); | |
| 1768 EXPECT_ACTION_UPDATE_STATE( | |
| 1769 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); | |
| 1770 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
| 1771 | |
| 1772 // Trigger another BeginFrame. | |
| 1773 // Since we are in prefer smoothness mode, we do not start the next | |
| 1774 // BeginMainFrame until after we draw. | |
| 1775 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); | |
| 1776 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); | |
| 1777 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
| 1778 | |
| 1779 // Trigger the deadline and verify we send the BeginMainFrame after we | |
| 1780 // draw, even if we are swap throttled. | |
| 1781 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | |
| 1782 state.OnBeginImplFrameDeadline(); | |
| 1783 EXPECT_ACTION_UPDATE_STATE( | |
| 1784 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | |
| 1785 state.DidSwapBuffers(); | |
| 1786 EXPECT_ACTION_UPDATE_STATE( | |
| 1787 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | |
| 1788 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
| 1750 } | 1789 } |
| 1751 | 1790 |
| 1752 TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyOnLostOutputSurface) { | 1791 TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyOnLostOutputSurface) { |
| 1753 SchedulerSettings default_scheduler_settings; | 1792 SchedulerSettings default_scheduler_settings; |
| 1754 StateMachine state(default_scheduler_settings); | 1793 StateMachine state(default_scheduler_settings); |
| 1755 state.SetCanStart(); | 1794 state.SetCanStart(); |
| 1756 state.UpdateState(state.NextAction()); | 1795 state.UpdateState(state.NextAction()); |
| 1757 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1796 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1758 state.SetVisible(true); | 1797 state.SetVisible(true); |
| 1759 state.SetCanDraw(true); | 1798 state.SetCanDraw(true); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1846 state.SetNeedsAnimate(); | 1885 state.SetNeedsAnimate(); |
| 1847 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1886 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1848 | 1887 |
| 1849 state.OnBeginImplFrameDeadline(); | 1888 state.OnBeginImplFrameDeadline(); |
| 1850 EXPECT_ACTION_UPDATE_STATE( | 1889 EXPECT_ACTION_UPDATE_STATE( |
| 1851 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1890 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1852 } | 1891 } |
| 1853 | 1892 |
| 1854 } // namespace | 1893 } // namespace |
| 1855 } // namespace cc | 1894 } // namespace cc |
| OLD | NEW |