diff options
author | brianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-28 03:29:42 +0000 |
---|---|---|
committer | brianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-28 03:29:42 +0000 |
commit | bfadad256321299f5337891718f5486683e506fd (patch) | |
tree | f78ee1ad7dc0e25c486387167cafc6f8bcbd45cd /cc | |
parent | ddfb4fdb3e85ed6864f1ca2a973a08df1cee4b3d (diff) | |
download | chromium_src-bfadad256321299f5337891718f5486683e506fd.zip chromium_src-bfadad256321299f5337891718f5486683e506fd.tar.gz chromium_src-bfadad256321299f5337891718f5486683e506fd.tar.bz2 |
cc: Simplify Scheduler::NextAction
This obseletes the switch statement in Scheduler::NextAction,
by moving the remaining logic necessary needed to do so into
the Should<some action> methods.
BUG=279568
Review URL: https://chromiumcodereview.appspot.com/23474005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/scheduler/scheduler_state_machine.cc | 81 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine.h | 1 |
2 files changed, 27 insertions, 55 deletions
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc index 9498b7d..f3c094f 100644 --- a/cc/scheduler/scheduler_state_machine.cc +++ b/cc/scheduler/scheduler_state_machine.cc @@ -253,6 +253,11 @@ bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const { if (!can_start_) return false; + // We only want to start output surface initialization after the + // previous commit is complete. + if (commit_state_ != COMMIT_STATE_IDLE) + return false; + // We need to create the output surface if we don't have one and we haven't // started creating one yet. return output_surface_state_ == OUTPUT_SURFACE_LOST; @@ -385,65 +390,31 @@ bool SchedulerStateMachine::ShouldSendBeginFrameToMainThread() const { return true; } +bool SchedulerStateMachine::ShouldCommit() const { + return commit_state_ == COMMIT_STATE_READY_TO_COMMIT; +} + SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { if (ShouldAcquireLayerTexturesForMainThread()) return ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD; - - switch (commit_state_) { - case COMMIT_STATE_IDLE: - if (ShouldUpdateVisibleTiles()) - return ACTION_UPDATE_VISIBLE_TILES; - if (ShouldActivatePendingTree()) - return ACTION_ACTIVATE_PENDING_TREE; - if (ShouldDraw()) { - return needs_forced_redraw_ ? ACTION_DRAW_FORCED - : ACTION_DRAW_IF_POSSIBLE; - } - if (ShouldSendBeginFrameToMainThread()) - return ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD; - if (ShouldBeginOutputSurfaceCreation()) - return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; - return ACTION_NONE; - - case COMMIT_STATE_FRAME_IN_PROGRESS: - if (ShouldUpdateVisibleTiles()) - return ACTION_UPDATE_VISIBLE_TILES; - if (ShouldActivatePendingTree()) - return ACTION_ACTIVATE_PENDING_TREE; - if (ShouldDraw()) { - return needs_forced_redraw_ ? ACTION_DRAW_FORCED - : ACTION_DRAW_IF_POSSIBLE; - } - return ACTION_NONE; - - case COMMIT_STATE_READY_TO_COMMIT: - return ACTION_COMMIT; - - case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: - if (ShouldUpdateVisibleTiles()) - return ACTION_UPDATE_VISIBLE_TILES; - if (ShouldActivatePendingTree()) - return ACTION_ACTIVATE_PENDING_TREE; - if (ShouldDraw()) { - if (needs_forced_redraw_) - return ACTION_DRAW_FORCED; - else if (PendingDrawsShouldBeAborted()) - return ACTION_DRAW_AND_SWAP_ABORT; - else - return ACTION_DRAW_IF_POSSIBLE; - } - return ACTION_NONE; - - case COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW: - if (ShouldUpdateVisibleTiles()) - return ACTION_UPDATE_VISIBLE_TILES; - if (ShouldActivatePendingTree()) - return ACTION_ACTIVATE_PENDING_TREE; - if (ShouldDraw()) - return ACTION_DRAW_FORCED; - return ACTION_NONE; + if (ShouldUpdateVisibleTiles()) + return ACTION_UPDATE_VISIBLE_TILES; + if (ShouldActivatePendingTree()) + return ACTION_ACTIVATE_PENDING_TREE; + if (ShouldCommit()) + return ACTION_COMMIT; + if (ShouldDraw()) { + if (needs_forced_redraw_) + return ACTION_DRAW_FORCED; + else if (PendingDrawsShouldBeAborted()) + return ACTION_DRAW_AND_SWAP_ABORT; + else + return ACTION_DRAW_IF_POSSIBLE; } - NOTREACHED(); + if (ShouldSendBeginFrameToMainThread()) + return ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD; + if (ShouldBeginOutputSurfaceCreation()) + return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; return ACTION_NONE; } diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h index 09653ee..43bf2be 100644 --- a/cc/scheduler/scheduler_state_machine.h +++ b/cc/scheduler/scheduler_state_machine.h @@ -179,6 +179,7 @@ class CC_EXPORT SchedulerStateMachine { bool ShouldAcquireLayerTexturesForMainThread() const; bool ShouldUpdateVisibleTiles() const; bool ShouldSendBeginFrameToMainThread() const; + bool ShouldCommit() const; bool HasDrawnThisFrame() const; bool HasActivatedPendingTreeThisFrame() const; |