| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 scheduler_->SetCanDraw(true); | 427 scheduler_->SetCanDraw(true); |
| 428 | 428 |
| 429 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); | 429 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); |
| 430 client_->Reset(); | 430 client_->Reset(); |
| 431 scheduler_->DidCreateAndInitializeOutputSurface(); | 431 scheduler_->DidCreateAndInitializeOutputSurface(); |
| 432 EXPECT_NO_ACTION(client_); | 432 EXPECT_NO_ACTION(client_); |
| 433 } | 433 } |
| 434 | 434 |
| 435 TEST_F(SchedulerTest, SendBeginFramesToChildren) { | 435 TEST_F(SchedulerTest, SendBeginFramesToChildren) { |
| 436 scheduler_settings_.use_external_begin_frame_source = true; | 436 scheduler_settings_.use_external_begin_frame_source = true; |
| 437 scheduler_settings_.forward_begin_frames_to_children = true; | |
| 438 SetUpScheduler(true); | 437 SetUpScheduler(true); |
| 439 | 438 |
| 440 EXPECT_FALSE(client_->begin_frame_is_sent_to_children()); | 439 EXPECT_FALSE(client_->begin_frame_is_sent_to_children()); |
| 441 scheduler_->SetNeedsCommit(); | 440 scheduler_->SetNeedsCommit(); |
| 442 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 441 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 443 EXPECT_TRUE(client_->needs_begin_frames()); | 442 EXPECT_TRUE(client_->needs_begin_frames()); |
| 444 | 443 |
| 445 scheduler_->SetChildrenNeedBeginFrames(true); | 444 scheduler_->SetChildrenNeedBeginFrames(true); |
| 446 | 445 |
| 447 client_->Reset(); | 446 client_->Reset(); |
| 448 EXPECT_SCOPED(AdvanceFrame()); | 447 EXPECT_SCOPED(AdvanceFrame()); |
| 449 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 448 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 450 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 449 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 451 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 450 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 452 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 451 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 453 EXPECT_TRUE(client_->needs_begin_frames()); | 452 EXPECT_TRUE(client_->needs_begin_frames()); |
| 454 } | 453 } |
| 455 | 454 |
| 456 TEST_F(SchedulerTest, SendBeginFramesToChildrenWithoutCommit) { | 455 TEST_F(SchedulerTest, SendBeginFramesToChildrenWithoutCommit) { |
| 457 scheduler_settings_.use_external_begin_frame_source = true; | 456 scheduler_settings_.use_external_begin_frame_source = true; |
| 458 scheduler_settings_.forward_begin_frames_to_children = true; | |
| 459 SetUpScheduler(true); | 457 SetUpScheduler(true); |
| 460 | 458 |
| 461 EXPECT_FALSE(client_->needs_begin_frames()); | 459 EXPECT_FALSE(client_->needs_begin_frames()); |
| 462 scheduler_->SetChildrenNeedBeginFrames(true); | 460 scheduler_->SetChildrenNeedBeginFrames(true); |
| 463 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 461 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 464 EXPECT_TRUE(client_->needs_begin_frames()); | 462 EXPECT_TRUE(client_->needs_begin_frames()); |
| 465 | 463 |
| 466 client_->Reset(); | 464 client_->Reset(); |
| 467 EXPECT_SCOPED(AdvanceFrame()); | 465 EXPECT_SCOPED(AdvanceFrame()); |
| 468 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 466 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 task_runner().RunPendingTasks(); // Run posted deadline. | 521 task_runner().RunPendingTasks(); // Run posted deadline. |
| 524 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); | 522 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 525 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 523 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 526 client_->Reset(); | 524 client_->Reset(); |
| 527 } | 525 } |
| 528 | 526 |
| 529 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { | 527 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { |
| 530 scheduler_settings_.use_external_begin_frame_source = true; | 528 scheduler_settings_.use_external_begin_frame_source = true; |
| 531 SetUpScheduler(true); | 529 SetUpScheduler(true); |
| 532 | 530 |
| 533 scheduler_->SetCanStart(); | |
| 534 scheduler_->SetVisible(true); | |
| 535 scheduler_->SetCanDraw(true); | |
| 536 | |
| 537 scheduler_->SetDeferCommits(true); | 531 scheduler_->SetDeferCommits(true); |
| 538 | 532 |
| 539 scheduler_->SetNeedsCommit(); | 533 scheduler_->SetNeedsCommit(); |
| 540 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 534 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 541 | 535 |
| 542 client_->Reset(); | 536 client_->Reset(); |
| 543 AdvanceFrame(); | 537 AdvanceFrame(); |
| 544 // BeginMainFrame is not sent during the defer commit is on. | 538 // BeginMainFrame is not sent during the defer commit is on. |
| 545 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 539 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 546 | 540 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 559 AdvanceFrame(); | 553 AdvanceFrame(); |
| 560 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 554 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 561 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 555 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 562 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 556 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 563 } | 557 } |
| 564 | 558 |
| 565 TEST_F(SchedulerTest, DeferCommitWithRedraw) { | 559 TEST_F(SchedulerTest, DeferCommitWithRedraw) { |
| 566 scheduler_settings_.use_external_begin_frame_source = true; | 560 scheduler_settings_.use_external_begin_frame_source = true; |
| 567 SetUpScheduler(true); | 561 SetUpScheduler(true); |
| 568 | 562 |
| 569 scheduler_->SetCanStart(); | |
| 570 scheduler_->SetVisible(true); | |
| 571 scheduler_->SetCanDraw(true); | |
| 572 | |
| 573 scheduler_->SetDeferCommits(true); | 563 scheduler_->SetDeferCommits(true); |
| 574 | 564 |
| 575 scheduler_->SetNeedsCommit(); | 565 scheduler_->SetNeedsCommit(); |
| 576 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 566 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 577 | 567 |
| 578 client_->Reset(); | 568 client_->Reset(); |
| 579 scheduler_->SetNeedsRedraw(); | 569 scheduler_->SetNeedsRedraw(); |
| 580 EXPECT_NO_ACTION(client_); | 570 EXPECT_NO_ACTION(client_); |
| 581 | 571 |
| 582 client_->Reset(); | 572 client_->Reset(); |
| (...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 2379 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 2390 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2380 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2391 client_->Reset(); | 2381 client_->Reset(); |
| 2392 | 2382 |
| 2393 task_runner().RunPendingTasks(); // Run posted deadline. | 2383 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2394 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); | 2384 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 2395 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2385 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 2396 client_->Reset(); | 2386 client_->Reset(); |
| 2397 } | 2387 } |
| 2398 | 2388 |
| 2389 TEST_F(SchedulerTest, AuthoritativeVSyncInterval) { |
| 2390 SetUpScheduler(true); |
| 2391 |
| 2392 base::TimeDelta initial_interval = |
| 2393 scheduler_->begin_impl_frame_args().interval; |
| 2394 base::TimeDelta authoritative_interval = |
| 2395 base::TimeDelta::FromMilliseconds(33); |
| 2396 |
| 2397 scheduler_->SetNeedsCommit(); |
| 2398 EXPECT_SCOPED(AdvanceFrame()); |
| 2399 |
| 2400 EXPECT_EQ(initial_interval, scheduler_->begin_impl_frame_args().interval); |
| 2401 |
| 2402 scheduler_->NotifyBeginMainFrameStarted(); |
| 2403 scheduler_->NotifyReadyToCommit(); |
| 2404 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 2405 |
| 2406 scheduler_->SetAuthoritativeVSyncInterval(authoritative_interval); |
| 2407 |
| 2408 EXPECT_SCOPED(AdvanceFrame()); |
| 2409 |
| 2410 // At the next BeginFrame, authoritative interval is used instead of previous |
| 2411 // interval. |
| 2412 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); |
| 2413 EXPECT_EQ(authoritative_interval, |
| 2414 scheduler_->begin_impl_frame_args().interval); |
| 2415 } |
| 2416 |
| 2399 } // namespace | 2417 } // namespace |
| 2400 } // namespace cc | 2418 } // namespace cc |
| OLD | NEW |