Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 2828873006: Revert of Revert "cc: Make scheduler run incoming frame after previous deadline." (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // called inside EXPECT_SCOPED like so; 390 // called inside EXPECT_SCOPED like so;
391 // EXPECT_SCOPED(client.AdvanceFrame()); 391 // EXPECT_SCOPED(client.AdvanceFrame());
392 void AdvanceFrame() { 392 void AdvanceFrame() {
393 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 393 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
394 "FakeSchedulerClient::AdvanceFrame"); 394 "FakeSchedulerClient::AdvanceFrame");
395 395
396 // Send the next BeginFrame message if using an external source, otherwise 396 // Send the next BeginFrame message if using an external source, otherwise
397 // it will be already in the task queue. 397 // it will be already in the task queue.
398 if (scheduler_->begin_frame_source() == 398 if (scheduler_->begin_frame_source() ==
399 fake_external_begin_frame_source_.get()) { 399 fake_external_begin_frame_source_.get()) {
400 // Run pending task for previous deadline first.
401 task_runner_->RunPendingTasks();
400 EXPECT_TRUE(scheduler_->begin_frames_expected()); 402 EXPECT_TRUE(scheduler_->begin_frames_expected());
401 SendNextBeginFrame(); 403 SendNextBeginFrame();
402 } else { 404 } else {
405 // Begin frame might be queued up and posted after the previous deadline
406 // runs so run tasks until we get to the next frame.
403 task_runner_->RunTasksWhile(client_->FrameHasNotAdvancedCallback()); 407 task_runner_->RunTasksWhile(client_->FrameHasNotAdvancedCallback());
404 } 408 }
405 } 409 }
406 410
407 BeginFrameArgs SendNextBeginFrame() { 411 BeginFrameArgs SendNextBeginFrame() {
408 DCHECK_EQ(scheduler_->begin_frame_source(), 412 DCHECK_EQ(scheduler_->begin_frame_source(),
409 fake_external_begin_frame_source_.get()); 413 fake_external_begin_frame_source_.get());
410 // Creep the time forward so that any BeginFrameArgs is not equal to the 414 // Creep the time forward so that any BeginFrameArgs is not equal to the
411 // last one otherwise we violate the BeginFrameSource contract. 415 // last one otherwise we violate the BeginFrameSource contract.
412 now_src_->Advance(BeginFrameArgs::DefaultInterval()); 416 now_src_->Advance(BeginFrameArgs::DefaultInterval());
(...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 client_->Reset(); 3507 client_->Reset();
3504 3508
3505 SendNextBeginFrame(); 3509 SendNextBeginFrame();
3506 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 3510 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
3507 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 3511 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
3508 // Until tiles were prepared, further proactive BeginFrames are expected. 3512 // Until tiles were prepared, further proactive BeginFrames are expected.
3509 EXPECT_TRUE(scheduler_->begin_frames_expected()); 3513 EXPECT_TRUE(scheduler_->begin_frames_expected());
3510 client_->Reset(); 3514 client_->Reset();
3511 3515
3512 // Send the next BeginFrame before the previous one's deadline was executed. 3516 // Send the next BeginFrame before the previous one's deadline was executed.
3513 // This should trigger the previous BeginFrame's deadline synchronously, 3517 // This will wait for the previous deadline after which no further BeginFrames
3514 // during which tiles will be prepared. As a result of that, no further 3518 // will be needed, and the new BeginFrame should be dropped.
3515 // BeginFrames will be needed, and the new BeginFrame should be dropped.
3516 BeginFrameArgs args = SendNextBeginFrame(); 3519 BeginFrameArgs args = SendNextBeginFrame();
3520
3521 task_runner().RunPendingTasks(); // Run posted deadline.
3517 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 3); 3522 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 3);
3518 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3523 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3519 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3524 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3520 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3525 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3521 EXPECT_FALSE(scheduler_->begin_frames_expected()); 3526 EXPECT_FALSE(scheduler_->begin_frames_expected());
3522 client_->Reset(); 3527 client_->Reset();
3523 3528
3524 // Latest ack should be for the dropped BeginFrame. Since we don't have 3529 // Latest ack should be for the dropped BeginFrame. Since we don't have
3525 // further updates, its |latest_confirmed_sequence_number| should be for the 3530 // further updates, its |latest_confirmed_sequence_number| should be for the
3526 // dropped BeginFrame, too. 3531 // dropped BeginFrame, too.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3673 // |latest_confirmed_sequence_number| should be set to invalid. 3678 // |latest_confirmed_sequence_number| should be set to invalid.
3674 uint64_t latest_confirmed_sequence_number = 3679 uint64_t latest_confirmed_sequence_number =
3675 BeginFrameArgs::kInvalidFrameNumber; 3680 BeginFrameArgs::kInvalidFrameNumber;
3676 bool has_damage = false; 3681 bool has_damage = false;
3677 EXPECT_EQ( 3682 EXPECT_EQ(
3678 BeginFrameAck(args.source_id, args.sequence_number, 3683 BeginFrameAck(args.source_id, args.sequence_number,
3679 latest_confirmed_sequence_number, has_damage), 3684 latest_confirmed_sequence_number, has_damage),
3680 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); 3685 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get()));
3681 } 3686 }
3682 3687
3688 TEST_F(SchedulerTest, BeginFrameWhilePreviousDeadlinePending) {
3689 SetUpScheduler(EXTERNAL_BFS);
3690
3691 scheduler_->SetNeedsRedraw();
3692
3693 client_->Reset();
3694 EXPECT_SCOPED(AdvanceFrame());
3695 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
3696
3697 // Do not run pending deadline but send a new begin frame. The begin frame is
3698 // saved and run when the previous frame is over.
3699 client_->Reset();
3700 SendNextBeginFrame();
3701 EXPECT_NO_ACTION(client_);
3702
3703 task_runner_->RunPendingTasks();
3704 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_);
3705
3706 // The saved begin frame is posted as a task.
3707 client_->Reset();
3708 task_runner_->RunPendingTasks();
3709 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
3710 }
3711
3712 TEST_F(SchedulerTest, IncomingBeginFrameReplacesSavedBeginFrame) {
3713 SetUpScheduler(EXTERNAL_BFS);
3714
3715 scheduler_->SetNeedsRedraw();
3716
3717 client_->Reset();
3718 EXPECT_SCOPED(AdvanceFrame());
3719 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
3720
3721 // Send two BeginFrames while deadline is pending.
3722 client_->Reset();
3723 SendNextBeginFrame();
3724 EXPECT_NO_ACTION(client_);
3725
3726 SendNextBeginFrame();
3727 EXPECT_NO_ACTION(client_);
3728
3729 task_runner_->RunPendingTasks();
3730 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_);
3731
3732 // Only the last BeginFrame runs.
3733 client_->Reset();
3734 task_runner_->RunPendingTasks();
3735 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
3736
3737 client_->Reset();
3738 task_runner_->RunPendingTasks();
3739 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
3740 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
3741 }
3742
3683 } // namespace 3743 } // namespace
3684 } // namespace cc 3744 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698