Chromium Code Reviews| 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_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_FRAME_STATE_INSIDE_DEADLINE, \ | 14 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_DEADLINE, \ |
| 20 state.begin_frame_state()) \ | 15 state.begin_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 state.AdvanceBeginFrameStateWhenNoActionsRemain(); \ | 20 state.AdvanceBeginFrameStateWhenNoActionsRemain(); \ |
| 26 } | 21 } |
| 27 | 22 |
| 28 namespace cc { | 23 namespace cc { |
| 29 | 24 |
| 30 namespace { | 25 namespace { |
| 31 | 26 |
| 32 const SchedulerStateMachine::BeginFrameState all_begin_frame_states[] = { | 27 const SchedulerStateMachine::BeginFrameState all_begin_frame_states[] = { |
| 33 SchedulerStateMachine::BEGIN_FRAME_STATE_IDLE, | 28 SchedulerStateMachine::BEGIN_FRAME_STATE_IDLE, |
| 34 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME, | 29 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME, |
| 35 SchedulerStateMachine::BEGIN_FRAME_STATE_DEADLINE_PENDING, | 30 SchedulerStateMachine::BEGIN_FRAME_STATE_DEADLINE_PENDING, |
| 36 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_DEADLINE, }; | 31 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_DEADLINE, }; |
| 37 | 32 |
| 38 const SchedulerStateMachine::CommitState all_commit_states[] = { | 33 const SchedulerStateMachine::CommitState all_commit_states[] = { |
| 39 SchedulerStateMachine::COMMIT_STATE_IDLE, | 34 SchedulerStateMachine::COMMIT_STATE_IDLE, |
| 40 SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 35 SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| 41 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 36 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, }; |
| 42 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, }; | |
| 43 | 37 |
| 44 // Exposes the protected state fields of the SchedulerStateMachine for testing | 38 // Exposes the protected state fields of the SchedulerStateMachine for testing |
| 45 class StateMachine : public SchedulerStateMachine { | 39 class StateMachine : public SchedulerStateMachine { |
| 46 public: | 40 public: |
| 47 explicit StateMachine(const SchedulerSettings& scheduler_settings) | 41 explicit StateMachine(const SchedulerSettings& scheduler_settings) |
| 48 : SchedulerStateMachine(scheduler_settings) {} | 42 : SchedulerStateMachine(scheduler_settings) {} |
| 49 | 43 |
| 50 void CreateAndInitializeOutputSurfaceWithActivatedCommit() { | 44 void CreateAndInitializeOutputSurfaceWithActivatedCommit() { |
| 51 DidCreateAndInitializeOutputSurface(); | 45 DidCreateAndInitializeOutputSurface(); |
| 52 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | 46 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 67 return output_surface_state_; | 61 return output_surface_state_; |
| 68 } | 62 } |
| 69 | 63 |
| 70 bool NeedsCommit() const { return needs_commit_; } | 64 bool NeedsCommit() const { return needs_commit_; } |
| 71 | 65 |
| 72 void SetNeedsRedraw(bool b) { needs_redraw_ = b; } | 66 void SetNeedsRedraw(bool b) { needs_redraw_ = b; } |
| 73 bool NeedsRedraw() const { return needs_redraw_; } | 67 bool NeedsRedraw() const { return needs_redraw_; } |
| 74 | 68 |
| 75 void SetNeedsForcedRedrawForTimeout(bool b) { | 69 void SetNeedsForcedRedrawForTimeout(bool b) { |
| 76 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; | 70 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; |
| 77 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | 71 active_tree_needs_first_draw_ = true; |
|
danakj
2013/09/17 17:05:07
Can you explain these? I don't see that the state
brianderson
2013/10/03 14:44:38
You are right. I shouldn't be setting active_tree_
| |
| 78 } | 72 } |
| 79 bool NeedsForcedRedrawForTimeout() const { | 73 bool NeedsForcedRedrawForTimeout() const { |
| 80 return forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE; | 74 return forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE; |
| 81 } | 75 } |
| 82 | 76 |
| 83 void SetNeedsForcedRedrawForReadback() { | 77 void SetNeedsForcedRedrawForReadback() { |
| 84 readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK; | 78 readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK; |
| 85 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | 79 active_tree_needs_first_draw_ = true; |
| 86 } | 80 } |
| 87 | 81 |
| 88 bool NeedsForcedRedrawForReadback() const { | 82 bool NeedsForcedRedrawForReadback() const { |
| 89 return readback_state_ != READBACK_STATE_IDLE; | 83 return readback_state_ != READBACK_STATE_IDLE; |
| 90 } | 84 } |
| 91 | 85 |
| 92 void SetActiveTreeNeedsFirstDraw(bool needs_first_draw) { | 86 void SetActiveTreeNeedsFirstDraw(bool needs_first_draw) { |
| 93 active_tree_needs_first_draw_ = needs_first_draw; | 87 active_tree_needs_first_draw_ = needs_first_draw; |
| 94 } | 88 } |
| 95 | 89 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 } | 394 } |
| 401 } | 395 } |
| 402 | 396 |
| 403 // When in BeginFrame deadline we should always draw for SetNeedsRedraw or | 397 // When in BeginFrame deadline we should always draw for SetNeedsRedraw or |
| 404 // SetNeedsForcedRedrawForReadback have been called... except if we're | 398 // SetNeedsForcedRedrawForReadback have been called... except if we're |
| 405 // ready to commit, in which case we expect a commit first. | 399 // ready to commit, in which case we expect a commit first. |
| 406 for (size_t i = 0; i < num_commit_states; ++i) { | 400 for (size_t i = 0; i < num_commit_states; ++i) { |
| 407 for (size_t j = 0; j < 2; ++j) { | 401 for (size_t j = 0; j < 2; ++j) { |
| 408 bool request_readback = j; | 402 bool request_readback = j; |
| 409 | 403 |
| 410 // Skip invalid states | |
| 411 if (request_readback && | |
| 412 (SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW != | |
| 413 all_commit_states[i])) | |
| 414 continue; | |
| 415 | |
| 416 StateMachine state(default_scheduler_settings); | 404 StateMachine state(default_scheduler_settings); |
| 417 state.SetCanStart(); | 405 state.SetCanStart(); |
| 418 state.UpdateState(state.NextAction()); | 406 state.UpdateState(state.NextAction()); |
| 419 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 407 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 420 state.SetCanDraw(true); | 408 state.SetCanDraw(true); |
| 421 state.SetCommitState(all_commit_states[i]); | 409 state.SetCommitState(all_commit_states[i]); |
| 422 state.SetBeginFrameState( | 410 state.SetBeginFrameState( |
| 423 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_DEADLINE); | 411 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_DEADLINE); |
| 424 if (request_readback) { | 412 if (request_readback) { |
| 425 state.SetNeedsForcedRedrawForReadback(); | 413 state.SetNeedsForcedRedrawForReadback(); |
| 426 } else { | 414 } else { |
| 427 state.SetNeedsRedraw(true); | 415 state.SetNeedsRedraw(true); |
| 428 state.SetVisible(true); | 416 state.SetVisible(true); |
| 429 } | 417 } |
| 430 | 418 |
| 431 SchedulerStateMachine::Action expected_action; | 419 SchedulerStateMachine::Action expected_action; |
| 432 if (all_commit_states[i] == | 420 if (all_commit_states[i] == |
| 433 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) { | 421 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) { |
| 434 expected_action = SchedulerStateMachine::ACTION_COMMIT; | 422 expected_action = SchedulerStateMachine::ACTION_COMMIT; |
| 435 } else if (request_readback) { | 423 } else if (request_readback) { |
| 436 if (all_commit_states[i] == | 424 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_READBACK; |
| 437 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW) | |
| 438 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_READBACK; | |
| 439 else | |
| 440 expected_action = SchedulerStateMachine::ACTION_NONE; | |
| 441 } else { | 425 } else { |
| 442 expected_action = | 426 expected_action = |
| 443 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE; | 427 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE; |
| 444 } | 428 } |
| 445 | 429 |
| 446 // Case 1: needs_commit=false. | 430 // Case 1: needs_commit=false. |
| 447 EXPECT_NE(state.BeginFrameNeededToDrawByImplThread(), request_readback) | 431 EXPECT_NE(state.BeginFrameNeededToDrawByImplThread(), request_readback) |
| 448 << *state.AsValue(); | 432 << *state.AsValue(); |
| 449 EXPECT_EQ(expected_action, state.NextAction()) << *state.AsValue(); | 433 EXPECT_EQ(expected_action, state.NextAction()) << *state.AsValue(); |
| 450 | 434 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 } | 500 } |
| 517 | 501 |
| 518 TEST(SchedulerStateMachineTest, | 502 TEST(SchedulerStateMachineTest, |
| 519 TestCanRedrawWithWaitingForFirstDrawMakesProgress) { | 503 TestCanRedrawWithWaitingForFirstDrawMakesProgress) { |
| 520 SchedulerSettings default_scheduler_settings; | 504 SchedulerSettings default_scheduler_settings; |
| 521 StateMachine state(default_scheduler_settings); | 505 StateMachine state(default_scheduler_settings); |
| 522 state.SetCanStart(); | 506 state.SetCanStart(); |
| 523 state.UpdateState(state.NextAction()); | 507 state.UpdateState(state.NextAction()); |
| 524 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 508 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 525 | 509 |
| 526 state.SetCommitState( | |
| 527 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW); | |
| 528 state.SetActiveTreeNeedsFirstDraw(true); | 510 state.SetActiveTreeNeedsFirstDraw(true); |
| 529 state.SetNeedsCommit(); | 511 state.SetNeedsCommit(); |
| 530 state.SetNeedsRedraw(true); | 512 state.SetNeedsRedraw(true); |
| 531 state.SetVisible(true); | 513 state.SetVisible(true); |
| 532 state.SetCanDraw(false); | 514 state.SetCanDraw(false); |
| 533 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); | 515 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); |
| 534 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); | 516 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); |
| 535 EXPECT_ACTION_UPDATE_STATE( | 517 EXPECT_ACTION_UPDATE_STATE( |
| 536 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); | 518 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); |
| 537 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 519 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 | 574 |
| 593 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); | 575 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); |
| 594 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME, | 576 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME, |
| 595 state.begin_frame_state()); | 577 state.begin_frame_state()); |
| 596 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); | 578 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); |
| 597 | 579 |
| 598 // Commit and make sure we draw on next BeginFrame | 580 // Commit and make sure we draw on next BeginFrame |
| 599 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 581 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 600 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 582 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 601 state.OnBeginFrameDeadline(); | 583 state.OnBeginFrameDeadline(); |
| 602 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 584 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 603 state.CommitState()); | |
| 604 EXPECT_ACTION_UPDATE_STATE( | 585 EXPECT_ACTION_UPDATE_STATE( |
| 605 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 586 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 606 state.DidDrawIfPossibleCompleted(true); | 587 state.DidDrawIfPossibleCompleted(true); |
| 607 | 588 |
| 608 // Verify that another commit will start immediately after draw. | 589 // Verify that another commit will start immediately after draw. |
| 609 EXPECT_ACTION_UPDATE_STATE( | 590 EXPECT_ACTION_UPDATE_STATE( |
| 610 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); | 591 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); |
| 611 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 592 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 612 } | 593 } |
| 613 | 594 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 632 EXPECT_FALSE(state.NeedsCommit()); | 613 EXPECT_FALSE(state.NeedsCommit()); |
| 633 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 614 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 634 | 615 |
| 635 // Tell the scheduler the frame finished. | 616 // Tell the scheduler the frame finished. |
| 636 state.FinishCommit(); | 617 state.FinishCommit(); |
| 637 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 618 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
| 638 state.CommitState()); | 619 state.CommitState()); |
| 639 | 620 |
| 640 // Commit. | 621 // Commit. |
| 641 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 622 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 642 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 623 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 643 state.CommitState()); | |
| 644 EXPECT_TRUE(state.NeedsRedraw()); | 624 EXPECT_TRUE(state.NeedsRedraw()); |
| 645 | 625 |
| 646 // Expect to do nothing until BeginFrame deadline | 626 // Expect to do nothing until BeginFrame deadline |
| 647 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 627 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 648 | 628 |
| 649 // At BeginFrame deadline, draw. | 629 // At BeginFrame deadline, draw. |
| 650 state.OnBeginFrameDeadline(); | 630 state.OnBeginFrameDeadline(); |
| 651 EXPECT_ACTION_UPDATE_STATE( | 631 EXPECT_ACTION_UPDATE_STATE( |
| 652 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 632 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 653 state.DidDrawIfPossibleCompleted(true); | 633 state.DidDrawIfPossibleCompleted(true); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 683 state.SetNeedsCommit(); | 663 state.SetNeedsCommit(); |
| 684 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 664 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 685 | 665 |
| 686 // Tell the scheduler the frame finished. | 666 // Tell the scheduler the frame finished. |
| 687 state.FinishCommit(); | 667 state.FinishCommit(); |
| 688 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 668 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
| 689 state.CommitState()); | 669 state.CommitState()); |
| 690 | 670 |
| 691 // First commit. | 671 // First commit. |
| 692 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 672 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 693 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 673 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 694 state.CommitState()); | |
| 695 EXPECT_TRUE(state.NeedsRedraw()); | 674 EXPECT_TRUE(state.NeedsRedraw()); |
| 696 | 675 |
| 697 // Expect to do nothing until BeginFrame deadline. | 676 // Expect to do nothing until BeginFrame deadline. |
| 698 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 677 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 699 | 678 |
| 700 // At BeginFrame deadline, draw. | 679 // At BeginFrame deadline, draw. |
| 701 state.OnBeginFrameDeadline(); | 680 state.OnBeginFrameDeadline(); |
| 702 EXPECT_ACTION_UPDATE_STATE( | 681 EXPECT_ACTION_UPDATE_STATE( |
| 703 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 682 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 704 state.DidDrawIfPossibleCompleted(true); | 683 state.DidDrawIfPossibleCompleted(true); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 // Ask for another draw. Expect nothing happens. | 951 // Ask for another draw. Expect nothing happens. |
| 973 state.SetNeedsRedraw(true); | 952 state.SetNeedsRedraw(true); |
| 974 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 953 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
| 975 | 954 |
| 976 // Finish the frame, and commit. | 955 // Finish the frame, and commit. |
| 977 state.FinishCommit(); | 956 state.FinishCommit(); |
| 978 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 957 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 979 | 958 |
| 980 // We will abort the draw when the output surface is lost if we are | 959 // We will abort the draw when the output surface is lost if we are |
| 981 // waiting for the first draw to unblock the main thread. | 960 // waiting for the first draw to unblock the main thread. |
| 982 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 961 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 983 state.CommitState()); | |
| 984 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); | 962 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); |
| 985 | 963 |
| 986 // Expect to be told to begin context recreation, independent of | 964 // Expect to be told to begin context recreation, independent of |
| 987 // BeginFrame state. | 965 // BeginFrame state. |
| 988 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_IDLE, | 966 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_IDLE, |
| 989 state.begin_frame_state()); | 967 state.begin_frame_state()); |
| 990 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 968 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 991 state.NextAction()); | 969 state.NextAction()); |
| 992 | 970 |
| 993 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); | 971 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1039 state.DidLoseOutputSurface(); | 1017 state.DidLoseOutputSurface(); |
| 1040 | 1018 |
| 1041 // Ask for another draw and also set needs commit. Expect nothing happens. | 1019 // Ask for another draw and also set needs commit. Expect nothing happens. |
| 1042 state.SetNeedsRedraw(true); | 1020 state.SetNeedsRedraw(true); |
| 1043 state.SetNeedsCommit(); | 1021 state.SetNeedsCommit(); |
| 1044 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1022 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1045 | 1023 |
| 1046 // Finish the frame, and commit. | 1024 // Finish the frame, and commit. |
| 1047 state.FinishCommit(); | 1025 state.FinishCommit(); |
| 1048 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1026 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1049 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1027 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 1050 state.CommitState()); | |
| 1051 | 1028 |
| 1052 // Because the output surface is missing, we expect the draw to abort. | 1029 // Because the output surface is missing, we expect the draw to abort. |
| 1053 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); | 1030 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); |
| 1054 | 1031 |
| 1055 // Expect to be told to begin context recreation, independent of | 1032 // Expect to be told to begin context recreation, independent of |
| 1056 // BeginFrame state | 1033 // BeginFrame state |
| 1057 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_IDLE, | 1034 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_IDLE, |
| 1058 state.begin_frame_state()); | 1035 state.begin_frame_state()); |
| 1059 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 1036 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 1060 state.NextAction()); | 1037 state.NextAction()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1100 state.SetCanStart(); | 1077 state.SetCanStart(); |
| 1101 state.UpdateState(state.NextAction()); | 1078 state.UpdateState(state.NextAction()); |
| 1102 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1079 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1103 state.SetVisible(true); | 1080 state.SetVisible(true); |
| 1104 state.SetCanDraw(true); | 1081 state.SetCanDraw(true); |
| 1105 | 1082 |
| 1106 // Cause a lost context lost. | 1083 // Cause a lost context lost. |
| 1107 state.DidLoseOutputSurface(); | 1084 state.DidLoseOutputSurface(); |
| 1108 | 1085 |
| 1109 // Ask a forced redraw for readback and verify it ocurrs. | 1086 // Ask a forced redraw for readback and verify it ocurrs. |
| 1110 state.SetCommitState( | |
| 1111 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW); | |
| 1112 state.SetNeedsForcedRedrawForReadback(); | 1087 state.SetNeedsForcedRedrawForReadback(); |
| 1113 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); | 1088 state.OnBeginFrame(BeginFrameArgs::CreateForTesting()); |
| 1114 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1089 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
| 1115 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1090 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1116 | 1091 |
| 1117 // Forced redraws for readbacks need to be followed by a new commit | 1092 // Forced redraws for readbacks need to be followed by a new commit |
| 1118 // to replace the readback commit. | 1093 // to replace the readback commit. |
| 1119 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1094 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| 1120 state.CommitState()); | 1095 state.CommitState()); |
| 1121 state.FinishCommit(); | 1096 state.FinishCommit(); |
| 1122 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1097 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1123 | 1098 |
| 1124 // We don't yet have an output surface, so we the draw and swap should abort. | 1099 // We don't yet have an output surface, so we the draw and swap should abort. |
| 1125 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); | 1100 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); |
| 1126 | 1101 |
| 1127 // Expect to be told to begin context recreation, independent of | 1102 // Expect to be told to begin context recreation, independent of |
| 1128 // BeginFrame state | 1103 // BeginFrame state |
| 1129 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 1104 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
| 1130 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 1105 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 1131 state.NextAction()); | 1106 state.NextAction()); |
| 1132 | 1107 |
| 1133 state.OnBeginFrameDeadline(); | 1108 state.OnBeginFrameDeadline(); |
| 1134 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 1109 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 1135 state.NextAction()); | 1110 state.NextAction()); |
| 1136 | 1111 |
| 1137 // Ask a readback and verify it occurs. | 1112 // Ask a readback and verify it occurs. |
| 1138 state.SetCommitState( | |
| 1139 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW); | |
| 1140 state.SetNeedsForcedRedrawForReadback(); | 1113 state.SetNeedsForcedRedrawForReadback(); |
| 1141 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1114 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
| 1142 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1115 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1143 } | 1116 } |
| 1144 | 1117 |
| 1145 TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) { | 1118 TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) { |
| 1146 SchedulerSettings default_scheduler_settings; | 1119 SchedulerSettings default_scheduler_settings; |
| 1147 StateMachine state(default_scheduler_settings); | 1120 StateMachine state(default_scheduler_settings); |
| 1148 state.SetCanStart(); | 1121 state.SetCanStart(); |
| 1149 state.UpdateState(state.NextAction()); | 1122 state.UpdateState(state.NextAction()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1199 state.UpdateState(state.NextAction()); | 1172 state.UpdateState(state.NextAction()); |
| 1200 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1173 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1201 state.SetVisible(false); | 1174 state.SetVisible(false); |
| 1202 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS); | 1175 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS); |
| 1203 state.SetNeedsCommit(); | 1176 state.SetNeedsCommit(); |
| 1204 | 1177 |
| 1205 state.FinishCommit(); | 1178 state.FinishCommit(); |
| 1206 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); | 1179 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); |
| 1207 state.UpdateState(state.NextAction()); | 1180 state.UpdateState(state.NextAction()); |
| 1208 | 1181 |
| 1209 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1182 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 1210 state.CommitState()); | |
| 1211 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); | 1183 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); |
| 1212 } | 1184 } |
| 1213 | 1185 |
| 1214 TEST(SchedulerStateMachineTest, TestFinishCommitWhenForcedCommitInProgress) { | 1186 TEST(SchedulerStateMachineTest, TestFinishCommitWhenForcedCommitInProgress) { |
| 1215 SchedulerSettings default_scheduler_settings; | 1187 SchedulerSettings default_scheduler_settings; |
| 1216 StateMachine state(default_scheduler_settings); | 1188 StateMachine state(default_scheduler_settings); |
| 1217 state.SetCanStart(); | 1189 state.SetCanStart(); |
| 1218 state.UpdateState(state.NextAction()); | 1190 state.UpdateState(state.NextAction()); |
| 1219 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1191 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1220 state.SetVisible(false); | 1192 state.SetVisible(false); |
| 1221 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS); | 1193 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS); |
| 1222 state.SetNeedsCommit(); | 1194 state.SetNeedsCommit(); |
| 1223 state.SetNeedsForcedCommitForReadback(); | 1195 state.SetNeedsForcedCommitForReadback(); |
| 1224 | 1196 |
| 1225 // The commit for readback interupts the normal commit. | 1197 // The commit for readback interupts the normal commit. |
| 1226 state.FinishCommit(); | 1198 state.FinishCommit(); |
| 1227 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1199 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1228 | 1200 |
| 1229 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1201 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 1230 state.CommitState()); | |
| 1231 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1202 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
| 1232 | 1203 |
| 1233 // When the readback interrupts the normal commit, we should not get | 1204 // When the readback interrupts the normal commit, we should not get |
| 1234 // another BeginFrame on the impl thread when the readback completes. | 1205 // another BeginFrame on the impl thread when the readback completes. |
| 1235 EXPECT_NE(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, | 1206 EXPECT_NE(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, |
| 1236 state.NextAction()); | 1207 state.NextAction()); |
| 1237 | 1208 |
| 1238 // The normal commit can then proceed. | 1209 // The normal commit can then proceed. |
| 1239 state.FinishCommit(); | 1210 state.FinishCommit(); |
| 1240 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1211 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1289 state.SetNeedsCommit(); | 1260 state.SetNeedsCommit(); |
| 1290 state.SetNeedsForcedCommitForReadback(); | 1261 state.SetNeedsForcedCommitForReadback(); |
| 1291 EXPECT_ACTION_UPDATE_STATE( | 1262 EXPECT_ACTION_UPDATE_STATE( |
| 1292 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); | 1263 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); |
| 1293 state.FinishCommit(); | 1264 state.FinishCommit(); |
| 1294 | 1265 |
| 1295 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1266 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
| 1296 state.CommitState()); | 1267 state.CommitState()); |
| 1297 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1268 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1298 | 1269 |
| 1299 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1270 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 1300 state.CommitState()); | |
| 1301 | 1271 |
| 1302 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1272 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
| 1303 state.DidDrawIfPossibleCompleted(true); | 1273 state.DidDrawIfPossibleCompleted(true); |
| 1304 | 1274 |
| 1305 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1275 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1306 | 1276 |
| 1307 // Should be waiting for the normal begin frame from the main thread. | 1277 // Should be waiting for the normal begin frame from the main thread. |
| 1308 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1278 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| 1309 state.CommitState()); | 1279 state.CommitState()); |
| 1310 } | 1280 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1324 | 1294 |
| 1325 // Schedule a readback, commit it, draw it. | 1295 // Schedule a readback, commit it, draw it. |
| 1326 state.SetNeedsForcedCommitForReadback(); | 1296 state.SetNeedsForcedCommitForReadback(); |
| 1327 EXPECT_ACTION_UPDATE_STATE( | 1297 EXPECT_ACTION_UPDATE_STATE( |
| 1328 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); | 1298 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); |
| 1329 state.FinishCommit(); | 1299 state.FinishCommit(); |
| 1330 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1300 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
| 1331 state.CommitState()); | 1301 state.CommitState()); |
| 1332 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1302 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1333 | 1303 |
| 1334 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1304 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 1335 state.CommitState()); | |
| 1336 | 1305 |
| 1337 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1306 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
| 1338 state.DidDrawIfPossibleCompleted(true); | 1307 state.DidDrawIfPossibleCompleted(true); |
| 1339 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1308 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1340 | 1309 |
| 1341 // Should be waiting for the normal begin frame from the main thread. | 1310 // Should be waiting for the normal begin frame from the main thread. |
| 1342 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1311 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| 1343 state.CommitState()) | 1312 state.CommitState()) |
| 1344 << *state.AsValue(); | 1313 << *state.AsValue(); |
| 1345 } | 1314 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1360 state.SetNeedsCommit(); | 1329 state.SetNeedsCommit(); |
| 1361 state.SetNeedsForcedCommitForReadback(); | 1330 state.SetNeedsForcedCommitForReadback(); |
| 1362 EXPECT_ACTION_UPDATE_STATE( | 1331 EXPECT_ACTION_UPDATE_STATE( |
| 1363 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); | 1332 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); |
| 1364 state.FinishCommit(); | 1333 state.FinishCommit(); |
| 1365 | 1334 |
| 1366 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1335 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
| 1367 state.CommitState()); | 1336 state.CommitState()); |
| 1368 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1337 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1369 | 1338 |
| 1370 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1339 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 1371 state.CommitState()); | |
| 1372 | 1340 |
| 1373 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1341 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
| 1374 state.DidDrawIfPossibleCompleted(true); | 1342 state.DidDrawIfPossibleCompleted(true); |
| 1375 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1343 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1376 | 1344 |
| 1377 // Should be waiting for the main thread's begin frame. | 1345 // Should be waiting for the main thread's begin frame. |
| 1378 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1346 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| 1379 state.CommitState()) | 1347 state.CommitState()) |
| 1380 << *state.AsValue(); | 1348 << *state.AsValue(); |
| 1381 | 1349 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1402 | 1370 |
| 1403 state.SetNeedsCommit(); | 1371 state.SetNeedsCommit(); |
| 1404 state.SetNeedsForcedCommitForReadback(); | 1372 state.SetNeedsForcedCommitForReadback(); |
| 1405 state.UpdateState(state.NextAction()); | 1373 state.UpdateState(state.NextAction()); |
| 1406 state.FinishCommit(); | 1374 state.FinishCommit(); |
| 1407 | 1375 |
| 1408 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1376 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
| 1409 state.CommitState()); | 1377 state.CommitState()); |
| 1410 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1378 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1411 | 1379 |
| 1412 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1380 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
| 1413 state.CommitState()); | |
| 1414 | 1381 |
| 1415 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1382 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
| 1416 state.DidDrawIfPossibleCompleted(true); | 1383 state.DidDrawIfPossibleCompleted(true); |
| 1417 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1384 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1418 } | 1385 } |
| 1419 | 1386 |
| 1420 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { | 1387 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { |
| 1421 SchedulerSettings default_scheduler_settings; | 1388 SchedulerSettings default_scheduler_settings; |
| 1422 StateMachine state(default_scheduler_settings); | 1389 StateMachine state(default_scheduler_settings); |
| 1423 state.SetCanStart(); | 1390 state.SetCanStart(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1506 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 1473 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
| 1507 | 1474 |
| 1508 state.BeginFrameAbortedByMainThread(true); | 1475 state.BeginFrameAbortedByMainThread(true); |
| 1509 | 1476 |
| 1510 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 1477 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
| 1511 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); | 1478 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); |
| 1512 } | 1479 } |
| 1513 | 1480 |
| 1514 } // namespace | 1481 } // namespace |
| 1515 } // namespace cc | 1482 } // namespace cc |
| OLD | NEW |