Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: cc/scheduler/scheduler_state_machine_unittest.cc

Issue 311353003: cc: Don't swap throttle BeginMainFrame within deadline (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
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);
1789 state.DidSwapBuffersComplete();
1790 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1791
1792 // Finish the previous commit and draw it.
1793 state.NotifyBeginMainFrameStarted();
1794 state.NotifyReadyToCommit();
1795 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1796 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1797 state.NotifyReadyToActivate();
1798 EXPECT_ACTION_UPDATE_STATE(
1799 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE);
1800 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1801
1802 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
1803 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
1804 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1805
1806 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly());
1807 state.OnBeginImplFrameDeadline();
1808 EXPECT_ACTION_UPDATE_STATE(
1809 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1810 state.DidSwapBuffers();
1811 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1812
1813 // Verify we do not send another BeginMainFrame in the deadline if we
1814 // did not just swap.
1815 state.SetNeedsCommit();
1816 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1817 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
1818 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1819 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly());
1820 state.OnBeginImplFrameDeadline();
1821 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1750 } 1822 }
1751 1823
1752 TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyOnLostOutputSurface) { 1824 TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyOnLostOutputSurface) {
1753 SchedulerSettings default_scheduler_settings; 1825 SchedulerSettings default_scheduler_settings;
1754 StateMachine state(default_scheduler_settings); 1826 StateMachine state(default_scheduler_settings);
1755 state.SetCanStart(); 1827 state.SetCanStart();
1756 state.UpdateState(state.NextAction()); 1828 state.UpdateState(state.NextAction());
1757 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1829 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1758 state.SetVisible(true); 1830 state.SetVisible(true);
1759 state.SetCanDraw(true); 1831 state.SetCanDraw(true);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 state.SetNeedsAnimate(); 1918 state.SetNeedsAnimate();
1847 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1919 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1848 1920
1849 state.OnBeginImplFrameDeadline(); 1921 state.OnBeginImplFrameDeadline();
1850 EXPECT_ACTION_UPDATE_STATE( 1922 EXPECT_ACTION_UPDATE_STATE(
1851 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 1923 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1852 } 1924 }
1853 1925
1854 } // namespace 1926 } // namespace
1855 } // namespace cc 1927 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698