| 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.h" | 5 #include "cc/scheduler/scheduler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 base::TimeDelta CommitToActivateDurationEstimate() override { | 154 base::TimeDelta CommitToActivateDurationEstimate() override { |
| 155 return base::TimeDelta(); | 155 return base::TimeDelta(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void DidBeginImplFrameDeadline() override {} | 158 void DidBeginImplFrameDeadline() override {} |
| 159 | 159 |
| 160 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { | 160 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { |
| 161 begin_frame_is_sent_to_children_ = true; | 161 begin_frame_is_sent_to_children_ = true; |
| 162 } | 162 } |
| 163 | 163 |
| 164 void SendBeginMainFrameNotExpectedSoon() override { |
| 165 PushAction("SendBeginMainFrameNotExpectedSoon"); |
| 166 } |
| 167 |
| 164 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { | 168 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { |
| 165 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback, | 169 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback, |
| 166 base::Unretained(this), | 170 base::Unretained(this), |
| 167 state); | 171 state); |
| 168 } | 172 } |
| 169 | 173 |
| 170 bool begin_frame_is_sent_to_children() const { | 174 bool begin_frame_is_sent_to_children() const { |
| 171 return begin_frame_is_sent_to_children_; | 175 return begin_frame_is_sent_to_children_; |
| 172 } | 176 } |
| 173 | 177 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 client_->Reset(); | 514 client_->Reset(); |
| 511 | 515 |
| 512 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) | 516 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 513 // to avoid excessive toggles. | 517 // to avoid excessive toggles. |
| 514 EXPECT_SCOPED(AdvanceFrame()); | 518 EXPECT_SCOPED(AdvanceFrame()); |
| 515 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 519 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 516 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 520 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 517 client_->Reset(); | 521 client_->Reset(); |
| 518 | 522 |
| 519 task_runner().RunPendingTasks(); // Run posted deadline. | 523 task_runner().RunPendingTasks(); // Run posted deadline. |
| 520 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 524 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 525 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 521 client_->Reset(); | 526 client_->Reset(); |
| 522 } | 527 } |
| 523 | 528 |
| 524 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { | 529 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { |
| 525 scheduler_settings_.use_external_begin_frame_source = true; | 530 scheduler_settings_.use_external_begin_frame_source = true; |
| 526 SetUpScheduler(true); | 531 SetUpScheduler(true); |
| 527 | 532 |
| 528 scheduler_->SetCanStart(); | 533 scheduler_->SetCanStart(); |
| 529 scheduler_->SetVisible(true); | 534 scheduler_->SetVisible(true); |
| 530 scheduler_->SetCanDraw(true); | 535 scheduler_->SetCanDraw(true); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 999 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 995 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1000 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 996 | 1001 |
| 997 // We need a BeginImplFrame where we don't swap to go idle. | 1002 // We need a BeginImplFrame where we don't swap to go idle. |
| 998 client->Reset(); | 1003 client->Reset(); |
| 999 EXPECT_SCOPED(AdvanceFrame()); | 1004 EXPECT_SCOPED(AdvanceFrame()); |
| 1000 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 1005 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 1001 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1006 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1002 client->Reset(); | 1007 client->Reset(); |
| 1003 task_runner().RunPendingTasks(); // Run posted deadline. | 1008 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1004 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client); | 1009 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 1010 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 1005 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1011 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1006 EXPECT_EQ(0, client->num_draws()); | 1012 EXPECT_EQ(0, client->num_draws()); |
| 1007 | 1013 |
| 1008 // Now trigger a PrepareTiles outside of a draw. We will then need | 1014 // Now trigger a PrepareTiles outside of a draw. We will then need |
| 1009 // a begin-frame for the PrepareTiles, but we don't need a draw. | 1015 // a begin-frame for the PrepareTiles, but we don't need a draw. |
| 1010 client->Reset(); | 1016 client->Reset(); |
| 1011 EXPECT_FALSE(client->needs_begin_frames()); | 1017 EXPECT_FALSE(client->needs_begin_frames()); |
| 1012 scheduler_->SetNeedsPrepareTiles(); | 1018 scheduler_->SetNeedsPrepareTiles(); |
| 1013 EXPECT_TRUE(client->needs_begin_frames()); | 1019 EXPECT_TRUE(client->needs_begin_frames()); |
| 1014 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 1020 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 client_->Reset(); | 1375 client_->Reset(); |
| 1370 | 1376 |
| 1371 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) | 1377 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 1372 // to avoid excessive toggles. | 1378 // to avoid excessive toggles. |
| 1373 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 1379 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| 1374 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 1380 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 1375 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1381 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1376 client_->Reset(); | 1382 client_->Reset(); |
| 1377 | 1383 |
| 1378 task_runner().RunPendingTasks(); // Run posted deadline. | 1384 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1379 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 1385 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 1386 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 1380 client_->Reset(); | 1387 client_->Reset(); |
| 1381 } | 1388 } |
| 1382 | 1389 |
| 1383 TEST_F(SchedulerTest, BeginRetroFrame_SwapThrottled) { | 1390 TEST_F(SchedulerTest, BeginRetroFrame_SwapThrottled) { |
| 1384 scheduler_settings_.use_external_begin_frame_source = true; | 1391 scheduler_settings_.use_external_begin_frame_source = true; |
| 1385 SetUpScheduler(true); | 1392 SetUpScheduler(true); |
| 1386 | 1393 |
| 1387 scheduler_->SetEstimatedParentDrawTime(base::TimeDelta::FromMicroseconds(1)); | 1394 scheduler_->SetEstimatedParentDrawTime(base::TimeDelta::FromMicroseconds(1)); |
| 1388 | 1395 |
| 1389 // To test swap ack throttling, this test disables automatic swap acks. | 1396 // To test swap ack throttling, this test disables automatic swap acks. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) | 1627 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 1621 // to avoid excessive toggles. | 1628 // to avoid excessive toggles. |
| 1622 task_runner().RunPendingTasks(); // Run posted BeginFrame. | 1629 task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| 1623 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 1630 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 1624 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1631 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1625 client_->Reset(); | 1632 client_->Reset(); |
| 1626 | 1633 |
| 1627 // Make sure SetNeedsBeginFrame isn't called on the client | 1634 // Make sure SetNeedsBeginFrame isn't called on the client |
| 1628 // when the BeginFrame is no longer needed. | 1635 // when the BeginFrame is no longer needed. |
| 1629 task_runner().RunPendingTasks(); // Run posted deadline. | 1636 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1630 EXPECT_NO_ACTION(client_); | 1637 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); |
| 1631 client_->Reset(); | 1638 client_->Reset(); |
| 1632 } | 1639 } |
| 1633 | 1640 |
| 1634 TEST_F(SchedulerTest, SyntheticBeginFrames) { | 1641 TEST_F(SchedulerTest, SyntheticBeginFrames) { |
| 1635 bool use_external_begin_frame_source = false; | 1642 bool use_external_begin_frame_source = false; |
| 1636 bool throttle_frame_production = true; | 1643 bool throttle_frame_production = true; |
| 1637 BeginFramesNotFromClient(use_external_begin_frame_source, | 1644 BeginFramesNotFromClient(use_external_begin_frame_source, |
| 1638 throttle_frame_production); | 1645 throttle_frame_production); |
| 1639 } | 1646 } |
| 1640 | 1647 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 | 1783 |
| 1777 client_->Reset(); | 1784 client_->Reset(); |
| 1778 EXPECT_SCOPED(AdvanceFrame()); | 1785 EXPECT_SCOPED(AdvanceFrame()); |
| 1779 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1786 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1780 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 1787 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 1781 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1788 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1782 | 1789 |
| 1783 client_->Reset(); | 1790 client_->Reset(); |
| 1784 scheduler_->DidLoseOutputSurface(); | 1791 scheduler_->DidLoseOutputSurface(); |
| 1785 // Do nothing when impl frame is in deadine pending state. | 1792 // Do nothing when impl frame is in deadine pending state. |
| 1786 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 1793 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 1794 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 1787 | 1795 |
| 1788 client_->Reset(); | 1796 client_->Reset(); |
| 1789 scheduler_->NotifyBeginMainFrameStarted(); | 1797 scheduler_->NotifyBeginMainFrameStarted(); |
| 1790 scheduler_->NotifyReadyToCommit(); | 1798 scheduler_->NotifyReadyToCommit(); |
| 1791 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1); | 1799 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1); |
| 1792 | 1800 |
| 1793 client_->Reset(); | 1801 client_->Reset(); |
| 1794 task_runner().RunPendingTasks(); // Run posted deadline. | 1802 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1795 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); | 1803 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); |
| 1796 } | 1804 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1807 | 1815 |
| 1808 client_->Reset(); | 1816 client_->Reset(); |
| 1809 EXPECT_SCOPED(AdvanceFrame()); | 1817 EXPECT_SCOPED(AdvanceFrame()); |
| 1810 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1818 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1811 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 1819 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 1812 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1820 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1813 | 1821 |
| 1814 client_->Reset(); | 1822 client_->Reset(); |
| 1815 scheduler_->DidLoseOutputSurface(); | 1823 scheduler_->DidLoseOutputSurface(); |
| 1816 // Do nothing when impl frame is in deadine pending state. | 1824 // Do nothing when impl frame is in deadine pending state. |
| 1817 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 1825 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 1826 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 1818 | 1827 |
| 1819 client_->Reset(); | 1828 client_->Reset(); |
| 1820 // Run posted deadline. | 1829 // Run posted deadline. |
| 1821 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1830 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1822 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1831 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1823 // OnBeginImplFrameDeadline didn't schedule any actions because main frame is | 1832 // OnBeginImplFrameDeadline didn't schedule any actions because main frame is |
| 1824 // not yet completed. | 1833 // not yet completed. |
| 1825 EXPECT_NO_ACTION(client_); | 1834 EXPECT_NO_ACTION(client_); |
| 1826 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1835 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1827 | 1836 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 | 1883 |
| 1875 client_->Reset(); | 1884 client_->Reset(); |
| 1876 scheduler_->NotifyBeginMainFrameStarted(); | 1885 scheduler_->NotifyBeginMainFrameStarted(); |
| 1877 scheduler_->NotifyReadyToCommit(); | 1886 scheduler_->NotifyReadyToCommit(); |
| 1878 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 1887 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 1879 | 1888 |
| 1880 client_->Reset(); | 1889 client_->Reset(); |
| 1881 scheduler_->DidLoseOutputSurface(); | 1890 scheduler_->DidLoseOutputSurface(); |
| 1882 if (impl_side_painting) { | 1891 if (impl_side_painting) { |
| 1883 // Sync tree should be forced to activate. | 1892 // Sync tree should be forced to activate. |
| 1884 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 2); | 1893 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3); |
| 1885 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 2); | 1894 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 1895 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 1886 } else { | 1896 } else { |
| 1887 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 1897 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 1898 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 1888 } | 1899 } |
| 1889 | 1900 |
| 1890 client_->Reset(); | 1901 client_->Reset(); |
| 1891 task_runner().RunPendingTasks(); // Run posted deadline. | 1902 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1892 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); | 1903 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); |
| 1893 } | 1904 } |
| 1894 | 1905 |
| 1895 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) { | 1906 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) { |
| 1896 DidLoseOutputSurfaceAfterReadyToCommit(false); | 1907 DidLoseOutputSurfaceAfterReadyToCommit(false); |
| 1897 } | 1908 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1909 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 1920 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 1910 | 1921 |
| 1911 client_->Reset(); | 1922 client_->Reset(); |
| 1912 EXPECT_SCOPED(AdvanceFrame()); | 1923 EXPECT_SCOPED(AdvanceFrame()); |
| 1913 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1924 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1914 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1925 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1915 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1926 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1916 | 1927 |
| 1917 client_->Reset(); | 1928 client_->Reset(); |
| 1918 scheduler_->DidLoseOutputSurface(); | 1929 scheduler_->DidLoseOutputSurface(); |
| 1919 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 1930 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 1931 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 1920 | 1932 |
| 1921 client_->Reset(); | 1933 client_->Reset(); |
| 1922 task_runner().RunPendingTasks(); // Run posted deadline. | 1934 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1923 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 2); | 1935 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 2); |
| 1924 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 2); | 1936 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 2); |
| 1925 } | 1937 } |
| 1926 | 1938 |
| 1927 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { | 1939 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { |
| 1928 scheduler_settings_.use_external_begin_frame_source = true; | 1940 scheduler_settings_.use_external_begin_frame_source = true; |
| 1929 SetUpScheduler(true); | 1941 SetUpScheduler(true); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1960 // NotifyReadyToCommit should trigger the commit. | 1972 // NotifyReadyToCommit should trigger the commit. |
| 1961 client_->Reset(); | 1973 client_->Reset(); |
| 1962 scheduler_->NotifyBeginMainFrameStarted(); | 1974 scheduler_->NotifyBeginMainFrameStarted(); |
| 1963 scheduler_->NotifyReadyToCommit(); | 1975 scheduler_->NotifyReadyToCommit(); |
| 1964 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 1976 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 1965 EXPECT_TRUE(client_->needs_begin_frames()); | 1977 EXPECT_TRUE(client_->needs_begin_frames()); |
| 1966 | 1978 |
| 1967 client_->Reset(); | 1979 client_->Reset(); |
| 1968 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); | 1980 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); |
| 1969 scheduler_->DidLoseOutputSurface(); | 1981 scheduler_->DidLoseOutputSurface(); |
| 1970 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 2); | 1982 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); |
| 1971 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 2); | 1983 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 1984 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 1972 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); | 1985 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); |
| 1973 | 1986 |
| 1974 // Posted BeginRetroFrame is aborted. | 1987 // Posted BeginRetroFrame is aborted. |
| 1975 client_->Reset(); | 1988 client_->Reset(); |
| 1976 task_runner().RunPendingTasks(); | 1989 task_runner().RunPendingTasks(); |
| 1977 EXPECT_NO_ACTION(client_); | 1990 EXPECT_NO_ACTION(client_); |
| 1978 } | 1991 } |
| 1979 | 1992 |
| 1980 TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { | 1993 TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { |
| 1981 scheduler_settings_.use_external_begin_frame_source = true; | 1994 scheduler_settings_.use_external_begin_frame_source = true; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 client_->Reset(); | 2034 client_->Reset(); |
| 2022 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 2035 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| 2023 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2036 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2024 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 2037 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 2025 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2038 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2026 EXPECT_TRUE(client_->needs_begin_frames()); | 2039 EXPECT_TRUE(client_->needs_begin_frames()); |
| 2027 | 2040 |
| 2028 client_->Reset(); | 2041 client_->Reset(); |
| 2029 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); | 2042 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); |
| 2030 scheduler_->DidLoseOutputSurface(); | 2043 scheduler_->DidLoseOutputSurface(); |
| 2031 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 2044 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 2045 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 2032 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); | 2046 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); |
| 2033 | 2047 |
| 2034 // BeginImplFrame deadline should abort drawing. | 2048 // BeginImplFrame deadline should abort drawing. |
| 2035 client_->Reset(); | 2049 client_->Reset(); |
| 2036 task_runner().RunPendingTasks(); // Run posted deadline. | 2050 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2037 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); | 2051 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); |
| 2038 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 2052 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2039 EXPECT_FALSE(client_->needs_begin_frames()); | 2053 EXPECT_FALSE(client_->needs_begin_frames()); |
| 2040 | 2054 |
| 2041 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. | 2055 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2062 | 2076 |
| 2063 // NotifyReadyToCommit should trigger the commit. | 2077 // NotifyReadyToCommit should trigger the commit. |
| 2064 client_->Reset(); | 2078 client_->Reset(); |
| 2065 scheduler_->NotifyBeginMainFrameStarted(); | 2079 scheduler_->NotifyBeginMainFrameStarted(); |
| 2066 scheduler_->NotifyReadyToCommit(); | 2080 scheduler_->NotifyReadyToCommit(); |
| 2067 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 2081 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 2068 EXPECT_TRUE(scheduler_->frame_source().NeedsBeginFrames()); | 2082 EXPECT_TRUE(scheduler_->frame_source().NeedsBeginFrames()); |
| 2069 | 2083 |
| 2070 client_->Reset(); | 2084 client_->Reset(); |
| 2071 scheduler_->DidLoseOutputSurface(); | 2085 scheduler_->DidLoseOutputSurface(); |
| 2072 EXPECT_NO_ACTION(client_); | 2086 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); |
| 2073 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames()); | 2087 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames()); |
| 2074 | 2088 |
| 2075 client_->Reset(); | 2089 client_->Reset(); |
| 2076 task_runner().RunPendingTasks(); // Run posted deadline. | 2090 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2077 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); | 2091 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); |
| 2078 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames()); | 2092 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames()); |
| 2079 } | 2093 } |
| 2080 | 2094 |
| 2081 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) { | 2095 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) { |
| 2082 scheduler_settings_.impl_side_painting = true; | 2096 scheduler_settings_.impl_side_painting = true; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2340 EXPECT_SCOPED(AdvanceFrame()); | 2354 EXPECT_SCOPED(AdvanceFrame()); |
| 2341 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2355 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2342 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 2356 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 2343 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2357 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2344 EXPECT_TRUE(client_->needs_begin_frames()); | 2358 EXPECT_TRUE(client_->needs_begin_frames()); |
| 2345 client_->Reset(); | 2359 client_->Reset(); |
| 2346 task_runner().RunPendingTasks(); // Run posted deadline. | 2360 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2347 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 2361 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 2348 } | 2362 } |
| 2349 | 2363 |
| 2364 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. |
| 2365 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { |
| 2366 scheduler_settings_.use_external_begin_frame_source = true; |
| 2367 SetUpScheduler(true); |
| 2368 |
| 2369 // SetNeedsCommit should begin the frame on the next BeginImplFrame. |
| 2370 scheduler_->SetNeedsCommit(); |
| 2371 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 2372 client_->Reset(); |
| 2373 |
| 2374 // Trigger a frame draw. |
| 2375 EXPECT_SCOPED(AdvanceFrame()); |
| 2376 scheduler_->NotifyBeginMainFrameStarted(); |
| 2377 scheduler_->NotifyReadyToCommit(); |
| 2378 task_runner().RunPendingTasks(); |
| 2379 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 5); |
| 2380 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 5); |
| 2381 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 5); |
| 2382 EXPECT_ACTION("ScheduledActionAnimate", client_, 3, 5); |
| 2383 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5); |
| 2384 client_->Reset(); |
| 2385 |
| 2386 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 2387 // and send a SendBeginMainFrameNotExpectedSoon. |
| 2388 EXPECT_SCOPED(AdvanceFrame()); |
| 2389 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 2390 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2391 client_->Reset(); |
| 2392 |
| 2393 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2394 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 2395 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 2396 client_->Reset(); |
| 2397 } |
| 2398 |
| 2350 } // namespace | 2399 } // namespace |
| 2351 } // namespace cc | 2400 } // namespace cc |
| OLD | NEW |