| Index: cc/scheduler/scheduler_state_machine.cc
|
| diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
|
| index c3a4a1e272a5a6006ac49548dea5b206cdb40a0b..b3820f3f3cc1124fcb60f3db941804e2fdaf8435 100644
|
| --- a/cc/scheduler/scheduler_state_machine.cc
|
| +++ b/cc/scheduler/scheduler_state_machine.cc
|
| @@ -16,10 +16,10 @@ namespace cc {
|
|
|
| SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
|
| : settings_(settings),
|
| - output_surface_state_(OUTPUT_SURFACE_LOST),
|
| - begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE),
|
| - commit_state_(COMMIT_STATE_IDLE),
|
| - forced_redraw_state_(FORCED_REDRAW_STATE_IDLE),
|
| + output_surface_state_(OutputSurfaceState::LOST),
|
| + begin_impl_frame_state_(BeginImplFrameState::IDLE),
|
| + commit_state_(CommitState::IDLE),
|
| + forced_redraw_state_(ForcedRedrawOnTimeoutState::IDLE),
|
| commit_count_(0),
|
| current_frame_number_(0),
|
| last_frame_number_animate_performed_(-1),
|
| @@ -54,16 +54,16 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
|
| const char* SchedulerStateMachine::OutputSurfaceStateToString(
|
| OutputSurfaceState state) {
|
| switch (state) {
|
| - case OUTPUT_SURFACE_ACTIVE:
|
| - return "OUTPUT_SURFACE_ACTIVE";
|
| - case OUTPUT_SURFACE_LOST:
|
| - return "OUTPUT_SURFACE_LOST";
|
| - case OUTPUT_SURFACE_CREATING:
|
| - return "OUTPUT_SURFACE_CREATING";
|
| - case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
|
| - return "OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT";
|
| - case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
|
| - return "OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION";
|
| + case OutputSurfaceState::ACTIVE:
|
| + return "OutputSurfaceState::ACTIVE";
|
| + case OutputSurfaceState::LOST:
|
| + return "OutputSurfaceState::LOST";
|
| + case OutputSurfaceState::CREATING:
|
| + return "OutputSurfaceState::CREATING";
|
| + case OutputSurfaceState::WAITING_FOR_FIRST_COMMIT:
|
| + return "OutputSurfaceState::WAITING_FOR_FIRST_COMMIT";
|
| + case OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION:
|
| + return "OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION";
|
| }
|
| NOTREACHED();
|
| return "???";
|
| @@ -72,14 +72,14 @@ const char* SchedulerStateMachine::OutputSurfaceStateToString(
|
| const char* SchedulerStateMachine::BeginImplFrameStateToString(
|
| BeginImplFrameState state) {
|
| switch (state) {
|
| - case BEGIN_IMPL_FRAME_STATE_IDLE:
|
| - return "BEGIN_IMPL_FRAME_STATE_IDLE";
|
| - case BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING:
|
| - return "BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING";
|
| - case BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME:
|
| - return "BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME";
|
| - case BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE:
|
| - return "BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE";
|
| + case BeginImplFrameState::IDLE:
|
| + return "BeginImplFrameState::IDLE";
|
| + case BeginImplFrameState::BEGIN_FRAME_STARTING:
|
| + return "BeginImplFrameState::BEGIN_FRAME_STARTING";
|
| + case BeginImplFrameState::INSIDE_BEGIN_FRAME:
|
| + return "BeginImplFrameState::INSIDE_BEGIN_FRAME";
|
| + case BeginImplFrameState::INSIDE_DEADLINE:
|
| + return "BeginImplFrameState::INSIDE_DEADLINE";
|
| }
|
| NOTREACHED();
|
| return "???";
|
| @@ -87,18 +87,18 @@ const char* SchedulerStateMachine::BeginImplFrameStateToString(
|
|
|
| const char* SchedulerStateMachine::CommitStateToString(CommitState state) {
|
| switch (state) {
|
| - case COMMIT_STATE_IDLE:
|
| - return "COMMIT_STATE_IDLE";
|
| - case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT:
|
| - return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT";
|
| - case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED:
|
| - return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED";
|
| - case COMMIT_STATE_READY_TO_COMMIT:
|
| - return "COMMIT_STATE_READY_TO_COMMIT";
|
| - case COMMIT_STATE_WAITING_FOR_ACTIVATION:
|
| - return "COMMIT_STATE_WAITING_FOR_ACTIVATION";
|
| - case COMMIT_STATE_WAITING_FOR_DRAW:
|
| - return "COMMIT_STATE_WAITING_FOR_DRAW";
|
| + case CommitState::IDLE:
|
| + return "CommitState::IDLE";
|
| + case CommitState::BEGIN_MAIN_FRAME_SENT:
|
| + return "CommitState::BEGIN_MAIN_FRAME_SENT";
|
| + case CommitState::BEGIN_MAIN_FRAME_STARTED:
|
| + return "CommitState::BEGIN_MAIN_FRAME_STARTED";
|
| + case CommitState::READY_TO_COMMIT:
|
| + return "CommitState::READY_TO_COMMIT";
|
| + case CommitState::WAITING_FOR_ACTIVATION:
|
| + return "CommitState::WAITING_FOR_ACTIVATION";
|
| + case CommitState::WAITING_FOR_DRAW:
|
| + return "CommitState::WAITING_FOR_DRAW";
|
| }
|
| NOTREACHED();
|
| return "???";
|
| @@ -107,14 +107,14 @@ const char* SchedulerStateMachine::CommitStateToString(CommitState state) {
|
| const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
|
| ForcedRedrawOnTimeoutState state) {
|
| switch (state) {
|
| - case FORCED_REDRAW_STATE_IDLE:
|
| - return "FORCED_REDRAW_STATE_IDLE";
|
| - case FORCED_REDRAW_STATE_WAITING_FOR_COMMIT:
|
| - return "FORCED_REDRAW_STATE_WAITING_FOR_COMMIT";
|
| - case FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION:
|
| - return "FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION";
|
| - case FORCED_REDRAW_STATE_WAITING_FOR_DRAW:
|
| - return "FORCED_REDRAW_STATE_WAITING_FOR_DRAW";
|
| + case ForcedRedrawOnTimeoutState::IDLE:
|
| + return "ForcedRedrawOnTimeoutState::IDLE";
|
| + case ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT:
|
| + return "ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT";
|
| + case ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION:
|
| + return "ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION";
|
| + case ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW:
|
| + return "ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW";
|
| }
|
| NOTREACHED();
|
| return "???";
|
| @@ -122,26 +122,26 @@ const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
|
|
|
| const char* SchedulerStateMachine::ActionToString(Action action) {
|
| switch (action) {
|
| - case ACTION_NONE:
|
| - return "ACTION_NONE";
|
| - case ACTION_ANIMATE:
|
| - return "ACTION_ANIMATE";
|
| - case ACTION_SEND_BEGIN_MAIN_FRAME:
|
| - return "ACTION_SEND_BEGIN_MAIN_FRAME";
|
| - case ACTION_COMMIT:
|
| - return "ACTION_COMMIT";
|
| - case ACTION_ACTIVATE_SYNC_TREE:
|
| - return "ACTION_ACTIVATE_SYNC_TREE";
|
| - case ACTION_DRAW_AND_SWAP_IF_POSSIBLE:
|
| - return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE";
|
| - case ACTION_DRAW_AND_SWAP_FORCED:
|
| - return "ACTION_DRAW_AND_SWAP_FORCED";
|
| - case ACTION_DRAW_AND_SWAP_ABORT:
|
| - return "ACTION_DRAW_AND_SWAP_ABORT";
|
| - case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
|
| - return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION";
|
| - case ACTION_PREPARE_TILES:
|
| - return "ACTION_PREPARE_TILES";
|
| + case Action::NONE:
|
| + return "Action::NONE";
|
| + case Action::ANIMATE:
|
| + return "Action::ANIMATE";
|
| + case Action::SEND_BEGIN_MAIN_FRAME:
|
| + return "Action::SEND_BEGIN_MAIN_FRAME";
|
| + case Action::COMMIT:
|
| + return "Action::COMMIT";
|
| + case Action::ACTIVATE_SYNC_TREE:
|
| + return "Action::ACTIVATE_SYNC_TREE";
|
| + case Action::DRAW_AND_SWAP_IF_POSSIBLE:
|
| + return "Action::DRAW_AND_SWAP_IF_POSSIBLE";
|
| + case Action::DRAW_AND_SWAP_FORCED:
|
| + return "Action::DRAW_AND_SWAP_FORCED";
|
| + case Action::DRAW_AND_SWAP_ABORT:
|
| + return "Action::DRAW_AND_SWAP_ABORT";
|
| + case Action::BEGIN_OUTPUT_SURFACE_CREATION:
|
| + return "Action::BEGIN_OUTPUT_SURFACE_CREATION";
|
| + case Action::PREPARE_TILES:
|
| + return "Action::PREPARE_TILES";
|
| }
|
| NOTREACHED();
|
| return "???";
|
| @@ -290,7 +290,7 @@ bool SchedulerStateMachine::PendingActivationsShouldBeForced() const {
|
| // There is no output surface to trigger our activations.
|
| // If we do not force activations to make forward progress, we might deadlock
|
| // with the main thread.
|
| - if (output_surface_state_ == OUTPUT_SURFACE_LOST)
|
| + if (output_surface_state_ == OutputSurfaceState::LOST)
|
| return true;
|
|
|
| // If we're not visible, we should force activation.
|
| @@ -313,12 +313,12 @@ bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const {
|
|
|
| // We only want to start output surface initialization after the
|
| // previous commit is complete.
|
| - if (commit_state_ != COMMIT_STATE_IDLE)
|
| + if (commit_state_ != CommitState::IDLE)
|
| return false;
|
|
|
| // Make sure the BeginImplFrame from any previous OutputSurfaces
|
| // are complete before creating the new OutputSurface.
|
| - if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE)
|
| + if (begin_impl_frame_state_ != BeginImplFrameState::IDLE)
|
| return false;
|
|
|
| // We want to clear the pipline of any pending draws and activations
|
| @@ -330,7 +330,7 @@ bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const {
|
|
|
| // 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;
|
| + return output_surface_state_ == OutputSurfaceState::LOST;
|
| }
|
|
|
| bool SchedulerStateMachine::ShouldDraw() const {
|
| @@ -343,7 +343,7 @@ bool SchedulerStateMachine::ShouldDraw() const {
|
| return active_tree_needs_first_draw_;
|
|
|
| // Don't draw if we are waiting on the first commit after a surface.
|
| - if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE)
|
| + if (output_surface_state_ != OutputSurfaceState::ACTIVE)
|
| return false;
|
|
|
| // If a commit has occurred after the animate call, we need to call animate
|
| @@ -361,11 +361,11 @@ bool SchedulerStateMachine::ShouldDraw() const {
|
|
|
| // Except for the cases above, do not draw outside of the BeginImplFrame
|
| // deadline.
|
| - if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
|
| + if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE)
|
| return false;
|
|
|
| // Only handle forced redraws due to timeouts on the regular deadline.
|
| - if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
|
| + if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
|
| return true;
|
|
|
| return needs_redraw_;
|
| @@ -392,15 +392,15 @@ bool SchedulerStateMachine::ShouldActivatePendingTree() const {
|
|
|
| bool SchedulerStateMachine::ShouldAnimate() const {
|
| // Don't animate if we are waiting on the first commit after a surface.
|
| - if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE)
|
| + if (output_surface_state_ != OutputSurfaceState::ACTIVE)
|
| return false;
|
|
|
| // If a commit occurred after our last call, we need to do animation again.
|
| if (HasAnimatedThisFrame() && !did_commit_after_animating_)
|
| return false;
|
|
|
| - if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING &&
|
| - begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
|
| + if (begin_impl_frame_state_ != BeginImplFrameState::BEGIN_FRAME_STARTING &&
|
| + begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE)
|
| return false;
|
|
|
| return needs_redraw_ || needs_animate_;
|
| @@ -422,7 +422,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
|
| return false;
|
|
|
| // Only send BeginMainFrame when there isn't another commit pending already.
|
| - if (commit_state_ != COMMIT_STATE_IDLE)
|
| + if (commit_state_ != CommitState::IDLE)
|
| return false;
|
|
|
| // Don't send BeginMainFrame early if we are prioritizing the active tree
|
| @@ -433,17 +433,17 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
|
| }
|
|
|
| // We should not send BeginMainFrame while we are in
|
| - // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new
|
| + // BeginImplFrameState::IDLE since we might have new
|
| // user input arriving soon.
|
| // TODO(brianderson): Allow sending BeginMainFrame while idle when the main
|
| // thread isn't consuming user input.
|
| - if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE &&
|
| + if (begin_impl_frame_state_ == BeginImplFrameState::IDLE &&
|
| BeginFrameNeeded())
|
| return false;
|
|
|
| // We need a new commit for the forced redraw. This honors the
|
| // single commit per interval because the result will be swapped to screen.
|
| - if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT)
|
| + if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT)
|
| return true;
|
|
|
| // After this point, we only start a commit once per frame.
|
| @@ -457,7 +457,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
|
| // SwapAck throttle the BeginMainFrames unless we just swapped.
|
| // TODO(brianderson): Remove this restriction to improve throughput.
|
| bool just_swapped_in_deadline =
|
| - begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE &&
|
| + begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE &&
|
| HasSwappedThisFrame();
|
| if (pending_swaps_ >= max_pending_swaps_ && !just_swapped_in_deadline)
|
| return false;
|
| @@ -469,7 +469,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
|
| }
|
|
|
| bool SchedulerStateMachine::ShouldCommit() const {
|
| - if (commit_state_ != COMMIT_STATE_READY_TO_COMMIT)
|
| + if (commit_state_ != CommitState::READY_TO_COMMIT)
|
| return false;
|
|
|
| // We must not finish the commit until the pending tree is free.
|
| @@ -495,7 +495,7 @@ bool SchedulerStateMachine::ShouldPrepareTiles() const {
|
| // Limiting to once per-frame is not enough, since we only want to
|
| // prepare tiles _after_ draws. Polling for draw triggers and
|
| // begin-frame are mutually exclusive, so we limit to these two cases.
|
| - if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE &&
|
| + if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE &&
|
| !inside_poll_for_anticipated_draw_triggers_)
|
| return false;
|
| return needs_prepare_tiles_;
|
| @@ -503,38 +503,39 @@ bool SchedulerStateMachine::ShouldPrepareTiles() const {
|
|
|
| SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
|
| if (ShouldActivatePendingTree())
|
| - return ACTION_ACTIVATE_SYNC_TREE;
|
| + return Action::ACTIVATE_SYNC_TREE;
|
| if (ShouldCommit())
|
| - return ACTION_COMMIT;
|
| + return Action::COMMIT;
|
| if (ShouldAnimate())
|
| - return ACTION_ANIMATE;
|
| + return Action::ANIMATE;
|
| if (ShouldDraw()) {
|
| if (PendingDrawsShouldBeAborted())
|
| - return ACTION_DRAW_AND_SWAP_ABORT;
|
| - else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
|
| - return ACTION_DRAW_AND_SWAP_FORCED;
|
| + return Action::DRAW_AND_SWAP_ABORT;
|
| + else if (forced_redraw_state_ ==
|
| + ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
|
| + return Action::DRAW_AND_SWAP_FORCED;
|
| else
|
| - return ACTION_DRAW_AND_SWAP_IF_POSSIBLE;
|
| + return Action::DRAW_AND_SWAP_IF_POSSIBLE;
|
| }
|
| if (ShouldPrepareTiles())
|
| - return ACTION_PREPARE_TILES;
|
| + return Action::PREPARE_TILES;
|
| if (ShouldSendBeginMainFrame())
|
| - return ACTION_SEND_BEGIN_MAIN_FRAME;
|
| + return Action::SEND_BEGIN_MAIN_FRAME;
|
| if (ShouldBeginOutputSurfaceCreation())
|
| - return ACTION_BEGIN_OUTPUT_SURFACE_CREATION;
|
| - return ACTION_NONE;
|
| + return Action::BEGIN_OUTPUT_SURFACE_CREATION;
|
| + return Action::NONE;
|
| }
|
|
|
| void SchedulerStateMachine::UpdateState(Action action) {
|
| switch (action) {
|
| - case ACTION_NONE:
|
| + case Action::NONE:
|
| return;
|
|
|
| - case ACTION_ACTIVATE_SYNC_TREE:
|
| + case Action::ACTIVATE_SYNC_TREE:
|
| UpdateStateOnActivation();
|
| return;
|
|
|
| - case ACTION_ANIMATE:
|
| + case Action::ANIMATE:
|
| last_frame_number_animate_performed_ = current_frame_number_;
|
| needs_animate_ = false;
|
| did_commit_after_animating_ = false;
|
| @@ -543,48 +544,48 @@ void SchedulerStateMachine::UpdateState(Action action) {
|
| SetNeedsRedraw();
|
| return;
|
|
|
| - case ACTION_SEND_BEGIN_MAIN_FRAME:
|
| + case Action::SEND_BEGIN_MAIN_FRAME:
|
| DCHECK(!has_pending_tree_ ||
|
| settings_.main_frame_before_activation_enabled);
|
| DCHECK(visible_);
|
| - commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
|
| + commit_state_ = CommitState::BEGIN_MAIN_FRAME_SENT;
|
| needs_commit_ = false;
|
| last_frame_number_begin_main_frame_sent_ =
|
| current_frame_number_;
|
| return;
|
|
|
| - case ACTION_COMMIT: {
|
| + 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: {
|
| + 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: {
|
| + case Action::DRAW_AND_SWAP_ABORT: {
|
| bool did_request_swap = false;
|
| UpdateStateOnDraw(did_request_swap);
|
| return;
|
| }
|
|
|
| - case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
|
| - DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST);
|
| - output_surface_state_ = OUTPUT_SURFACE_CREATING;
|
| + case Action::BEGIN_OUTPUT_SURFACE_CREATION:
|
| + DCHECK_EQ(output_surface_state_, OutputSurfaceState::LOST);
|
| + output_surface_state_ = OutputSurfaceState::CREATING;
|
|
|
| // The following DCHECKs make sure we are in the proper quiescent state.
|
| // The pipeline should be flushed entirely before we start output
|
| // surface creation to avoid complicated corner cases.
|
| - DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE);
|
| + DCHECK_EQ(commit_state_, CommitState::IDLE);
|
| DCHECK(!has_pending_tree_);
|
| DCHECK(!active_tree_needs_first_draw_);
|
| return;
|
|
|
| - case ACTION_PREPARE_TILES:
|
| + case Action::PREPARE_TILES:
|
| UpdateStateOnPrepareTiles();
|
| return;
|
| }
|
| @@ -597,13 +598,13 @@ void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) {
|
| did_commit_after_animating_ = true;
|
|
|
| if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) {
|
| - commit_state_ = COMMIT_STATE_IDLE;
|
| + commit_state_ = CommitState::IDLE;
|
| } else if (settings_.impl_side_painting) {
|
| - commit_state_ = COMMIT_STATE_WAITING_FOR_ACTIVATION;
|
| + commit_state_ = CommitState::WAITING_FOR_ACTIVATION;
|
| } else {
|
| commit_state_ = settings_.main_thread_should_always_be_low_latency
|
| - ? COMMIT_STATE_WAITING_FOR_DRAW
|
| - : COMMIT_STATE_IDLE;
|
| + ? CommitState::WAITING_FOR_DRAW
|
| + : CommitState::IDLE;
|
| }
|
|
|
| // If we are impl-side-painting but the commit was aborted, then we behave
|
| @@ -611,19 +612,20 @@ void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) {
|
| has_pending_tree_ = settings_.impl_side_painting && !commit_has_no_updates;
|
|
|
| // Update state related to forced draws.
|
| - if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) {
|
| - forced_redraw_state_ = has_pending_tree_
|
| - ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION
|
| - : FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
|
| + if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT) {
|
| + forced_redraw_state_ =
|
| + has_pending_tree_ ? ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION
|
| + : ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW;
|
| }
|
|
|
| // Update the output surface state.
|
| - DCHECK_NE(output_surface_state_, OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION);
|
| - if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) {
|
| + DCHECK_NE(output_surface_state_,
|
| + OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION);
|
| + if (output_surface_state_ == OutputSurfaceState::WAITING_FOR_FIRST_COMMIT) {
|
| if (has_pending_tree_) {
|
| - output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION;
|
| + output_surface_state_ = OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION;
|
| } else {
|
| - output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
|
| + output_surface_state_ = OutputSurfaceState::ACTIVE;
|
| needs_redraw_ = true;
|
| }
|
| }
|
| @@ -632,7 +634,7 @@ void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) {
|
| // was unchanged but we need to do a forced draw.
|
| if (!has_pending_tree_ &&
|
| (!commit_has_no_updates ||
|
| - forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)) {
|
| + forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)) {
|
| needs_redraw_ = true;
|
| active_tree_needs_first_draw_ = true;
|
| }
|
| @@ -645,17 +647,18 @@ void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) {
|
| }
|
|
|
| void SchedulerStateMachine::UpdateStateOnActivation() {
|
| - if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION) {
|
| + if (commit_state_ == CommitState::WAITING_FOR_ACTIVATION) {
|
| commit_state_ = settings_.main_thread_should_always_be_low_latency
|
| - ? COMMIT_STATE_WAITING_FOR_DRAW
|
| - : COMMIT_STATE_IDLE;
|
| + ? CommitState::WAITING_FOR_DRAW
|
| + : CommitState::IDLE;
|
| }
|
|
|
| - if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION)
|
| - output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
|
| + if (output_surface_state_ == OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION)
|
| + output_surface_state_ = OutputSurfaceState::ACTIVE;
|
|
|
| - if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION)
|
| - forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
|
| + if (forced_redraw_state_ ==
|
| + ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION)
|
| + forced_redraw_state_ = ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW;
|
|
|
| has_pending_tree_ = false;
|
| pending_tree_is_ready_for_activation_ = false;
|
| @@ -664,11 +667,11 @@ void SchedulerStateMachine::UpdateStateOnActivation() {
|
| }
|
|
|
| void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) {
|
| - if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
|
| - forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
|
| + if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
|
| + forced_redraw_state_ = ForcedRedrawOnTimeoutState::IDLE;
|
|
|
| - if (commit_state_ == COMMIT_STATE_WAITING_FOR_DRAW)
|
| - commit_state_ = COMMIT_STATE_IDLE;
|
| + if (commit_state_ == CommitState::WAITING_FOR_DRAW)
|
| + commit_state_ = CommitState::IDLE;
|
|
|
| needs_redraw_ = false;
|
| active_tree_needs_first_draw_ = false;
|
| @@ -730,7 +733,7 @@ bool SchedulerStateMachine::ShouldSetNeedsBeginFrames(
|
| return true;
|
|
|
| // Stop requesting BeginFrames after a deadline.
|
| - if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
|
| + if (begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE)
|
| return true;
|
|
|
| // Stop requesting BeginFrames immediately when output surface is lost.
|
| @@ -774,7 +777,7 @@ void SchedulerStateMachine::SetChildrenNeedBeginFrames(
|
| bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const {
|
| // The forced draw respects our normal draw scheduling, so we need to
|
| // request a BeginImplFrame for it.
|
| - if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
|
| + if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
|
| return true;
|
|
|
| return needs_animate_ || needs_redraw_;
|
| @@ -791,7 +794,7 @@ bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
|
|
|
| // We should proactively request a BeginImplFrame if a commit is pending
|
| // because we will want to draw if the commit completes quickly.
|
| - if (needs_commit_ || commit_state_ != COMMIT_STATE_IDLE)
|
| + if (needs_commit_ || commit_state_ != CommitState::IDLE)
|
| return true;
|
|
|
| // If the pending tree activates quickly, we'll want a BeginImplFrame soon
|
| @@ -818,44 +821,43 @@ bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
|
| void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) {
|
| AdvanceCurrentFrameNumber();
|
| begin_impl_frame_args_ = args;
|
| - DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE)
|
| + DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::IDLE)
|
| << AsValue()->ToString();
|
| - begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING;
|
| + begin_impl_frame_state_ = BeginImplFrameState::BEGIN_FRAME_STARTING;
|
| }
|
|
|
| void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() {
|
| - DCHECK_EQ(begin_impl_frame_state_,
|
| - BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING)
|
| + DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::BEGIN_FRAME_STARTING)
|
| << AsValue()->ToString();
|
| - begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME;
|
| + begin_impl_frame_state_ = BeginImplFrameState::INSIDE_BEGIN_FRAME;
|
| }
|
|
|
| void SchedulerStateMachine::OnBeginImplFrameDeadline() {
|
| - DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)
|
| + DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::INSIDE_BEGIN_FRAME)
|
| << AsValue()->ToString();
|
| - begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
|
| + begin_impl_frame_state_ = BeginImplFrameState::INSIDE_DEADLINE;
|
| }
|
|
|
| void SchedulerStateMachine::OnBeginImplFrameIdle() {
|
| - DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
|
| + DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::INSIDE_DEADLINE)
|
| << AsValue()->ToString();
|
| - begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE;
|
| + begin_impl_frame_state_ = BeginImplFrameState::IDLE;
|
| }
|
|
|
| SchedulerStateMachine::BeginImplFrameDeadlineMode
|
| SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
|
| if (ShouldTriggerBeginImplFrameDeadlineImmediately()) {
|
| - return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE;
|
| + return BeginImplFrameDeadlineMode::IMMEDIATE;
|
| } else if (needs_redraw_ && pending_swaps_ < max_pending_swaps_) {
|
| // We have an animation or fast input path on the impl thread that wants
|
| // to draw, so don't wait too long for a new active tree.
|
| // If we are swap throttled we should wait until we are unblocked.
|
| - return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR;
|
| + return BeginImplFrameDeadlineMode::REGULAR;
|
| } else {
|
| // The impl thread doesn't have anything it wants to draw and we are just
|
| // waiting for a new active tree or we are swap throttled. In short we are
|
| // blocked.
|
| - return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE;
|
| + return BeginImplFrameDeadlineMode::LATE;
|
| }
|
| }
|
|
|
| @@ -863,12 +865,12 @@ bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
|
| const {
|
| // TODO(brianderson): This should take into account multiple commit sources.
|
|
|
| - if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)
|
| + if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_BEGIN_FRAME)
|
| return false;
|
|
|
| // If we've lost the output surface, end the current BeginImplFrame ASAP
|
| // so we can start creating the next output surface.
|
| - if (output_surface_state_ == OUTPUT_SURFACE_LOST)
|
| + if (output_surface_state_ == OutputSurfaceState::LOST)
|
| return true;
|
|
|
| // SwapAck throttle the deadline since we wont draw and swap anyway.
|
| @@ -886,7 +888,7 @@ bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
|
| // don't have a pending tree -- otherwise we should give it a chance to
|
| // activate.
|
| // TODO(skyostil): Revisit this when we have more accurate deadline estimates.
|
| - if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_)
|
| + if (commit_state_ == CommitState::IDLE && !has_pending_tree_)
|
| return true;
|
|
|
| // Prioritize impl-thread draws in impl_latency_takes_priority_ mode.
|
| @@ -910,8 +912,8 @@ bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const {
|
| // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main
|
| // thread is in a low latency mode.
|
| if (HasSentBeginMainFrameThisFrame() &&
|
| - (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING ||
|
| - begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME))
|
| + (begin_impl_frame_state_ == BeginImplFrameState::BEGIN_FRAME_STARTING ||
|
| + begin_impl_frame_state_ == BeginImplFrameState::INSIDE_BEGIN_FRAME))
|
| return false;
|
|
|
| // If there's a commit in progress it must either be from the previous frame
|
| @@ -929,7 +931,7 @@ bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const {
|
| if (has_pending_tree_)
|
| return true;
|
|
|
| - if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) {
|
| + if (begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE) {
|
| // Even if there's a new active tree to draw at the deadline or we've just
|
| // swapped it, it may have been triggered by a previous BeginImplFrame, in
|
| // which case the main thread is in a high latency mode.
|
| @@ -1001,14 +1003,14 @@ void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
|
| break;
|
| case DRAW_SUCCESS:
|
| consecutive_checkerboard_animations_ = 0;
|
| - forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
|
| + forced_redraw_state_ = ForcedRedrawOnTimeoutState::IDLE;
|
| break;
|
| case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS:
|
| needs_redraw_ = true;
|
|
|
| // If we're already in the middle of a redraw, we don't need to
|
| // restart it.
|
| - if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE)
|
| + if (forced_redraw_state_ != ForcedRedrawOnTimeoutState::IDLE)
|
| return;
|
|
|
| needs_commit_ = true;
|
| @@ -1019,7 +1021,7 @@ void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
|
| consecutive_checkerboard_animations_ = 0;
|
| // We need to force a draw, but it doesn't make sense to do this until
|
| // we've committed and have new textures.
|
| - forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT;
|
| + forced_redraw_state_ = ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT;
|
| }
|
| break;
|
| case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT:
|
| @@ -1037,9 +1039,9 @@ void SchedulerStateMachine::SetNeedsCommit() {
|
| }
|
|
|
| void SchedulerStateMachine::NotifyReadyToCommit() {
|
| - DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED)
|
| + DCHECK(commit_state_ == CommitState::BEGIN_MAIN_FRAME_STARTED)
|
| << AsValue()->ToString();
|
| - commit_state_ = COMMIT_STATE_READY_TO_COMMIT;
|
| + commit_state_ = CommitState::READY_TO_COMMIT;
|
| // In main thread low latency mode, commit should happen right after
|
| // BeginFrame, meaning when this function is called, next action should be
|
| // commit.
|
| @@ -1048,11 +1050,11 @@ void SchedulerStateMachine::NotifyReadyToCommit() {
|
| }
|
|
|
| void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
|
| - DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
|
| + DCHECK_EQ(commit_state_, CommitState::BEGIN_MAIN_FRAME_SENT);
|
| switch (reason) {
|
| case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST:
|
| case CommitEarlyOutReason::ABORTED_NOT_VISIBLE:
|
| - commit_state_ = COMMIT_STATE_IDLE;
|
| + commit_state_ = CommitState::IDLE;
|
| SetNeedsCommit();
|
| return;
|
| case CommitEarlyOutReason::FINISHED_NO_UPDATES:
|
| @@ -1069,10 +1071,10 @@ void SchedulerStateMachine::DidPrepareTiles() {
|
| }
|
|
|
| void SchedulerStateMachine::DidLoseOutputSurface() {
|
| - if (output_surface_state_ == OUTPUT_SURFACE_LOST ||
|
| - output_surface_state_ == OUTPUT_SURFACE_CREATING)
|
| + if (output_surface_state_ == OutputSurfaceState::LOST ||
|
| + output_surface_state_ == OutputSurfaceState::CREATING)
|
| return;
|
| - output_surface_state_ = OUTPUT_SURFACE_LOST;
|
| + output_surface_state_ = OutputSurfaceState::LOST;
|
| needs_redraw_ = false;
|
| }
|
|
|
| @@ -1082,8 +1084,8 @@ void SchedulerStateMachine::NotifyReadyToActivate() {
|
| }
|
|
|
| void SchedulerStateMachine::DidCreateAndInitializeOutputSurface() {
|
| - DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_CREATING);
|
| - output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT;
|
| + DCHECK_EQ(output_surface_state_, OutputSurfaceState::CREATING);
|
| + output_surface_state_ = OutputSurfaceState::WAITING_FOR_FIRST_COMMIT;
|
|
|
| if (did_create_and_initialize_first_output_surface_) {
|
| // TODO(boliu): See if we can remove this when impl-side painting is always
|
| @@ -1095,19 +1097,19 @@ void SchedulerStateMachine::DidCreateAndInitializeOutputSurface() {
|
| }
|
|
|
| void SchedulerStateMachine::NotifyBeginMainFrameStarted() {
|
| - DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
|
| - commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED;
|
| + DCHECK_EQ(commit_state_, CommitState::BEGIN_MAIN_FRAME_SENT);
|
| + commit_state_ = CommitState::BEGIN_MAIN_FRAME_STARTED;
|
| }
|
|
|
| bool SchedulerStateMachine::HasInitializedOutputSurface() const {
|
| switch (output_surface_state_) {
|
| - case OUTPUT_SURFACE_LOST:
|
| - case OUTPUT_SURFACE_CREATING:
|
| + case OutputSurfaceState::LOST:
|
| + case OutputSurfaceState::CREATING:
|
| return false;
|
|
|
| - case OUTPUT_SURFACE_ACTIVE:
|
| - case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
|
| - case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
|
| + case OutputSurfaceState::ACTIVE:
|
| + case OutputSurfaceState::WAITING_FOR_FIRST_COMMIT:
|
| + case OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION:
|
| return true;
|
| }
|
| NOTREACHED();
|
|
|