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