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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1476 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
1477 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); | 1477 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); |
1478 | 1478 |
1479 bool expect_send_begin_main_frame = true; | 1479 bool expect_send_begin_main_frame = true; |
1480 EXPECT_SCOPED( | 1480 EXPECT_SCOPED( |
1481 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1481 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
1482 } | 1482 } |
1483 | 1483 |
1484 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the | 1484 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the |
1485 // queue, which means there is no latency to recover. | 1485 // queue, which means there is no latency to recover. |
1486 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateAbort) { | 1486 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateBeginMainFrameAbort) { |
1487 scheduler_settings_.use_external_begin_frame_source = true; | 1487 scheduler_settings_.use_external_begin_frame_source = true; |
1488 SetUpScheduler(true); | 1488 SetUpScheduler(true); |
1489 | 1489 |
1490 // Use fast estimates so we think we can recover latency if needed. | 1490 // Use fast estimates so we think we can recover latency if needed. |
1491 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1491 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
1492 | 1492 |
1493 // Impl thread hits deadline before BeginMainFrame aborts. | 1493 // Impl thread hits deadline before BeginMainFrame aborts. |
1494 scheduler_->SetNeedsBeginMainFrame(); | 1494 scheduler_->SetNeedsBeginMainFrame(); |
1495 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1495 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
1496 EXPECT_SCOPED(AdvanceFrame()); | 1496 EXPECT_SCOPED(AdvanceFrame()); |
(...skipping 14 matching lines...) Expand all Loading... |
1511 scheduler_->SetNeedsBeginMainFrame(); | 1511 scheduler_->SetNeedsBeginMainFrame(); |
1512 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1512 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
1513 EXPECT_SCOPED(AdvanceFrame()); | 1513 EXPECT_SCOPED(AdvanceFrame()); |
1514 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); | 1514 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); |
1515 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1515 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
1516 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1516 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
1517 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1517 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
1518 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1518 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
1519 } | 1519 } |
1520 | 1520 |
| 1521 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the |
| 1522 // queue, which means there is no latency to recover. |
| 1523 TEST_F(SchedulerTest, MainFrameNotSkippedAfterCanDrawChanges) { |
| 1524 scheduler_settings_.use_external_begin_frame_source = true; |
| 1525 SetUpScheduler(true); |
| 1526 |
| 1527 // Use fast estimates so we think we can recover latency if needed. |
| 1528 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1529 |
| 1530 // Impl thread hits deadline before BeginMainFrame aborts. |
| 1531 scheduler_->SetNeedsBeginMainFrame(); |
| 1532 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1533 EXPECT_SCOPED(AdvanceFrame()); |
| 1534 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); |
| 1535 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1536 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); |
| 1537 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1538 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1539 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1540 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 1541 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1542 |
| 1543 // Make us abort the upcoming draw. |
| 1544 client_->Reset(); |
| 1545 scheduler_->NotifyReadyToCommit(); |
| 1546 scheduler_->NotifyReadyToActivate(); |
| 1547 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 2); |
| 1548 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 2); |
| 1549 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1550 scheduler_->SetCanDraw(false); |
| 1551 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1552 |
| 1553 // Make CanDraw true after activation. |
| 1554 client_->Reset(); |
| 1555 scheduler_->SetCanDraw(true); |
| 1556 EXPECT_NO_ACTION(client_); |
| 1557 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1558 |
| 1559 // Make sure we don't skip the next BeginMainFrame. |
| 1560 client_->Reset(); |
| 1561 scheduler_->SetNeedsBeginMainFrame(); |
| 1562 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1563 EXPECT_SCOPED(AdvanceFrame()); |
| 1564 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); |
| 1565 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1566 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1567 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1568 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1569 } |
| 1570 |
1521 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( | 1571 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( |
1522 bool swap_ack_before_deadline) { | 1572 bool swap_ack_before_deadline) { |
1523 // To get into a high latency state, this test disables automatic swap acks. | 1573 // To get into a high latency state, this test disables automatic swap acks. |
1524 client_->SetAutomaticSwapAck(false); | 1574 client_->SetAutomaticSwapAck(false); |
1525 | 1575 |
1526 // Draw and swap for first BeginFrame | 1576 // Draw and swap for first BeginFrame |
1527 client_->Reset(); | 1577 client_->Reset(); |
1528 scheduler_->SetNeedsBeginMainFrame(); | 1578 scheduler_->SetNeedsBeginMainFrame(); |
1529 scheduler_->SetNeedsRedraw(); | 1579 scheduler_->SetNeedsRedraw(); |
1530 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1580 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
(...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3625 } | 3675 } |
3626 | 3676 |
3627 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3677 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
3628 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3678 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
3629 SMOOTHNESS_TAKES_PRIORITY, | 3679 SMOOTHNESS_TAKES_PRIORITY, |
3630 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3680 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
3631 } | 3681 } |
3632 | 3682 |
3633 } // namespace | 3683 } // namespace |
3634 } // namespace cc | 3684 } // namespace cc |
OLD | NEW |