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

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

Issue 23907006: cc: Allow sending BeginMainFrame before draw or activation (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedDeadline3
Patch Set: Fix smoothness mode Created 6 years, 11 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
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_state_machine.h" 5 #include "cc/scheduler/scheduler_state_machine.h"
6 6
7 #include "cc/scheduler/scheduler.h" 7 #include "cc/scheduler/scheduler.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 #define EXPECT_ACTION_UPDATE_STATE(action) \ 10 #define EXPECT_ACTION_UPDATE_STATE(action) \
11 EXPECT_EQ(action, state.NextAction()) << *state.AsValue(); \ 11 EXPECT_EQ(action, state.NextAction()) << *state.AsValue(); \
12 if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \ 12 if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \
13 action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \ 13 action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \
14 if (SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW == \
15 state.CommitState() && \
16 SchedulerStateMachine::OUTPUT_SURFACE_ACTIVE != \
17 state.output_surface_state()) \
18 return; \
19 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, \ 14 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, \
20 state.begin_impl_frame_state()) \ 15 state.begin_impl_frame_state()) \
21 << *state.AsValue(); \ 16 << *state.AsValue(); \
22 } \ 17 } \
23 state.UpdateState(action); \ 18 state.UpdateState(action); \
24 if (action == SchedulerStateMachine::ACTION_NONE) { \ 19 if (action == SchedulerStateMachine::ACTION_NONE) { \
25 if (state.begin_impl_frame_state() == \ 20 if (state.begin_impl_frame_state() == \
26 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) \ 21 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) \
27 state.OnBeginImplFrameDeadlinePending(); \ 22 state.OnBeginImplFrameDeadlinePending(); \
28 if (state.begin_impl_frame_state() == \ 23 if (state.begin_impl_frame_state() == \
29 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \ 24 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \
30 state.OnBeginImplFrameIdle(); \ 25 state.OnBeginImplFrameIdle(); \
31 } 26 }
32 27
33 namespace cc { 28 namespace cc {
34 29
35 namespace { 30 namespace {
36 31
37 const SchedulerStateMachine::BeginImplFrameState all_begin_impl_frame_states[] = 32 const SchedulerStateMachine::BeginImplFrameState all_begin_impl_frame_states[] =
38 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, 33 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE,
39 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, 34 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING,
40 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME, 35 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME,
41 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, }; 36 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, };
42 37
43 const SchedulerStateMachine::CommitState all_commit_states[] = { 38 const SchedulerStateMachine::CommitState all_commit_states[] = {
44 SchedulerStateMachine::COMMIT_STATE_IDLE, 39 SchedulerStateMachine::COMMIT_STATE_IDLE,
45 SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, 40 SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
46 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 41 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, };
47 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, };
48 42
49 // Exposes the protected state fields of the SchedulerStateMachine for testing 43 // Exposes the protected state fields of the SchedulerStateMachine for testing
50 class StateMachine : public SchedulerStateMachine { 44 class StateMachine : public SchedulerStateMachine {
51 public: 45 public:
52 explicit StateMachine(const SchedulerSettings& scheduler_settings) 46 explicit StateMachine(const SchedulerSettings& scheduler_settings)
53 : SchedulerStateMachine(scheduler_settings) {} 47 : SchedulerStateMachine(scheduler_settings) {}
54 48
55 void CreateAndInitializeOutputSurfaceWithActivatedCommit() { 49 void CreateAndInitializeOutputSurfaceWithActivatedCommit() {
56 DidCreateAndInitializeOutputSurface(); 50 DidCreateAndInitializeOutputSurface();
57 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; 51 output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
(...skipping 17 matching lines...) Expand all
75 OutputSurfaceState output_surface_state() const { 69 OutputSurfaceState output_surface_state() const {
76 return output_surface_state_; 70 return output_surface_state_;
77 } 71 }
78 72
79 bool NeedsCommit() const { return needs_commit_; } 73 bool NeedsCommit() const { return needs_commit_; }
80 74
81 void SetNeedsRedraw(bool b) { needs_redraw_ = b; } 75 void SetNeedsRedraw(bool b) { needs_redraw_ = b; }
82 76
83 void SetNeedsForcedRedrawForTimeout(bool b) { 77 void SetNeedsForcedRedrawForTimeout(bool b) {
84 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; 78 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT;
85 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; 79 active_tree_needs_first_draw_ = true;
86 } 80 }
87 bool NeedsForcedRedrawForTimeout() const { 81 bool NeedsForcedRedrawForTimeout() const {
88 return forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE; 82 return forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE;
89 } 83 }
90 84
91 void SetNeedsForcedRedrawForReadback() { 85 void SetNeedsForcedRedrawForReadback() {
92 readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK; 86 readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK;
93 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; 87 active_tree_needs_first_draw_ = true;
94 } 88 }
95 89
96 bool NeedsForcedRedrawForReadback() const { 90 bool NeedsForcedRedrawForReadback() const {
97 return readback_state_ != READBACK_STATE_IDLE; 91 return readback_state_ != READBACK_STATE_IDLE;
98 } 92 }
99 93
100 void SetActiveTreeNeedsFirstDraw(bool needs_first_draw) { 94 void SetActiveTreeNeedsFirstDraw(bool needs_first_draw) {
101 active_tree_needs_first_draw_ = needs_first_draw; 95 active_tree_needs_first_draw_ = needs_first_draw;
102 } 96 }
103 97
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 275 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
282 EXPECT_TRUE(state.BeginImplFrameNeeded()); 276 EXPECT_TRUE(state.BeginImplFrameNeeded());
283 EXPECT_TRUE(state.RedrawPending()); 277 EXPECT_TRUE(state.RedrawPending());
284 // But the commit is ongoing. 278 // But the commit is ongoing.
285 EXPECT_TRUE(state.CommitPending()); 279 EXPECT_TRUE(state.CommitPending());
286 280
287 // Finish the commit. Note, we should not yet be forcing a draw, but should 281 // Finish the commit. Note, we should not yet be forcing a draw, but should
288 // continue the commit as usual. 282 // continue the commit as usual.
289 state.FinishCommit(); 283 state.FinishCommit();
290 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 284 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
285 if (!deadline_scheduling_enabled) {
286 EXPECT_ACTION_UPDATE_STATE(
287 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
288 }
291 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 289 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
292 EXPECT_TRUE(state.RedrawPending()); 290 EXPECT_TRUE(state.RedrawPending());
293 291
294 // The redraw should be forced at the end of the next BeginImplFrame. 292 // The redraw should be forced at the end of the next BeginImplFrame.
295 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); 293 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting());
294 if (deadline_scheduling_enabled) {
295 EXPECT_ACTION_UPDATE_STATE(
296 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
297 }
296 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 298 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
297 state.OnBeginImplFrameDeadline(); 299 state.OnBeginImplFrameDeadline();
298 EXPECT_ACTION_UPDATE_STATE( 300 EXPECT_ACTION_UPDATE_STATE(
299 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED); 301 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED);
300 } 302 }
301 303
302 TEST(SchedulerStateMachineTest, 304 TEST(SchedulerStateMachineTest,
303 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit) { 305 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit) {
304 bool deadline_scheduling_enabled = false; 306 bool deadline_scheduling_enabled = false;
305 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit( 307 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit(
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 state.NextAction()); 507 state.NextAction());
506 508
507 // Case 2: needs_commit=true 509 // Case 2: needs_commit=true
508 state.SetNeedsCommit(); 510 state.SetNeedsCommit();
509 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 511 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
510 state.NextAction()) 512 state.NextAction())
511 << *state.AsValue(); 513 << *state.AsValue();
512 } 514 }
513 } 515 }
514 516
515 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw or 517 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw
516 // SetNeedsForcedRedrawForReadback have been called... except if we're 518 // except if we're ready to commit, in which case we expect a commit first.
517 // ready to commit, in which case we expect a commit first. 519 // SetNeedsForcedRedrawForReadback should take precedence over all and
520 // issue a readback.
518 for (size_t i = 0; i < num_commit_states; ++i) { 521 for (size_t i = 0; i < num_commit_states; ++i) {
519 for (size_t j = 0; j < 2; ++j) { 522 for (size_t j = 0; j < 2; ++j) {
520 bool request_readback = j; 523 bool request_readback = j;
521 524
522 // Skip invalid states
523 if (request_readback &&
524 (SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW !=
525 all_commit_states[i]))
526 continue;
527
528 StateMachine state(default_scheduler_settings); 525 StateMachine state(default_scheduler_settings);
529 state.SetCanStart(); 526 state.SetCanStart();
530 state.UpdateState(state.NextAction()); 527 state.UpdateState(state.NextAction());
531 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 528 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
532 state.SetCanDraw(true); 529 state.SetCanDraw(true);
533 state.SetCommitState(all_commit_states[i]); 530 state.SetCommitState(all_commit_states[i]);
534 state.SetBeginImplFrameState( 531 state.SetBeginImplFrameState(
535 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 532 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
536 if (request_readback) { 533 if (request_readback) {
537 state.SetNeedsForcedRedrawForReadback(); 534 state.SetNeedsForcedRedrawForReadback();
538 } else { 535 } else {
539 state.SetNeedsRedraw(true); 536 state.SetNeedsRedraw(true);
540 state.SetVisible(true); 537 state.SetVisible(true);
541 } 538 }
542 539
543 SchedulerStateMachine::Action expected_action; 540 SchedulerStateMachine::Action expected_action;
544 if (all_commit_states[i] == 541 if (request_readback) {
545 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) { 542 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_READBACK;
543 } else if (all_commit_states[i] ==
544 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) {
546 expected_action = SchedulerStateMachine::ACTION_COMMIT; 545 expected_action = SchedulerStateMachine::ACTION_COMMIT;
547 } else if (request_readback) {
548 if (all_commit_states[i] ==
549 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW)
550 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_READBACK;
551 else
552 expected_action = SchedulerStateMachine::ACTION_NONE;
553 } else { 546 } else {
554 expected_action = 547 expected_action =
555 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE; 548 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE;
556 } 549 }
557 550
558 // Case 1: needs_commit=false. 551 // Case 1: needs_commit=false.
559 EXPECT_NE(state.BeginImplFrameNeeded(), request_readback) 552 EXPECT_NE(state.BeginImplFrameNeeded(), request_readback)
560 << *state.AsValue(); 553 << *state.AsValue();
561 EXPECT_EQ(expected_action, state.NextAction()) << *state.AsValue(); 554 EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
562 555
563 // Case 2: needs_commit=true. 556 // Case 2: needs_commit=true.
564 state.SetNeedsCommit(); 557 state.SetNeedsCommit();
565 EXPECT_NE(state.BeginImplFrameNeeded(), request_readback) 558 EXPECT_NE(state.BeginImplFrameNeeded(), request_readback)
566 << *state.AsValue(); 559 << *state.AsValue();
567 EXPECT_EQ(expected_action, state.NextAction()) << *state.AsValue(); 560 EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
568 } 561 }
569 } 562 }
570 } 563 }
571 564
572 TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) { 565 TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) {
573 SchedulerSettings default_scheduler_settings; 566 SchedulerSettings default_scheduler_settings;
574 567
575 size_t num_commit_states = 568 size_t num_commit_states =
576 sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState); 569 sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState);
577 for (size_t i = 0; i < num_commit_states; ++i) { 570 for (size_t i = 0; i < num_commit_states; ++i) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 } 621 }
629 622
630 TEST(SchedulerStateMachineTest, 623 TEST(SchedulerStateMachineTest,
631 TestCanRedrawWithWaitingForFirstDrawMakesProgress) { 624 TestCanRedrawWithWaitingForFirstDrawMakesProgress) {
632 SchedulerSettings default_scheduler_settings; 625 SchedulerSettings default_scheduler_settings;
633 StateMachine state(default_scheduler_settings); 626 StateMachine state(default_scheduler_settings);
634 state.SetCanStart(); 627 state.SetCanStart();
635 state.UpdateState(state.NextAction()); 628 state.UpdateState(state.NextAction());
636 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 629 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
637 630
638 state.SetCommitState(
639 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
640 state.SetActiveTreeNeedsFirstDraw(true); 631 state.SetActiveTreeNeedsFirstDraw(true);
641 state.SetNeedsCommit(); 632 state.SetNeedsCommit();
642 state.SetNeedsRedraw(true); 633 state.SetNeedsRedraw(true);
643 state.SetVisible(true); 634 state.SetVisible(true);
644 state.SetCanDraw(false); 635 state.SetCanDraw(false);
645 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); 636 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting());
646 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 637 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
647 EXPECT_ACTION_UPDATE_STATE( 638 EXPECT_ACTION_UPDATE_STATE(
648 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 639 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
649 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 640 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 state.OnBeginImplFrameIdle(); 691 state.OnBeginImplFrameIdle();
701 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, 692 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE,
702 state.begin_impl_frame_state()); 693 state.begin_impl_frame_state());
703 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); 694 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
704 695
705 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); 696 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting());
706 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, 697 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING,
707 state.begin_impl_frame_state()); 698 state.begin_impl_frame_state());
708 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); 699 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
709 700
710 // Commit and make sure we draw on next BeginImplFrame 701 // Finish the commit, then make sure we start the next commit immediately
702 // and draw on the next BeginImplFrame.
711 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 703 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
712 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
713 state.OnBeginImplFrameDeadline();
714 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW,
715 state.CommitState());
716 EXPECT_ACTION_UPDATE_STATE(
717 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
718 state.DidDrawIfPossibleCompleted(true);
719
720 // Verify that another commit will start immediately after draw.
721 EXPECT_ACTION_UPDATE_STATE( 704 EXPECT_ACTION_UPDATE_STATE(
722 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 705 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
723 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 706 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
707
708 state.OnBeginImplFrameDeadline();
709
710 EXPECT_TRUE(state.active_tree_needs_first_draw());
711 EXPECT_ACTION_UPDATE_STATE(
712 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
713 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
714 state.DidDrawIfPossibleCompleted(true);
724 } 715 }
725 716
726 TEST(SchedulerStateMachineTest, TestFullCycle) { 717 TEST(SchedulerStateMachineTest, TestFullCycle) {
727 SchedulerSettings default_scheduler_settings; 718 SchedulerSettings default_scheduler_settings;
728 StateMachine state(default_scheduler_settings); 719 StateMachine state(default_scheduler_settings);
729 state.SetCanStart(); 720 state.SetCanStart();
730 state.UpdateState(state.NextAction()); 721 state.UpdateState(state.NextAction());
731 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 722 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
732 state.SetVisible(true); 723 state.SetVisible(true);
733 state.SetCanDraw(true); 724 state.SetCanDraw(true);
(...skipping 10 matching lines...) Expand all
744 EXPECT_FALSE(state.NeedsCommit()); 735 EXPECT_FALSE(state.NeedsCommit());
745 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 736 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
746 737
747 // Tell the scheduler the frame finished. 738 // Tell the scheduler the frame finished.
748 state.FinishCommit(); 739 state.FinishCommit();
749 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 740 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
750 state.CommitState()); 741 state.CommitState());
751 742
752 // Commit. 743 // Commit.
753 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 744 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
754 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 745 EXPECT_TRUE(state.active_tree_needs_first_draw());
755 state.CommitState());
756 EXPECT_TRUE(state.needs_redraw()); 746 EXPECT_TRUE(state.needs_redraw());
757 747
758 // Expect to do nothing until BeginImplFrame deadline 748 // Expect to do nothing until BeginImplFrame deadline
759 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 749 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
760 750
761 // At BeginImplFrame deadline, draw. 751 // At BeginImplFrame deadline, draw.
762 state.OnBeginImplFrameDeadline(); 752 state.OnBeginImplFrameDeadline();
763 EXPECT_ACTION_UPDATE_STATE( 753 EXPECT_ACTION_UPDATE_STATE(
764 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 754 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
765 state.DidDrawIfPossibleCompleted(true); 755 state.DidDrawIfPossibleCompleted(true);
(...skipping 29 matching lines...) Expand all
795 state.SetNeedsCommit(); 785 state.SetNeedsCommit();
796 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 786 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
797 787
798 // Tell the scheduler the frame finished. 788 // Tell the scheduler the frame finished.
799 state.FinishCommit(); 789 state.FinishCommit();
800 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 790 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
801 state.CommitState()); 791 state.CommitState());
802 792
803 // First commit. 793 // First commit.
804 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 794 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
805 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 795 EXPECT_TRUE(state.active_tree_needs_first_draw());
806 state.CommitState());
807 EXPECT_TRUE(state.needs_redraw()); 796 EXPECT_TRUE(state.needs_redraw());
808 797
809 // Expect to do nothing until BeginImplFrame deadline. 798 // Expect to do nothing until BeginImplFrame deadline.
810 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 799 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
811 800
812 // At BeginImplFrame deadline, draw. 801 // At BeginImplFrame deadline, draw.
813 state.OnBeginImplFrameDeadline(); 802 state.OnBeginImplFrameDeadline();
814 EXPECT_ACTION_UPDATE_STATE( 803 EXPECT_ACTION_UPDATE_STATE(
815 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 804 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
816 state.DidDrawIfPossibleCompleted(true); 805 state.DidDrawIfPossibleCompleted(true);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 // Ask for another draw. Expect nothing happens. 1079 // Ask for another draw. Expect nothing happens.
1091 state.SetNeedsRedraw(true); 1080 state.SetNeedsRedraw(true);
1092 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); 1081 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
1093 1082
1094 // Finish the frame, and commit. 1083 // Finish the frame, and commit.
1095 state.FinishCommit(); 1084 state.FinishCommit();
1096 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1085 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1097 1086
1098 // We will abort the draw when the output surface is lost if we are 1087 // We will abort the draw when the output surface is lost if we are
1099 // waiting for the first draw to unblock the main thread. 1088 // waiting for the first draw to unblock the main thread.
1100 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1089 EXPECT_TRUE(state.active_tree_needs_first_draw());
1101 state.CommitState());
1102 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1090 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1103 1091
1104 // Expect to be told to begin context recreation, independent of 1092 // Expect to be told to begin context recreation, independent of
1105 // BeginImplFrame state. 1093 // BeginImplFrame state.
1106 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, 1094 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE,
1107 state.begin_impl_frame_state()); 1095 state.begin_impl_frame_state());
1108 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 1096 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
1109 state.NextAction()); 1097 state.NextAction());
1110 1098
1111 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); 1099 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 state.DidLoseOutputSurface(); 1161 state.DidLoseOutputSurface();
1174 1162
1175 // Ask for another draw and also set needs commit. Expect nothing happens. 1163 // Ask for another draw and also set needs commit. Expect nothing happens.
1176 state.SetNeedsRedraw(true); 1164 state.SetNeedsRedraw(true);
1177 state.SetNeedsCommit(); 1165 state.SetNeedsCommit();
1178 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1166 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1179 1167
1180 // Finish the frame, and commit. 1168 // Finish the frame, and commit.
1181 state.FinishCommit(); 1169 state.FinishCommit();
1182 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1170 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1183 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1171 EXPECT_TRUE(state.active_tree_needs_first_draw());
1184 state.CommitState());
1185 1172
1186 // Because the output surface is missing, we expect the draw to abort. 1173 // Because the output surface is missing, we expect the draw to abort.
1187 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1174 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1188 1175
1189 // Expect to be told to begin context recreation, independent of 1176 // Expect to be told to begin context recreation, independent of
1190 // BeginImplFrame state 1177 // BeginImplFrame state
1191 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, 1178 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE,
1192 state.begin_impl_frame_state()); 1179 state.begin_impl_frame_state());
1193 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 1180 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
1194 state.NextAction()); 1181 state.NextAction());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 state.SetCanStart(); 1236 state.SetCanStart();
1250 state.UpdateState(state.NextAction()); 1237 state.UpdateState(state.NextAction());
1251 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1238 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1252 state.SetVisible(true); 1239 state.SetVisible(true);
1253 state.SetCanDraw(true); 1240 state.SetCanDraw(true);
1254 1241
1255 // Cause a lost context lost. 1242 // Cause a lost context lost.
1256 state.DidLoseOutputSurface(); 1243 state.DidLoseOutputSurface();
1257 1244
1258 // Ask a forced redraw for readback and verify it ocurrs. 1245 // Ask a forced redraw for readback and verify it ocurrs.
1259 state.SetCommitState(
1260 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
1261 state.SetNeedsForcedRedrawForReadback(); 1246 state.SetNeedsForcedRedrawForReadback();
1262 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); 1247 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting());
1263 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); 1248 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
1264 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1249 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1265 1250
1266 // Forced redraws for readbacks need to be followed by a new commit 1251 // Forced redraws for readbacks need to be followed by a new commit
1267 // to replace the readback commit. 1252 // to replace the readback commit.
1268 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, 1253 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
1269 state.CommitState()); 1254 state.CommitState());
1270 state.FinishCommit(); 1255 state.FinishCommit();
1271 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1256 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1272 1257
1273 // We don't yet have an output surface, so we the draw and swap should abort. 1258 // We don't yet have an output surface, so we the draw and swap should abort.
1274 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1259 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1275 1260
1276 // Expect to be told to begin context recreation, independent of 1261 // Expect to be told to begin context recreation, independent of
1277 // BeginImplFrame state 1262 // BeginImplFrame state
1278 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); 1263 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
1279 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 1264 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
1280 state.NextAction()); 1265 state.NextAction());
1281 1266
1282 state.OnBeginImplFrameDeadline(); 1267 state.OnBeginImplFrameDeadline();
1283 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 1268 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
1284 state.NextAction()); 1269 state.NextAction());
1285 1270
1286 // Ask a readback and verify it occurs. 1271 // Ask a readback and verify it occurs.
1287 state.SetCommitState(
1288 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
1289 state.SetNeedsForcedRedrawForReadback(); 1272 state.SetNeedsForcedRedrawForReadback();
1290 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); 1273 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
1291 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1274 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1292 } 1275 }
1293 1276
1294 TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) { 1277 TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) {
1295 SchedulerSettings default_scheduler_settings; 1278 SchedulerSettings default_scheduler_settings;
1296 StateMachine state(default_scheduler_settings); 1279 StateMachine state(default_scheduler_settings);
1297 state.SetCanStart(); 1280 state.SetCanStart();
1298 state.UpdateState(state.NextAction()); 1281 state.UpdateState(state.NextAction());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 state.UpdateState(state.NextAction()); 1331 state.UpdateState(state.NextAction());
1349 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1332 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1350 state.SetVisible(false); 1333 state.SetVisible(false);
1351 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS); 1334 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS);
1352 state.SetNeedsCommit(); 1335 state.SetNeedsCommit();
1353 1336
1354 state.FinishCommit(); 1337 state.FinishCommit();
1355 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); 1338 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
1356 state.UpdateState(state.NextAction()); 1339 state.UpdateState(state.NextAction());
1357 1340
1358 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1341 EXPECT_TRUE(state.active_tree_needs_first_draw());
1359 state.CommitState());
1360 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1342 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1361 } 1343 }
1362 1344
1363 TEST(SchedulerStateMachineTest, TestFinishCommitWhenForcedCommitInProgress) { 1345 TEST(SchedulerStateMachineTest, TestFinishCommitWhenForcedCommitInProgress) {
1364 SchedulerSettings default_scheduler_settings; 1346 SchedulerSettings default_scheduler_settings;
1365 StateMachine state(default_scheduler_settings); 1347 StateMachine state(default_scheduler_settings);
1366 state.SetCanStart(); 1348 state.SetCanStart();
1367 state.UpdateState(state.NextAction()); 1349 state.UpdateState(state.NextAction());
1368 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1350 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1369 state.SetVisible(false); 1351 state.SetVisible(false);
1370 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS); 1352 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS);
1371 state.SetNeedsCommit(); 1353 state.SetNeedsCommit();
1372 state.SetNeedsForcedCommitForReadback(); 1354 state.SetNeedsForcedCommitForReadback();
1373 1355
1374 // The commit for readback interupts the normal commit. 1356 // The commit for readback interupts the normal commit.
1375 state.FinishCommit(); 1357 state.FinishCommit();
1376 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1358 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1377 1359
1378 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1360 EXPECT_TRUE(state.active_tree_needs_first_draw());
1379 state.CommitState());
1380 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); 1361 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
1381 1362
1382 // When the readback interrupts the normal commit, we should not get 1363 // When the readback interrupts the normal commit, we should not get
1383 // another BeginMainFrame when the readback completes. 1364 // another BeginMainFrame when the readback completes.
1384 EXPECT_NE(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME, 1365 EXPECT_NE(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME,
1385 state.NextAction()); 1366 state.NextAction());
1386 1367
1387 // The normal commit can then proceed. 1368 // The normal commit can then proceed.
1388 state.FinishCommit(); 1369 state.FinishCommit();
1389 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1370 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 state.SetNeedsCommit(); 1419 state.SetNeedsCommit();
1439 state.SetNeedsForcedCommitForReadback(); 1420 state.SetNeedsForcedCommitForReadback();
1440 EXPECT_ACTION_UPDATE_STATE( 1421 EXPECT_ACTION_UPDATE_STATE(
1441 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1422 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1442 state.FinishCommit(); 1423 state.FinishCommit();
1443 1424
1444 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 1425 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
1445 state.CommitState()); 1426 state.CommitState());
1446 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1427 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1447 1428
1448 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1429 EXPECT_TRUE(state.active_tree_needs_first_draw());
1449 state.CommitState());
1450 1430
1451 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); 1431 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
1452 state.DidDrawIfPossibleCompleted(true); 1432 state.DidDrawIfPossibleCompleted(true);
1453 1433
1454 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1434 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1455 1435
1456 // Should be waiting for the normal BeginMainFrame. 1436 // Should be waiting for the normal BeginMainFrame.
1457 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, 1437 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
1458 state.CommitState()); 1438 state.CommitState());
1459 } 1439 }
(...skipping 21 matching lines...) Expand all
1481 if (deadline_scheduling_enabled) { 1461 if (deadline_scheduling_enabled) {
1482 EXPECT_ACTION_UPDATE_STATE( 1462 EXPECT_ACTION_UPDATE_STATE(
1483 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1463 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1484 } 1464 }
1485 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1465 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1486 state.FinishCommit(); 1466 state.FinishCommit();
1487 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 1467 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
1488 state.CommitState()); 1468 state.CommitState());
1489 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1469 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1490 1470
1491 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1471 EXPECT_TRUE(state.active_tree_needs_first_draw());
1492 state.CommitState());
1493 1472
1494 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); 1473 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
1495 state.DidDrawIfPossibleCompleted(true); 1474 state.DidDrawIfPossibleCompleted(true);
1496 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1475 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1497 1476
1498 // Should be waiting for the normal BeginMainFrame. 1477 // Should be waiting for the normal BeginMainFrame.
1499 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, 1478 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
1500 state.CommitState()) 1479 state.CommitState())
1501 << *state.AsValue(); 1480 << *state.AsValue();
1502 } 1481 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 if (deadline_scheduling_enabled) { 1514 if (deadline_scheduling_enabled) {
1536 EXPECT_ACTION_UPDATE_STATE( 1515 EXPECT_ACTION_UPDATE_STATE(
1537 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1516 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1538 } 1517 }
1539 state.FinishCommit(); 1518 state.FinishCommit();
1540 1519
1541 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 1520 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
1542 state.CommitState()); 1521 state.CommitState());
1543 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1522 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1544 1523
1545 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1524 EXPECT_TRUE(state.active_tree_needs_first_draw());
1546 state.CommitState());
1547 1525
1548 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); 1526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
1549 state.DidDrawIfPossibleCompleted(true); 1527 state.DidDrawIfPossibleCompleted(true);
1550 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1528 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1551 1529
1552 // Should be waiting for BeginMainFrame. 1530 // Should be waiting for BeginMainFrame.
1553 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, 1531 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
1554 state.CommitState()) 1532 state.CommitState())
1555 << *state.AsValue(); 1533 << *state.AsValue();
1556 1534
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 1569
1592 state.SetNeedsCommit(); 1570 state.SetNeedsCommit();
1593 state.SetNeedsForcedCommitForReadback(); 1571 state.SetNeedsForcedCommitForReadback();
1594 state.UpdateState(state.NextAction()); 1572 state.UpdateState(state.NextAction());
1595 state.FinishCommit(); 1573 state.FinishCommit();
1596 1574
1597 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 1575 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
1598 state.CommitState()); 1576 state.CommitState());
1599 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1577 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1600 1578
1601 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 1579 EXPECT_TRUE(state.active_tree_needs_first_draw());
1602 state.CommitState());
1603 1580
1604 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); 1581 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
1605 state.DidDrawIfPossibleCompleted(true); 1582 state.DidDrawIfPossibleCompleted(true);
1606 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1583 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1607 } 1584 }
1608 1585
1609 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { 1586 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) {
1610 SchedulerSettings default_scheduler_settings; 1587 SchedulerSettings default_scheduler_settings;
1611 StateMachine state(default_scheduler_settings); 1588 StateMachine state(default_scheduler_settings);
1612 state.SetCanStart(); 1589 state.SetCanStart();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1733 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1757 1734
1758 // The deadline is not triggered early until we enter prefer smoothness mode. 1735 // The deadline is not triggered early until we enter prefer smoothness mode.
1759 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); 1736 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly());
1760 state.SetSmoothnessTakesPriority(true); 1737 state.SetSmoothnessTakesPriority(true);
1761 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); 1738 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly());
1762 } 1739 }
1763 1740
1764 } // namespace 1741 } // namespace
1765 } // namespace cc 1742 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698