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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 // Swapping will put us into a swap throttled state. | 1487 // Swapping will put us into a swap throttled state. |
1488 // Run posted deadline. | 1488 // Run posted deadline. |
1489 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1489 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
1490 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); | 1490 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); |
1491 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); | 1491 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); |
1492 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1492 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
1493 EXPECT_TRUE(client_->needs_begin_frames()); | 1493 EXPECT_TRUE(client_->needs_begin_frames()); |
1494 client_->Reset(); | 1494 client_->Reset(); |
1495 | 1495 |
1496 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames | 1496 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames |
1497 // and BeginMainFrame. | 1497 // but not a BeginMainFrame or draw. |
1498 scheduler_->SetNeedsCommit(); | 1498 scheduler_->SetNeedsCommit(); |
1499 scheduler_->SetNeedsRedraw(); | 1499 scheduler_->SetNeedsRedraw(); |
1500 // Run posted BeginRetroFrame. | 1500 // Run posted BeginRetroFrame. |
1501 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); | 1501 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); |
1502 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 1502 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
1503 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | 1503 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
1504 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | |
1505 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1504 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1506 EXPECT_TRUE(client_->needs_begin_frames()); | 1505 EXPECT_TRUE(client_->needs_begin_frames()); |
1507 client_->Reset(); | 1506 client_->Reset(); |
1508 | 1507 |
1509 // Let time pass sufficiently beyond the regular deadline but not beyond the | 1508 // Let time pass sufficiently beyond the regular deadline but not beyond the |
1510 // late deadline. | 1509 // late deadline. |
1511 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - | 1510 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - |
1512 base::TimeDelta::FromMicroseconds(1)); | 1511 base::TimeDelta::FromMicroseconds(1)); |
1513 task_runner().RunUntilTime(now_src()->Now()); | 1512 task_runner().RunUntilTime(now_src()->Now()); |
1514 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1513 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1515 | 1514 |
1516 // Take us out of a swap throttled state. | 1515 // Take us out of a swap throttled state. |
1517 scheduler_->DidSwapBuffersComplete(); | 1516 scheduler_->DidSwapBuffersComplete(); |
1518 EXPECT_NO_ACTION(client_); | 1517 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
1519 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1518 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1520 EXPECT_TRUE(client_->needs_begin_frames()); | 1519 EXPECT_TRUE(client_->needs_begin_frames()); |
1521 client_->Reset(); | 1520 client_->Reset(); |
1522 | 1521 |
1523 // Verify that the deadline was rescheduled. | 1522 // Verify that the deadline was rescheduled. |
1524 task_runner().RunUntilTime(now_src()->Now()); | 1523 task_runner().RunUntilTime(now_src()->Now()); |
1525 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 1524 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
1526 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1525 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
1527 EXPECT_TRUE(client_->needs_begin_frames()); | 1526 EXPECT_TRUE(client_->needs_begin_frames()); |
1528 client_->Reset(); | 1527 client_->Reset(); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 client_->Reset(); | 1753 client_->Reset(); |
1755 | 1754 |
1756 // Swapping will put us into a swap throttled state. | 1755 // Swapping will put us into a swap throttled state. |
1757 // Run posted deadline. | 1756 // Run posted deadline. |
1758 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1757 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
1759 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); | 1758 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); |
1760 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); | 1759 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); |
1761 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1760 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
1762 client_->Reset(); | 1761 client_->Reset(); |
1763 | 1762 |
1764 // While swap throttled, BeginFrames should trigger BeginImplFrames | 1763 // While swap throttled, BeginFrames should trigger BeginImplFrames, |
1765 // and BeginMainFrame. | 1764 // but not a BeginMainFrame or draw. |
1766 scheduler_->SetNeedsCommit(); | 1765 scheduler_->SetNeedsCommit(); |
1767 scheduler_->SetNeedsRedraw(); | 1766 scheduler_->SetNeedsRedraw(); |
1768 EXPECT_SCOPED(AdvanceFrame()); // Run posted BeginFrame. | 1767 EXPECT_SCOPED(AdvanceFrame()); // Run posted BeginFrame. |
1769 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 1768 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
1770 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | 1769 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
1771 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | |
1772 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1770 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1773 client_->Reset(); | 1771 client_->Reset(); |
1774 | 1772 |
1775 // Let time pass sufficiently beyond the regular deadline but not beyond the | 1773 // Let time pass sufficiently beyond the regular deadline but not beyond the |
1776 // late deadline. | 1774 // late deadline. |
1777 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - | 1775 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - |
1778 base::TimeDelta::FromMicroseconds(1)); | 1776 base::TimeDelta::FromMicroseconds(1)); |
1779 task_runner().RunUntilTime(now_src()->Now()); | 1777 task_runner().RunUntilTime(now_src()->Now()); |
1780 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1778 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1781 | 1779 |
1782 // Take us out of a swap throttled state. | 1780 // Take us out of a swap throttled state. |
1783 scheduler_->DidSwapBuffersComplete(); | 1781 scheduler_->DidSwapBuffersComplete(); |
1784 EXPECT_NO_ACTION(client_); | 1782 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
1785 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1783 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1786 client_->Reset(); | 1784 client_->Reset(); |
1787 | 1785 |
1788 // Verify that the deadline was rescheduled. | 1786 // Verify that the deadline was rescheduled. |
1789 // We can't use RunUntilTime(now) here because the next frame is also | 1787 // We can't use RunUntilTime(now) here because the next frame is also |
1790 // scheduled if throttle_frame_production = false. | 1788 // scheduled if throttle_frame_production = false. |
1791 base::TimeTicks before_deadline = now_src()->Now(); | 1789 base::TimeTicks before_deadline = now_src()->Now(); |
1792 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1790 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
1793 base::TimeTicks after_deadline = now_src()->Now(); | 1791 base::TimeTicks after_deadline = now_src()->Now(); |
1794 EXPECT_EQ(after_deadline, before_deadline); | 1792 EXPECT_EQ(after_deadline, before_deadline); |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 | 2518 |
2521 // At the next BeginFrame, authoritative interval is used instead of previous | 2519 // At the next BeginFrame, authoritative interval is used instead of previous |
2522 // interval. | 2520 // interval. |
2523 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); | 2521 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); |
2524 EXPECT_EQ(authoritative_interval, | 2522 EXPECT_EQ(authoritative_interval, |
2525 scheduler_->begin_impl_frame_args().interval); | 2523 scheduler_->begin_impl_frame_args().interval); |
2526 } | 2524 } |
2527 | 2525 |
2528 } // namespace | 2526 } // namespace |
2529 } // namespace cc | 2527 } // namespace cc |
OLD | NEW |