| 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 scheduler_settings_.use_external_begin_frame_source = true; | 1476 scheduler_settings_.use_external_begin_frame_source = true; |
| 1477 SetUpScheduler(true); | 1477 SetUpScheduler(true); |
| 1478 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1478 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1479 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); | 1479 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); |
| 1480 | 1480 |
| 1481 bool expect_send_begin_main_frame = true; | 1481 bool expect_send_begin_main_frame = true; |
| 1482 EXPECT_SCOPED( | 1482 EXPECT_SCOPED( |
| 1483 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1483 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the |
| 1487 // queue, which means there is no latency to recover. |
| 1488 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateAbort) { |
| 1489 scheduler_settings_.use_external_begin_frame_source = true; |
| 1490 SetUpScheduler(true); |
| 1491 |
| 1492 // Use fast estimates so we think we can recover latency if needed. |
| 1493 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1494 |
| 1495 // Impl thread hits deadline before BeginMainFrame aborts. |
| 1496 scheduler_->SetNeedsBeginMainFrame(); |
| 1497 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1498 EXPECT_SCOPED(AdvanceFrame()); |
| 1499 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1500 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1501 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1502 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 1503 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); |
| 1504 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1505 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); |
| 1506 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1507 |
| 1508 // After aborting the frame, make sure we don't skip the |
| 1509 // next BeginMainFrame. |
| 1510 client_->Reset(); |
| 1511 scheduler_->BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 1512 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1513 scheduler_->SetNeedsBeginMainFrame(); |
| 1514 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1515 EXPECT_SCOPED(AdvanceFrame()); |
| 1516 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1517 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1518 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1519 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); |
| 1520 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1521 } |
| 1522 |
| 1486 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( | 1523 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( |
| 1487 bool swap_ack_before_deadline) { | 1524 bool swap_ack_before_deadline) { |
| 1488 // To get into a high latency state, this test disables automatic swap acks. | 1525 // To get into a high latency state, this test disables automatic swap acks. |
| 1489 client_->SetAutomaticSwapAck(false); | 1526 client_->SetAutomaticSwapAck(false); |
| 1490 | 1527 |
| 1491 // Draw and swap for first BeginFrame | 1528 // Draw and swap for first BeginFrame |
| 1492 client_->Reset(); | 1529 client_->Reset(); |
| 1493 scheduler_->SetNeedsBeginMainFrame(); | 1530 scheduler_->SetNeedsBeginMainFrame(); |
| 1494 scheduler_->SetNeedsRedraw(); | 1531 scheduler_->SetNeedsRedraw(); |
| 1495 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1532 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| (...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3587 } | 3624 } |
| 3588 | 3625 |
| 3589 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3626 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3590 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3627 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3591 SMOOTHNESS_TAKES_PRIORITY, | 3628 SMOOTHNESS_TAKES_PRIORITY, |
| 3592 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3629 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3593 } | 3630 } |
| 3594 | 3631 |
| 3595 } // namespace | 3632 } // namespace |
| 3596 } // namespace cc | 3633 } // namespace cc |
| OLD | NEW |