diff options
author | brianderson <brianderson@chromium.org> | 2015-08-13 15:55:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-13 22:56:26 +0000 |
commit | 1f154eacd3030a3b9c369675740cac42a0203825 (patch) | |
tree | 0724ce879edecba3bf7aeffbc652d076a64a9fa0 /cc | |
parent | 1b1c3d9bb1fd134d73daf0c59c549e8d02b7a36a (diff) | |
download | chromium_src-1f154eacd3030a3b9c369675740cac42a0203825.zip chromium_src-1f154eacd3030a3b9c369675740cac42a0203825.tar.gz chromium_src-1f154eacd3030a3b9c369675740cac42a0203825.tar.bz2 |
cc: Remove SchedulerStateMachine::UpdateState
Also rename UpdateStateOn<Action> to Will<Action> and
call Will<Action> directly from the Scheduler.
This is in preparation of adding a Did<Action> methods
that will allow us to update state immediately
in response to the results of an action.
Update and restructure tests for new interface.
BUG=486072
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1253203003
Cr-Commit-Position: refs/heads/master@{#343294}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/scheduler/scheduler.cc | 21 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine.cc | 68 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine.h | 18 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine_unittest.cc | 147 |
4 files changed, 148 insertions, 106 deletions
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc index 452bbb6..851f976 100644 --- a/cc/scheduler/scheduler.cc +++ b/cc/scheduler/scheduler.cc @@ -629,17 +629,18 @@ void Scheduler::ProcessScheduledActions() { "SchedulerStateMachine", "state", AsValue()); - state_machine_.UpdateState(action); base::AutoReset<SchedulerStateMachine::Action> mark_inside_action(&inside_action_, action); switch (action) { case SchedulerStateMachine::ACTION_NONE: break; case SchedulerStateMachine::ACTION_ANIMATE: + state_machine_.WillAnimate(); client_->ScheduledActionAnimate(); break; case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: compositor_timing_history_->WillBeginMainFrame(); + state_machine_.WillSendBeginMainFrame(); client_->ScheduledActionSendBeginMainFrame(); break; case SchedulerStateMachine::ACTION_COMMIT: { @@ -648,11 +649,14 @@ void Scheduler::ProcessScheduledActions() { tracked_objects::ScopedTracker tracking_profile4( FROM_HERE_WITH_EXPLICIT_FUNCTION( "461509 Scheduler::ProcessScheduledActions4")); + bool commit_has_no_updates = false; + state_machine_.WillCommit(commit_has_no_updates); client_->ScheduledActionCommit(); break; } case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: compositor_timing_history_->WillActivate(); + state_machine_.WillActivate(); client_->ScheduledActionActivateSyncTree(); compositor_timing_history_->DidActivate(); break; @@ -662,23 +666,34 @@ void Scheduler::ProcessScheduledActions() { tracked_objects::ScopedTracker tracking_profile6( FROM_HERE_WITH_EXPLICIT_FUNCTION( "461509 Scheduler::ProcessScheduledActions6")); + bool did_request_swap = true; + state_machine_.WillDraw(did_request_swap); DrawAndSwapIfPossible(); break; } - case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: + case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: { + bool did_request_swap = true; + state_machine_.WillDraw(did_request_swap); DrawAndSwapForced(); break; - case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: + } + case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: { // No action is actually performed, but this allows the state machine to // advance out of its waiting to draw state without actually drawing. + bool did_request_swap = false; + state_machine_.WillDraw(did_request_swap); break; + } case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: + state_machine_.WillBeginOutputSurfaceCreation(); client_->ScheduledActionBeginOutputSurfaceCreation(); break; case SchedulerStateMachine::ACTION_PREPARE_TILES: + state_machine_.WillPrepareTiles(); client_->ScheduledActionPrepareTiles(); break; case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE: { + state_machine_.WillInvalidateOutputSurface(); client_->ScheduledActionInvalidateOutputSurface(); break; } diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc index 00b6ed0..a0c74fe 100644 --- a/cc/scheduler/scheduler_state_machine.cc +++ b/cc/scheduler/scheduler_state_machine.cc @@ -560,57 +560,7 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { return ACTION_NONE; } -void SchedulerStateMachine::UpdateState(Action action) { - switch (action) { - case ACTION_NONE: - return; - - case ACTION_ACTIVATE_SYNC_TREE: - UpdateStateOnActivation(); - return; - - case ACTION_ANIMATE: - UpdateStateOnAnimate(); - return; - - case ACTION_SEND_BEGIN_MAIN_FRAME: - UpdateStateOnSendBeginMainFrame(); - return; - - case ACTION_COMMIT: { - bool commit_has_no_updates = false; - UpdateStateOnCommit(commit_has_no_updates); - return; - } - - case ACTION_DRAW_AND_SWAP_FORCED: - case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { - bool did_request_swap = true; - UpdateStateOnDraw(did_request_swap); - return; - } - - case ACTION_DRAW_AND_SWAP_ABORT: { - bool did_request_swap = false; - UpdateStateOnDraw(did_request_swap); - return; - } - - case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: - UpdateStateOnBeginOutputSurfaceCreation(); - return; - - case ACTION_PREPARE_TILES: - UpdateStateOnPrepareTiles(); - return; - - case ACTION_INVALIDATE_OUTPUT_SURFACE: - UpdateStateOnInvalidateOutputSurface(); - return; - } -} - -void SchedulerStateMachine::UpdateStateOnAnimate() { +void SchedulerStateMachine::WillAnimate() { DCHECK(!animate_funnel_); last_frame_number_animate_performed_ = current_frame_number_; animate_funnel_ = true; @@ -619,7 +569,7 @@ void SchedulerStateMachine::UpdateStateOnAnimate() { SetNeedsRedraw(); } -void SchedulerStateMachine::UpdateStateOnSendBeginMainFrame() { +void SchedulerStateMachine::WillSendBeginMainFrame() { DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); DCHECK(visible_); DCHECK(!send_begin_main_frame_funnel_); @@ -629,7 +579,7 @@ void SchedulerStateMachine::UpdateStateOnSendBeginMainFrame() { last_frame_number_begin_main_frame_sent_ = current_frame_number_; } -void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) { +void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { commit_count_++; // Animate after commit even if we've already animated. @@ -683,7 +633,7 @@ void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) { last_commit_had_no_updates_ = commit_has_no_updates; } -void SchedulerStateMachine::UpdateStateOnActivation() { +void SchedulerStateMachine::WillActivate() { if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) { begin_main_frame_state_ = settings_.commit_to_active_tree @@ -703,7 +653,7 @@ void SchedulerStateMachine::UpdateStateOnActivation() { needs_redraw_ = true; } -void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { +void SchedulerStateMachine::WillDraw(bool did_request_swap) { if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; @@ -721,11 +671,11 @@ void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { } } -void SchedulerStateMachine::UpdateStateOnPrepareTiles() { +void SchedulerStateMachine::WillPrepareTiles() { needs_prepare_tiles_ = false; } -void SchedulerStateMachine::UpdateStateOnBeginOutputSurfaceCreation() { +void SchedulerStateMachine::WillBeginOutputSurfaceCreation() { DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); output_surface_state_ = OUTPUT_SURFACE_CREATING; @@ -737,7 +687,7 @@ void SchedulerStateMachine::UpdateStateOnBeginOutputSurfaceCreation() { DCHECK(!active_tree_needs_first_draw_); } -void SchedulerStateMachine::UpdateStateOnInvalidateOutputSurface() { +void SchedulerStateMachine::WillInvalidateOutputSurface() { DCHECK(!invalidate_output_surface_funnel_); invalidate_output_surface_funnel_ = true; last_frame_number_invalidate_output_surface_performed_ = @@ -1101,7 +1051,7 @@ void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { return; case CommitEarlyOutReason::FINISHED_NO_UPDATES: bool commit_has_no_updates = true; - UpdateStateOnCommit(commit_has_no_updates); + WillCommit(commit_has_no_updates); return; } } diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h index af81845..0477a2f 100644 --- a/cc/scheduler/scheduler_state_machine.h +++ b/cc/scheduler/scheduler_state_machine.h @@ -122,7 +122,14 @@ class CC_EXPORT SchedulerStateMachine { void AsValueInto(base::trace_event::TracedValue* dict) const; Action NextAction() const; - void UpdateState(Action action); + void WillAnimate(); + void WillSendBeginMainFrame(); + void WillCommit(bool commit_had_no_updates); + void WillActivate(); + void WillDraw(bool did_request_swap); + void WillBeginOutputSurfaceCreation(); + void WillPrepareTiles(); + void WillInvalidateOutputSurface(); // Indicates whether the impl thread needs a BeginImplFrame callback in order // to make progress. @@ -284,15 +291,6 @@ class CC_EXPORT SchedulerStateMachine { bool ShouldPrepareTiles() const; bool ShouldInvalidateOutputSurface() const; - void UpdateStateOnAnimate(); - void UpdateStateOnSendBeginMainFrame(); - void UpdateStateOnCommit(bool commit_had_no_updates); - void UpdateStateOnActivation(); - void UpdateStateOnDraw(bool did_request_swap); - void UpdateStateOnBeginOutputSurfaceCreation(); - void UpdateStateOnPrepareTiles(); - void UpdateStateOnInvalidateOutputSurface(); - const SchedulerSettings settings_; OutputSurfaceState output_surface_state_; diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc index 8f07c86..c110a0d 100644 --- a/cc/scheduler/scheduler_state_machine_unittest.cc +++ b/cc/scheduler/scheduler_state_machine_unittest.cc @@ -40,7 +40,7 @@ EXPECT_IMPL_FRAME_STATE( \ SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); \ } \ - state.UpdateState(action); \ + WillPerformAction(&state, action); \ if (action == SchedulerStateMachine::ACTION_NONE) { \ if (state.begin_impl_frame_state() == \ SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) \ @@ -50,17 +50,70 @@ state.OnBeginImplFrameIdle(); \ } -#define SET_UP_STATE(state) \ - state.SetCanStart(); \ - state.UpdateState(state.NextAction()); \ - state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); \ - state.SetVisible(true); \ +#define SET_UP_STATE(state) \ + state.SetCanStart(); \ + EXPECT_ACTION_UPDATE_STATE( \ + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); \ + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); \ + state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); \ + state.SetVisible(true); \ state.SetCanDraw(true); namespace cc { namespace { +void WillPerformAction(SchedulerStateMachine* sm, + SchedulerStateMachine::Action action) { + switch (action) { + case SchedulerStateMachine::ACTION_NONE: + return; + + case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: + sm->WillActivate(); + return; + + case SchedulerStateMachine::ACTION_ANIMATE: + sm->WillAnimate(); + return; + + case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: + sm->WillSendBeginMainFrame(); + return; + + case SchedulerStateMachine::ACTION_COMMIT: { + bool commit_has_no_updates = false; + sm->WillCommit(commit_has_no_updates); + return; + } + + case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: + case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { + bool did_request_swap = true; + sm->WillDraw(did_request_swap); + return; + } + + case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: { + bool did_request_swap = false; + sm->WillDraw(did_request_swap); + return; + } + + case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: + sm->WillBeginOutputSurfaceCreation(); + return; + + case SchedulerStateMachine::ACTION_PREPARE_TILES: + sm->WillPrepareTiles(); + return; + + case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE: + sm->WillInvalidateOutputSurface(); + return; + } +} + const SchedulerStateMachine::BeginImplFrameState all_begin_impl_frame_states[] = {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, @@ -146,7 +199,7 @@ class StateMachine : public SchedulerStateMachine { using SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately; using SchedulerStateMachine::ProactiveBeginFrameWanted; - using SchedulerStateMachine::UpdateStateOnCommit; + using SchedulerStateMachine::WillCommit; }; TEST(SchedulerStateMachineTest, BeginFrameNeeded) { @@ -154,7 +207,8 @@ TEST(SchedulerStateMachineTest, BeginFrameNeeded) { StateMachine state(default_scheduler_settings); state.SetCanStart(); EXPECT_ACTION_UPDATE_STATE( - SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION) + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetBeginMainFrameState( SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); @@ -202,7 +256,8 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { StateMachine state(default_scheduler_settings); state.SetCanStart(); EXPECT_ACTION_UPDATE_STATE( - SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION) + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetBeginMainFrameState( SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); @@ -246,7 +301,9 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { state.SetBeginMainFrameState( SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetNeedsRedraw(false); state.SetVisible(true); @@ -272,7 +329,9 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { state.SetBeginMainFrameState( SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetNeedsRedraw(false); state.SetVisible(true); @@ -662,7 +721,9 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { for (size_t j = 0; j < num_begin_impl_frame_states; ++j) { StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetBeginMainFrameState(begin_main_frame_states[i]); state.SetBeginImplFrameState(all_begin_impl_frame_states[j]); @@ -688,7 +749,9 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { for (size_t i = 0; i < num_begin_main_frame_states; ++i) { StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetCanDraw(true); state.SetBeginMainFrameState(begin_main_frame_states[i]); @@ -704,8 +767,7 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { expected_action = SchedulerStateMachine::ACTION_COMMIT; } else { expected_action = SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE; - EXPECT_ACTION(SchedulerStateMachine::ACTION_ANIMATE); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); } // Case 1: needs_begin_main_frame=false. @@ -728,7 +790,9 @@ TEST(SchedulerStateMachineTest, TestNoBeginMainFrameStatesRedrawWhenInvisible) { for (size_t j = 0; j < 2; ++j) { StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetBeginMainFrameState(begin_main_frame_states[i]); state.SetVisible(false); @@ -762,7 +826,9 @@ TEST(SchedulerStateMachineTest, TestCanRedraw_StopsDraw) { for (size_t j = 0; j < 2; ++j) { StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetBeginMainFrameState(begin_main_frame_states[i]); state.SetVisible(false); @@ -782,7 +848,9 @@ TEST(SchedulerStateMachineTest, SchedulerSettings default_scheduler_settings; StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetActiveTreeNeedsFirstDraw(true); @@ -1125,7 +1193,9 @@ TEST(SchedulerStateMachineTest, TestRequestCommitInvisible) { SchedulerSettings default_scheduler_settings; StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetNeedsBeginMainFrame(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1189,7 +1259,9 @@ TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseCommitNotNeeded) { SchedulerSettings default_scheduler_settings; StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.DidCreateAndInitializeOutputSurface(); state.SetVisible(true); state.SetCanDraw(true); @@ -1270,8 +1342,9 @@ TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) { state.NextAction()); state.DidLoseOutputSurface(); - EXPECT_ACTION(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Once context recreation begins, nothing should happen. EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1566,8 +1639,9 @@ TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) { // Cause a lost output surface, and restore it. state.DidLoseOutputSurface(); - EXPECT_ACTION(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.DidCreateAndInitializeOutputSurface(); EXPECT_FALSE(state.RedrawPending()); @@ -1602,7 +1676,9 @@ TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) { SchedulerSettings default_scheduler_settings; StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetVisible(true); @@ -1621,7 +1697,9 @@ TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) { SchedulerSettings default_scheduler_settings; StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetVisible(false); state.SetNeedsBeginMainFrame(); @@ -1640,23 +1718,24 @@ TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) { SchedulerSettings default_scheduler_settings; StateMachine state(default_scheduler_settings); state.SetCanStart(); - state.UpdateState(state.NextAction()); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); state.SetVisible(false); state.SetBeginMainFrameState( SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); state.SetNeedsBeginMainFrame(); + // After the commit completes, activation and draw happen immediately + // because we are not visible. state.NotifyBeginMainFrameStarted(); state.NotifyReadyToCommit(); - EXPECT_ACTION(SchedulerStateMachine::ACTION_COMMIT); - state.UpdateState(state.NextAction()); - state.NotifyReadyToActivate(); - EXPECT_ACTION(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); - state.UpdateState(state.NextAction()); - + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); EXPECT_TRUE(state.active_tree_needs_first_draw()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); } TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) { @@ -1982,7 +2061,7 @@ TEST(SchedulerStateMachineTest, EarlyOutCommitWantsProactiveBeginFrame) { EXPECT_FALSE(state.ProactiveBeginFrameWanted()); bool commit_has_no_updates = true; - state.UpdateStateOnCommit(commit_has_no_updates); + state.WillCommit(commit_has_no_updates); EXPECT_TRUE(state.ProactiveBeginFrameWanted()); state.OnBeginImplFrame(); EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |