Commit a237dea3 authored by Xunran Ding's avatar Xunran Ding Committed by Commit Bot

Convert scheduler states enums to enum class

The cc/scheduler/scheduler_state_machine uses a lot of enums.
enums are not real types and hence have subtle problems.
C++ introduced the concept of "enum class" types which would
be better replacements.

BUG=440759

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I12ce9ee05b668bee5c2f84bbe522edd741d2bd56
Reviewed-on: https://chromium-review.googlesource.com/709094
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520959}
parent f05f36fd
...@@ -856,6 +856,7 @@ Xu Xing <xing.xu@intel.com> ...@@ -856,6 +856,7 @@ Xu Xing <xing.xu@intel.com>
Xuefei Ren <xrenishere@gmail.com> Xuefei Ren <xrenishere@gmail.com>
Xueqing Huang <huangxueqing@xiaomi.com> Xueqing Huang <huangxueqing@xiaomi.com>
Xun Sun <xun.sun@intel.com> Xun Sun <xun.sun@intel.com>
Xunran Ding <dingxunran@gmail.com>
Yael Aharon <yael.aharon@intel.com> Yael Aharon <yael.aharon@intel.com>
Yair Yogev <progame@chromium.org> Yair Yogev <progame@chromium.org>
Yan Wang <yan0422.wang@samsung.com> Yan Wang <yan0422.wang@samsung.com>
......
...@@ -122,7 +122,7 @@ void Scheduler::SetNeedsRedraw() { ...@@ -122,7 +122,7 @@ void Scheduler::SetNeedsRedraw() {
} }
void Scheduler::SetNeedsPrepareTiles() { void Scheduler::SetNeedsPrepareTiles() {
DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_PREPARE_TILES)); DCHECK(!IsInsideAction(SchedulerStateMachine::Action::PREPARE_TILES));
state_machine_.SetNeedsPrepareTiles(); state_machine_.SetNeedsPrepareTiles();
ProcessScheduledActions(); ProcessScheduledActions();
} }
...@@ -134,7 +134,7 @@ void Scheduler::DidSubmitCompositorFrame() { ...@@ -134,7 +134,7 @@ void Scheduler::DidSubmitCompositorFrame() {
// There is no need to call ProcessScheduledActions here because // There is no need to call ProcessScheduledActions here because
// submitting a CompositorFrame should not trigger any new actions. // submitting a CompositorFrame should not trigger any new actions.
if (!inside_process_scheduled_actions_) { if (!inside_process_scheduled_actions_) {
DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::Action::NONE);
} }
} }
...@@ -228,7 +228,7 @@ void Scheduler::BeginImplFrameNotExpectedSoon() { ...@@ -228,7 +228,7 @@ void Scheduler::BeginImplFrameNotExpectedSoon() {
void Scheduler::SetupNextBeginFrameIfNeeded() { void Scheduler::SetupNextBeginFrameIfNeeded() {
if (state_machine_.begin_impl_frame_state() != if (state_machine_.begin_impl_frame_state() !=
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { SchedulerStateMachine::BeginImplFrameState::IDLE) {
return; return;
} }
...@@ -319,7 +319,7 @@ void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { ...@@ -319,7 +319,7 @@ void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) {
void Scheduler::OnDrawForLayerTreeFrameSink(bool resourceless_software_draw) { void Scheduler::OnDrawForLayerTreeFrameSink(bool resourceless_software_draw) {
DCHECK(settings_.using_synchronous_renderer_compositor); DCHECK(settings_.using_synchronous_renderer_compositor);
DCHECK_EQ(state_machine_.begin_impl_frame_state(), DCHECK_EQ(state_machine_.begin_impl_frame_state(),
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); SchedulerStateMachine::BeginImplFrameState::IDLE);
DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
state_machine_.SetResourcelessSoftwareDraw(resourceless_software_draw); state_machine_.SetResourcelessSoftwareDraw(resourceless_software_draw);
...@@ -355,7 +355,7 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) { ...@@ -355,7 +355,7 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) {
// Run the previous deadline if any. // Run the previous deadline if any.
if (state_machine_.begin_impl_frame_state() == if (state_machine_.begin_impl_frame_state() ==
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) { SchedulerStateMachine::BeginImplFrameState::INSIDE_BEGIN_FRAME) {
OnBeginImplFrameDeadline(); OnBeginImplFrameDeadline();
// We may not need begin frames any longer. // We may not need begin frames any longer.
if (!observing_begin_frame_source_) { if (!observing_begin_frame_source_) {
...@@ -365,7 +365,7 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) { ...@@ -365,7 +365,7 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) {
} }
} }
DCHECK_EQ(state_machine_.begin_impl_frame_state(), DCHECK_EQ(state_machine_.begin_impl_frame_state(),
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); SchedulerStateMachine::BeginImplFrameState::IDLE);
bool main_thread_is_in_high_latency_mode = bool main_thread_is_in_high_latency_mode =
state_machine_.main_thread_missed_last_deadline(); state_machine_.main_thread_missed_last_deadline();
...@@ -376,7 +376,7 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) { ...@@ -376,7 +376,7 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) {
"MainThreadLatency", main_thread_is_in_high_latency_mode); "MainThreadLatency", main_thread_is_in_high_latency_mode);
DCHECK_EQ(state_machine_.begin_impl_frame_state(), DCHECK_EQ(state_machine_.begin_impl_frame_state(),
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); SchedulerStateMachine::BeginImplFrameState::IDLE);
adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate(); adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate();
adjusted_args.deadline -= kDeadlineFudgeFactor; adjusted_args.deadline -= kDeadlineFudgeFactor;
...@@ -392,10 +392,10 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) { ...@@ -392,10 +392,10 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) {
compositor_timing_history_->BeginMainFrameQueueDurationCriticalEstimate(); compositor_timing_history_->BeginMainFrameQueueDurationCriticalEstimate();
// TODO(khushalsagar): We need to consider the deadline fudge factor here to // TODO(khushalsagar): We need to consider the deadline fudge factor here to
// match the deadline used in BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR mode // match the deadline used in BeginImplFrameDeadlineMode::REGULAR mode
// (used in the case where the impl thread needs to redraw). In the case where // (used in the case where the impl thread needs to redraw). In the case where
// main_frame_to_active is fast, we should consider using // main_frame_to_active is fast, we should consider using
// BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE instead to avoid putting the main // BeginImplFrameDeadlineMode::LATE instead to avoid putting the main
// thread in high latency mode. See crbug.com/753146. // thread in high latency mode. See crbug.com/753146.
base::TimeDelta bmf_to_activate_threshold = base::TimeDelta bmf_to_activate_threshold =
adjusted_args.interval - adjusted_args.interval -
...@@ -484,7 +484,7 @@ void Scheduler::SendBeginFrameAck(const viz::BeginFrameArgs& args, ...@@ -484,7 +484,7 @@ void Scheduler::SendBeginFrameAck(const viz::BeginFrameArgs& args,
void Scheduler::BeginImplFrame(const viz::BeginFrameArgs& args, void Scheduler::BeginImplFrame(const viz::BeginFrameArgs& args,
base::TimeTicks now) { base::TimeTicks now) {
DCHECK_EQ(state_machine_.begin_impl_frame_state(), DCHECK_EQ(state_machine_.begin_impl_frame_state(),
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); SchedulerStateMachine::BeginImplFrameState::IDLE);
DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
DCHECK(state_machine_.HasInitializedLayerTreeFrameSink()); DCHECK(state_machine_.HasInitializedLayerTreeFrameSink());
...@@ -508,26 +508,26 @@ void Scheduler::ScheduleBeginImplFrameDeadline() { ...@@ -508,26 +508,26 @@ void Scheduler::ScheduleBeginImplFrameDeadline() {
begin_impl_frame_deadline_mode_ = begin_impl_frame_deadline_mode_ =
state_machine_.CurrentBeginImplFrameDeadlineMode(); state_machine_.CurrentBeginImplFrameDeadlineMode();
switch (begin_impl_frame_deadline_mode_) { switch (begin_impl_frame_deadline_mode_) {
case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE: case SchedulerStateMachine::BeginImplFrameDeadlineMode::NONE:
// No deadline. // No deadline.
return; return;
case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: case SchedulerStateMachine::BeginImplFrameDeadlineMode::IMMEDIATE:
// We are ready to draw a new active tree immediately. // We are ready to draw a new active tree immediately.
// We don't use Now() here because it's somewhat expensive to call. // We don't use Now() here because it's somewhat expensive to call.
deadline_ = base::TimeTicks(); deadline_ = base::TimeTicks();
break; break;
case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: case SchedulerStateMachine::BeginImplFrameDeadlineMode::REGULAR:
// We are animating on the impl thread but we can wait for some time. // We are animating on the impl thread but we can wait for some time.
deadline_ = begin_impl_frame_tracker_.Current().deadline; deadline_ = begin_impl_frame_tracker_.Current().deadline;
break; break;
case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: case SchedulerStateMachine::BeginImplFrameDeadlineMode::LATE:
// We are blocked for one reason or another and we should wait. // We are blocked for one reason or another and we should wait.
// TODO(brianderson): Handle long deadlines (that are past the next // TODO(brianderson): Handle long deadlines (that are past the next
// frame's frame time) properly instead of using this hack. // frame's frame time) properly instead of using this hack.
deadline_ = begin_impl_frame_tracker_.Current().frame_time + deadline_ = begin_impl_frame_tracker_.Current().frame_time +
begin_impl_frame_tracker_.Current().interval; begin_impl_frame_tracker_.Current().interval;
break; break;
case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED: case SchedulerStateMachine::BeginImplFrameDeadlineMode::BLOCKED:
// We are blocked because we are waiting for ReadyToDraw signal. We would // We are blocked because we are waiting for ReadyToDraw signal. We would
// post deadline after we received ReadyToDraw singal. // post deadline after we received ReadyToDraw singal.
TRACE_EVENT1("cc", "Scheduler::ScheduleBeginImplFrameDeadline", TRACE_EVENT1("cc", "Scheduler::ScheduleBeginImplFrameDeadline",
...@@ -552,7 +552,7 @@ void Scheduler::ScheduleBeginImplFrameDeadlineIfNeeded() { ...@@ -552,7 +552,7 @@ void Scheduler::ScheduleBeginImplFrameDeadlineIfNeeded() {
return; return;
if (state_machine_.begin_impl_frame_state() != if (state_machine_.begin_impl_frame_state() !=
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) SchedulerStateMachine::BeginImplFrameState::INSIDE_BEGIN_FRAME)
return; return;
if (begin_impl_frame_deadline_mode_ == if (begin_impl_frame_deadline_mode_ ==
...@@ -645,9 +645,9 @@ void Scheduler::ProcessScheduledActions() { ...@@ -645,9 +645,9 @@ void Scheduler::ProcessScheduledActions() {
base::AutoReset<SchedulerStateMachine::Action> mark_inside_action( base::AutoReset<SchedulerStateMachine::Action> mark_inside_action(
&inside_action_, action); &inside_action_, action);
switch (action) { switch (action) {
case SchedulerStateMachine::ACTION_NONE: case SchedulerStateMachine::Action::NONE:
break; break;
case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: case SchedulerStateMachine::Action::SEND_BEGIN_MAIN_FRAME:
compositor_timing_history_->WillBeginMainFrame( compositor_timing_history_->WillBeginMainFrame(
begin_main_frame_args_.on_critical_path, begin_main_frame_args_.on_critical_path,
begin_main_frame_args_.frame_time); begin_main_frame_args_.frame_time);
...@@ -655,7 +655,7 @@ void Scheduler::ProcessScheduledActions() { ...@@ -655,7 +655,7 @@ void Scheduler::ProcessScheduledActions() {
// TODO(brianderson): Pass begin_main_frame_args_ directly to client. // TODO(brianderson): Pass begin_main_frame_args_ directly to client.
client_->ScheduledActionSendBeginMainFrame(begin_main_frame_args_); client_->ScheduledActionSendBeginMainFrame(begin_main_frame_args_);
break; break;
case SchedulerStateMachine::ACTION_NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT: case SchedulerStateMachine::Action::NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT:
state_machine_.WillNotifyBeginMainFrameNotSent(); state_machine_.WillNotifyBeginMainFrameNotSent();
// If SendBeginMainFrameNotExpectedSoon was not previously sent by // If SendBeginMainFrameNotExpectedSoon was not previously sent by
// BeginImplFrameNotExpectedSoon (because the messages were not required // BeginImplFrameNotExpectedSoon (because the messages were not required
...@@ -667,51 +667,51 @@ void Scheduler::ProcessScheduledActions() { ...@@ -667,51 +667,51 @@ void Scheduler::ProcessScheduledActions() {
begin_main_frame_args_.interval); begin_main_frame_args_.interval);
} }
break; break;
case SchedulerStateMachine::ACTION_COMMIT: { case SchedulerStateMachine::Action::COMMIT: {
bool commit_has_no_updates = false; bool commit_has_no_updates = false;
state_machine_.WillCommit(commit_has_no_updates); state_machine_.WillCommit(commit_has_no_updates);
client_->ScheduledActionCommit(); client_->ScheduledActionCommit();
break; break;
} }
case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: case SchedulerStateMachine::Action::ACTIVATE_SYNC_TREE:
compositor_timing_history_->WillActivate(); compositor_timing_history_->WillActivate();
state_machine_.WillActivate(); state_machine_.WillActivate();
client_->ScheduledActionActivateSyncTree(); client_->ScheduledActionActivateSyncTree();
compositor_timing_history_->DidActivate(); compositor_timing_history_->DidActivate();
break; break;
case SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION: case SchedulerStateMachine::Action::PERFORM_IMPL_SIDE_INVALIDATION:
state_machine_.WillPerformImplSideInvalidation(); state_machine_.WillPerformImplSideInvalidation();
compositor_timing_history_->WillInvalidateOnImplSide(); compositor_timing_history_->WillInvalidateOnImplSide();
client_->ScheduledActionPerformImplSideInvalidation(); client_->ScheduledActionPerformImplSideInvalidation();
break; break;
case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: case SchedulerStateMachine::Action::DRAW_IF_POSSIBLE:
DrawIfPossible(); DrawIfPossible();
break; break;
case SchedulerStateMachine::ACTION_DRAW_FORCED: case SchedulerStateMachine::Action::DRAW_FORCED:
DrawForced(); DrawForced();
break; break;
case SchedulerStateMachine::ACTION_DRAW_ABORT: { case SchedulerStateMachine::Action::DRAW_ABORT: {
// No action is actually performed, but this allows the state machine to // No action is actually performed, but this allows the state machine to
// drain the pipeline without actually drawing. // drain the pipeline without actually drawing.
state_machine_.AbortDraw(); state_machine_.AbortDraw();
compositor_timing_history_->DrawAborted(); compositor_timing_history_->DrawAborted();
break; break;
} }
case SchedulerStateMachine::ACTION_BEGIN_LAYER_TREE_FRAME_SINK_CREATION: case SchedulerStateMachine::Action::BEGIN_LAYER_TREE_FRAME_SINK_CREATION:
state_machine_.WillBeginLayerTreeFrameSinkCreation(); state_machine_.WillBeginLayerTreeFrameSinkCreation();
client_->ScheduledActionBeginLayerTreeFrameSinkCreation(); client_->ScheduledActionBeginLayerTreeFrameSinkCreation();
break; break;
case SchedulerStateMachine::ACTION_PREPARE_TILES: case SchedulerStateMachine::Action::PREPARE_TILES:
state_machine_.WillPrepareTiles(); state_machine_.WillPrepareTiles();
client_->ScheduledActionPrepareTiles(); client_->ScheduledActionPrepareTiles();
break; break;
case SchedulerStateMachine::ACTION_INVALIDATE_LAYER_TREE_FRAME_SINK: { case SchedulerStateMachine::Action::INVALIDATE_LAYER_TREE_FRAME_SINK: {
state_machine_.WillInvalidateLayerTreeFrameSink(); state_machine_.WillInvalidateLayerTreeFrameSink();
client_->ScheduledActionInvalidateLayerTreeFrameSink(); client_->ScheduledActionInvalidateLayerTreeFrameSink();
break; break;
} }
} }
} while (action != SchedulerStateMachine::ACTION_NONE); } while (action != SchedulerStateMachine::Action::NONE);
ScheduleBeginImplFrameDeadlineIfNeeded(); ScheduleBeginImplFrameDeadlineIfNeeded();
SetupNextBeginFrameIfNeeded(); SetupNextBeginFrameIfNeeded();
...@@ -876,9 +876,9 @@ bool Scheduler::CanBeginMainFrameAndActivateBeforeDeadline( ...@@ -876,9 +876,9 @@ bool Scheduler::CanBeginMainFrameAndActivateBeforeDeadline(
bool Scheduler::IsBeginMainFrameSentOrStarted() const { bool Scheduler::IsBeginMainFrameSentOrStarted() const {
return (state_machine_.begin_main_frame_state() == return (state_machine_.begin_main_frame_state() ==
SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || SchedulerStateMachine::BeginMainFrameState::SENT ||
state_machine_.begin_main_frame_state() == state_machine_.begin_main_frame_state() ==
SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); SchedulerStateMachine::BeginMainFrameState::STARTED);
} }
viz::BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const { viz::BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const {
......
...@@ -189,7 +189,7 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase { ...@@ -189,7 +189,7 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase {
SchedulerStateMachine::BeginImplFrameDeadlineMode SchedulerStateMachine::BeginImplFrameDeadlineMode
begin_impl_frame_deadline_mode_ = begin_impl_frame_deadline_mode_ =
SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; SchedulerStateMachine::BeginImplFrameDeadlineMode::NONE;
base::TimeTicks deadline_; base::TimeTicks deadline_;
base::TimeTicks deadline_scheduled_at_; base::TimeTicks deadline_scheduled_at_;
...@@ -203,7 +203,7 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase { ...@@ -203,7 +203,7 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase {
SchedulerStateMachine state_machine_; SchedulerStateMachine state_machine_;
bool inside_process_scheduled_actions_ = false; bool inside_process_scheduled_actions_ = false;
SchedulerStateMachine::Action inside_action_ = SchedulerStateMachine::Action inside_action_ =
SchedulerStateMachine::ACTION_NONE; SchedulerStateMachine::Action::NONE;
bool stopped_ = false; bool stopped_ = false;
......
...@@ -25,16 +25,16 @@ SchedulerStateMachine::~SchedulerStateMachine() = default; ...@@ -25,16 +25,16 @@ SchedulerStateMachine::~SchedulerStateMachine() = default;
const char* SchedulerStateMachine::LayerTreeFrameSinkStateToString( const char* SchedulerStateMachine::LayerTreeFrameSinkStateToString(
LayerTreeFrameSinkState state) { LayerTreeFrameSinkState state) {
switch (state) { switch (state) {
case LAYER_TREE_FRAME_SINK_NONE: case LayerTreeFrameSinkState::NONE:
return "LAYER_TREE_FRAME_SINK_NONE"; return "LayerTreeFrameSinkState::NONE";
case LAYER_TREE_FRAME_SINK_ACTIVE: case LayerTreeFrameSinkState::ACTIVE:
return "LAYER_TREE_FRAME_SINK_ACTIVE"; return "LayerTreeFrameSinkState::ACTIVE";
case LAYER_TREE_FRAME_SINK_CREATING: case LayerTreeFrameSinkState::CREATING:
return "LAYER_TREE_FRAME_SINK_CREATING"; return "LayerTreeFrameSinkState::CREATING";
case LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: case LayerTreeFrameSinkState::WAITING_FOR_FIRST_COMMIT:
return "LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_COMMIT"; return "LayerTreeFrameSinkState::WAITING_FOR_FIRST_COMMIT";
case LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: case LayerTreeFrameSinkState::WAITING_FOR_FIRST_ACTIVATION:
return "LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION"; return "LayerTreeFrameSinkState::WAITING_FOR_FIRST_ACTIVATION";
} }
NOTREACHED(); NOTREACHED();
return "???"; return "???";
...@@ -43,12 +43,12 @@ const char* SchedulerStateMachine::LayerTreeFrameSinkStateToString( ...@@ -43,12 +43,12 @@ const char* SchedulerStateMachine::LayerTreeFrameSinkStateToString(
const char* SchedulerStateMachine::BeginImplFrameStateToString( const char* SchedulerStateMachine::BeginImplFrameStateToString(
BeginImplFrameState state) { BeginImplFrameState state) {
switch (state) { switch (state) {
case BEGIN_IMPL_FRAME_STATE_IDLE: case BeginImplFrameState::IDLE:
return "BEGIN_IMPL_FRAME_STATE_IDLE"; return "BeginImplFrameState::IDLE";
case BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME: case BeginImplFrameState::INSIDE_BEGIN_FRAME:
return "BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME"; return "BeginImplFrameState::INSIDE_BEGIN_FRAME";
case BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE: case BeginImplFrameState::INSIDE_DEADLINE:
return "BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE"; return "BeginImplFrameState::INSIDE_DEADLINE";
} }
NOTREACHED(); NOTREACHED();
return "???"; return "???";
...@@ -57,16 +57,16 @@ const char* SchedulerStateMachine::BeginImplFrameStateToString( ...@@ -57,16 +57,16 @@ const char* SchedulerStateMachine::BeginImplFrameStateToString(
const char* SchedulerStateMachine::BeginImplFrameDeadlineModeToString( const char* SchedulerStateMachine::BeginImplFrameDeadlineModeToString(
BeginImplFrameDeadlineMode mode) { BeginImplFrameDeadlineMode mode) {
switch (mode) { switch (mode) {
case BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE: case BeginImplFrameDeadlineMode::NONE:
return "BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE"; return "BeginImplFrameDeadlineMode::NONE";
case BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: case BeginImplFrameDeadlineMode::IMMEDIATE:
return "BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE"; return "BeginImplFrameDeadlineMode::IMMEDIATE";
case BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: case BeginImplFrameDeadlineMode::REGULAR:
return "BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR"; return "BeginImplFrameDeadlineMode::REGULAR";
case BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: case BeginImplFrameDeadlineMode::LATE:
return "BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE"; return "BeginImplFrameDeadlineMode::LATE";
case BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED: case BeginImplFrameDeadlineMode::BLOCKED:
return "BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED"; return "BeginImplFrameDeadlineMode::BLOCKED";
} }
NOTREACHED(); NOTREACHED();
return "???"; return "???";
...@@ -75,14 +75,14 @@ const char* SchedulerStateMachine::BeginImplFrameDeadlineModeToString( ...@@ -75,14 +75,14 @@ const char* SchedulerStateMachine::BeginImplFrameDeadlineModeToString(
const char* SchedulerStateMachine::BeginMainFrameStateToString( const char* SchedulerStateMachine::BeginMainFrameStateToString(
BeginMainFrameState state) { BeginMainFrameState state) {
switch (state) { switch (state) {
case BEGIN_MAIN_FRAME_STATE_IDLE: case BeginMainFrameState::IDLE:
return "BEGIN_MAIN_FRAME_STATE_IDLE"; return "BeginMainFrameState::IDLE";
case BEGIN_MAIN_FRAME_STATE_SENT: case BeginMainFrameState::SENT:
return "BEGIN_MAIN_FRAME_STATE_SENT"; return "BeginMainFrameState::SENT";
case BEGIN_MAIN_FRAME_STATE_STARTED: case BeginMainFrameState::STARTED:
return "BEGIN_MAIN_FRAME_STATE_STARTED"; return "BeginMainFrameState::STARTED";
case BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT: case BeginMainFrameState::READY_TO_COMMIT:
return "BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT"; return "BeginMainFrameState::READY_TO_COMMIT";
} }
NOTREACHED(); NOTREACHED();
return "???"; return "???";
...@@ -91,14 +91,14 @@ const char* SchedulerStateMachine::BeginMainFrameStateToString( ...@@ -91,14 +91,14 @@ const char* SchedulerStateMachine::BeginMainFrameStateToString(
const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
ForcedRedrawOnTimeoutState state) { ForcedRedrawOnTimeoutState state) {
switch (state) { switch (state) {
case FORCED_REDRAW_STATE_IDLE: case ForcedRedrawOnTimeoutState::IDLE:
return "FORCED_REDRAW_STATE_IDLE"; return "ForcedRedrawOnTimeoutState::IDLE";
case FORCED_REDRAW_STATE_WAITING_FOR_COMMIT: case ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT:
return "FORCED_REDRAW_STATE_WAITING_FOR_COMMIT"; return "ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT";
case FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION: case ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION:
return "FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION"; return "ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION";
case FORCED_REDRAW_STATE_WAITING_FOR_DRAW: case ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW:
return "FORCED_REDRAW_STATE_WAITING_FOR_DRAW"; return "ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW";
} }
NOTREACHED(); NOTREACHED();
return "???"; return "???";
...@@ -117,30 +117,30 @@ const char* ScrollHandlerStateToString(ScrollHandlerState state) { ...@@ -117,30 +117,30 @@ const char* ScrollHandlerStateToString(ScrollHandlerState state) {
const char* SchedulerStateMachine::ActionToString(Action action) { const char* SchedulerStateMachine::ActionToString(Action action) {
switch (action) { switch (action) {
case ACTION_NONE: case Action::NONE:
return "ACTION_NONE"; return "Action::NONE";
case ACTION_SEND_BEGIN_MAIN_FRAME: case Action::SEND_BEGIN_MAIN_FRAME:
return "ACTION_SEND_BEGIN_MAIN_FRAME"; return "Action::SEND_BEGIN_MAIN_FRAME";
case ACTION_COMMIT: case Action::COMMIT:
return "ACTION_COMMIT"; return "Action::COMMIT";
case ACTION_ACTIVATE_SYNC_TREE: case Action::ACTIVATE_SYNC_TREE:
return "ACTION_ACTIVATE_SYNC_TREE"; return "Action::ACTIVATE_SYNC_TREE";
case ACTION_DRAW_IF_POSSIBLE: case Action::DRAW_IF_POSSIBLE:
return "ACTION_DRAW_IF_POSSIBLE"; return "Action::DRAW_IF_POSSIBLE";
case ACTION_DRAW_FORCED: case Action::DRAW_FORCED:
return "ACTION_DRAW_FORCED"; return "Action::DRAW_FORCED";
case ACTION_DRAW_ABORT: case Action::DRAW_ABORT:
return "ACTION_DRAW_ABORT"; return "Action::DRAW_ABORT";
case ACTION_BEGIN_LAYER_TREE_FRAME_SINK_CREATION: case Action::BEGIN_LAYER_TREE_FRAME_SINK_CREATION:
return "ACTION_BEGIN_LAYER_TREE_FRAME_SINK_CREATION"; return "Action::BEGIN_LAYER_TREE_FRAME_SINK_CREATION";
case ACTION_PREPARE_TILES: case Action::PREPARE_TILES:
return "ACTION_PREPARE_TILES"; return "Action::PREPARE_TILES";
case ACTION_INVALIDATE_LAYER_TREE_FRAME_SINK: case Action::INVALIDATE_LAYER_TREE_FRAME_SINK:
return "ACTION_INVALIDATE_LAYER_TREE_FRAME_SINK"; return "Action::INVALIDATE_LAYER_TREE_FRAME_SINK";
case ACTION_PERFORM_IMPL_SIDE_INVALIDATION: case Action::PERFORM_IMPL_SIDE_INVALIDATION:
return "ACTION_PERFORM_IMPL_SIDE_INVALIDATION"; return "Action::PERFORM_IMPL_SIDE_INVALIDATION";
case ACTION_NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT: case Action::NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT:
return "ACTION_NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT"; return "Action::NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT";
} }
NOTREACHED(); NOTREACHED();
return "???"; return "???";
...@@ -242,7 +242,7 @@ bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { ...@@ -242,7 +242,7 @@ bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
// when the embedder is Android WebView, software draws could be scheduled by // when the embedder is Android WebView, software draws could be scheduled by
// the Android OS at any time and draws should not be aborted in this case. // the Android OS at any time and draws should not be aborted in this case.
bool is_layer_tree_frame_sink_lost = bool is_layer_tree_frame_sink_lost =
(layer_tree_frame_sink_state_ == LAYER_TREE_FRAME_SINK_NONE); (layer_tree_frame_sink_state_ == LayerTreeFrameSinkState::NONE);
if (resourceless_draw_) if (resourceless_draw_)
return is_layer_tree_frame_sink_lost || !can_draw_; return is_layer_tree_frame_sink_lost || !can_draw_;
...@@ -260,7 +260,7 @@ bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { ...@@ -260,7 +260,7 @@ bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
bool SchedulerStateMachine::ShouldAbortCurrentFrame() const { bool SchedulerStateMachine::ShouldAbortCurrentFrame() const {
// Abort the frame if there is no output surface to trigger our // Abort the frame if there is no output surface to trigger our
// activations, avoiding deadlock with the main thread. // activations, avoiding deadlock with the main thread.
if (layer_tree_frame_sink_state_ == LAYER_TREE_FRAME_SINK_NONE) if (layer_tree_frame_sink_state_ == LayerTreeFrameSinkState::NONE)
return true; return true;
// If we're not visible, we should just abort the frame. Since we // If we're not visible, we should just abort the frame. Since we
...@@ -288,13 +288,13 @@ bool SchedulerStateMachine::ShouldBeginLayerTreeFrameSinkCreation() const { ...@@ -288,13 +288,13 @@ bool SchedulerStateMachine::ShouldBeginLayerTreeFrameSinkCreation() const {
// We only want to start output surface initialization after the // We only want to start output surface initialization after the
// previous commit is complete. // previous commit is complete.
if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) { if (begin_main_frame_state_ != BeginMainFrameState::IDLE) {
return false; return false;
} }
// Make sure the BeginImplFrame from any previous LayerTreeFrameSinks // Make sure the BeginImplFrame from any previous LayerTreeFrameSinks
// are complete before creating the new LayerTreeFrameSink. // are complete before creating the new LayerTreeFrameSink.
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) if (begin_impl_frame_state_ != BeginImplFrameState::IDLE)
return false; return false;
// We want to clear the pipeline of any pending draws and activations // We want to clear the pipeline of any pending draws and activations
...@@ -306,7 +306,7 @@ bool SchedulerStateMachine::ShouldBeginLayerTreeFrameSinkCreation() const { ...@@ -306,7 +306,7 @@ bool SchedulerStateMachine::ShouldBeginLayerTreeFrameSinkCreation() const {
// We need to create the output surface if we don't have one and we haven't // We need to create the output surface if we don't have one and we haven't
// started creating one yet. // started creating one yet.
return layer_tree_frame_sink_state_ == LAYER_TREE_FRAME_SINK_NONE; return layer_tree_frame_sink_state_ == LayerTreeFrameSinkState::NONE;
} }
bool SchedulerStateMachine::ShouldDraw() const { bool SchedulerStateMachine::ShouldDraw() const {
...@@ -324,7 +324,7 @@ bool SchedulerStateMachine::ShouldDraw() const { ...@@ -324,7 +324,7 @@ bool SchedulerStateMachine::ShouldDraw() const {
return false; return false;
// Don't draw if we are waiting on the first commit after a surface. // Don't draw if we are waiting on the first commit after a surface.
if (layer_tree_frame_sink_state_ != LAYER_TREE_FRAME_SINK_ACTIVE) if (layer_tree_frame_sink_state_ != LayerTreeFrameSinkState::ACTIVE)
return false; return false;
// Do not queue too many draws. // Do not queue too many draws.
...@@ -333,7 +333,7 @@ bool SchedulerStateMachine::ShouldDraw() const { ...@@ -333,7 +333,7 @@ bool SchedulerStateMachine::ShouldDraw() const {
// Except for the cases above, do not draw outside of the BeginImplFrame // Except for the cases above, do not draw outside of the BeginImplFrame
// deadline. // deadline.
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE)
return false; return false;
// Wait for ready to draw in full-pipeline mode or the browser compositor's // Wait for ready to draw in full-pipeline mode or the browser compositor's
...@@ -350,7 +350,7 @@ bool SchedulerStateMachine::ShouldDraw() const { ...@@ -350,7 +350,7 @@ bool SchedulerStateMachine::ShouldDraw() const {
return false; return false;
// Only handle forced redraws due to timeouts on the regular deadline. // 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 true;
return needs_redraw_; return needs_redraw_;
...@@ -385,7 +385,7 @@ bool SchedulerStateMachine::ShouldNotifyBeginMainFrameNotSent() const { ...@@ -385,7 +385,7 @@ bool SchedulerStateMachine::ShouldNotifyBeginMainFrameNotSent() const {
// Don't notify if a BeginMainFrame has already been requested or is in // Don't notify if a BeginMainFrame has already been requested or is in
// progress. // progress.
if (needs_begin_main_frame_ || if (needs_begin_main_frame_ ||
begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) begin_main_frame_state_ != BeginMainFrameState::IDLE)
return false; return false;
// Only notify when we're visible. // Only notify when we're visible.
...@@ -445,7 +445,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { ...@@ -445,7 +445,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
// Other parts of the state machine indirectly defer the BeginMainFrame // Other parts of the state machine indirectly defer the BeginMainFrame
// by transitioning to WAITING commit states rather than going // by transitioning to WAITING commit states rather than going
// immediately to IDLE. // immediately to IDLE.
if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) if (begin_main_frame_state_ != BeginMainFrameState::IDLE)
return false; return false;
// MFBA is disabled and we are waiting for previous activation. // MFBA is disabled and we are waiting for previous activation.
...@@ -472,13 +472,13 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { ...@@ -472,13 +472,13 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
// TODO(brianderson): Allow sending BeginMainFrame while idle when the main // TODO(brianderson): Allow sending BeginMainFrame while idle when the main
// thread isn't consuming user input for non-synchronous compositor. // thread isn't consuming user input for non-synchronous compositor.
if (!settings_.using_synchronous_renderer_compositor && if (!settings_.using_synchronous_renderer_compositor &&
begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE) { begin_impl_frame_state_ == BeginImplFrameState::IDLE) {
return false; return false;
} }
// We need a new commit for the forced redraw. This honors the // We need a new commit for the forced redraw. This honors the
// single commit per interval because the result will be swapped to screen. // 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; return true;
// We shouldn't normally accept commits if there isn't a LayerTreeFrameSink. // We shouldn't normally accept commits if there isn't a LayerTreeFrameSink.
...@@ -492,7 +492,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { ...@@ -492,7 +492,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
// TODO(brianderson): Remove this restriction to improve throughput or // TODO(brianderson): Remove this restriction to improve throughput or
// make it conditional on ImplLatencyTakesPriority. // make it conditional on ImplLatencyTakesPriority.
bool just_submitted_in_deadline = bool just_submitted_in_deadline =
begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE &&
did_submit_in_last_frame_; did_submit_in_last_frame_;
if (IsDrawThrottled() && !just_submitted_in_deadline) if (IsDrawThrottled() && !just_submitted_in_deadline)
return false; return false;
...@@ -505,7 +505,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { ...@@ -505,7 +505,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
} }
bool SchedulerStateMachine::ShouldCommit() const { bool SchedulerStateMachine::ShouldCommit() const {
if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) if (begin_main_frame_state_ != BeginMainFrameState::READY_TO_COMMIT)
return false; return false;
// We must not finish the commit until the pending tree is free. // We must not finish the commit until the pending tree is free.
...@@ -538,7 +538,7 @@ bool SchedulerStateMachine::ShouldPrepareTiles() const { ...@@ -538,7 +538,7 @@ bool SchedulerStateMachine::ShouldPrepareTiles() const {
// Limiting to once per-frame is not enough, since we only want to prepare // Limiting to once per-frame is not enough, since we only want to prepare
// tiles _after_ draws. // tiles _after_ draws.
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE)
return false; return false;
return needs_prepare_tiles_; return needs_prepare_tiles_;
...@@ -554,7 +554,7 @@ bool SchedulerStateMachine::ShouldInvalidateLayerTreeFrameSink() const { ...@@ -554,7 +554,7 @@ bool SchedulerStateMachine::ShouldInvalidateLayerTreeFrameSink() const {
return false; return false;
// Invalidations are only performed inside a BeginFrame. // Invalidations are only performed inside a BeginFrame.
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_BEGIN_FRAME)
return false; return false;
// TODO(sunnyps): needs_prepare_tiles_ is needed here because PrepareTiles is // TODO(sunnyps): needs_prepare_tiles_ is needed here because PrepareTiles is
...@@ -565,30 +565,31 @@ bool SchedulerStateMachine::ShouldInvalidateLayerTreeFrameSink() const { ...@@ -565,30 +565,31 @@ bool SchedulerStateMachine::ShouldInvalidateLayerTreeFrameSink() const {
SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
if (ShouldActivateSyncTree()) if (ShouldActivateSyncTree())
return ACTION_ACTIVATE_SYNC_TREE; return Action::ACTIVATE_SYNC_TREE;
if (ShouldCommit()) if (ShouldCommit())
return ACTION_COMMIT; return Action::COMMIT;
if (ShouldDraw()) { if (ShouldDraw()) {
if (PendingDrawsShouldBeAborted()) if (PendingDrawsShouldBeAborted())
return ACTION_DRAW_ABORT; return Action::DRAW_ABORT;
else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) else if (forced_redraw_state_ ==
return ACTION_DRAW_FORCED; ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
return Action::DRAW_FORCED;
else else
return ACTION_DRAW_IF_POSSIBLE; return Action::DRAW_IF_POSSIBLE;
} }
if (ShouldPerformImplSideInvalidation()) if (ShouldPerformImplSideInvalidation())
return ACTION_PERFORM_IMPL_SIDE_INVALIDATION; return Action::PERFORM_IMPL_SIDE_INVALIDATION;
if (ShouldPrepareTiles()) if (ShouldPrepareTiles())
return ACTION_PREPARE_TILES; return Action::PREPARE_TILES;
if (ShouldSendBeginMainFrame()) if (ShouldSendBeginMainFrame())
return ACTION_SEND_BEGIN_MAIN_FRAME; return Action::SEND_BEGIN_MAIN_FRAME;
if (ShouldInvalidateLayerTreeFrameSink()) if (ShouldInvalidateLayerTreeFrameSink())
return ACTION_INVALIDATE_LAYER_TREE_FRAME_SINK; return Action::INVALIDATE_LAYER_TREE_FRAME_SINK;
if (ShouldBeginLayerTreeFrameSinkCreation()) if (ShouldBeginLayerTreeFrameSinkCreation())
return ACTION_BEGIN_LAYER_TREE_FRAME_SINK_CREATION; return Action::BEGIN_LAYER_TREE_FRAME_SINK_CREATION;
if (ShouldNotifyBeginMainFrameNotSent()) if (ShouldNotifyBeginMainFrameNotSent())
return ACTION_NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT; return Action::NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT;
return ACTION_NONE; return Action::NONE;
} }
bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const { bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const {
...@@ -601,7 +602,7 @@ bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const { ...@@ -601,7 +602,7 @@ bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const {
return false; return false;
// No invalidations should be done outside the impl frame. // No invalidations should be done outside the impl frame.
if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE) if (begin_impl_frame_state_ == BeginImplFrameState::IDLE)
return false; return false;
// We need to be able to create a pending tree to perform an invalidation. // We need to be able to create a pending tree to perform an invalidation.
...@@ -624,11 +625,11 @@ bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const { ...@@ -624,11 +625,11 @@ bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const {
} }
bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const { bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const {
DCHECK_NE(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE); DCHECK_NE(begin_impl_frame_state_, BeginImplFrameState::IDLE);
// If the main thread is ready to commit, the impl-side invalidations will be // If the main thread is ready to commit, the impl-side invalidations will be
// merged with the incoming main frame. // merged with the incoming main frame.
if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) if (begin_main_frame_state_ == BeginMainFrameState::READY_TO_COMMIT)
return true; return true;
// If we are inside the deadline, and haven't performed an invalidation yet, // If we are inside the deadline, and haven't performed an invalidation yet,
...@@ -641,7 +642,7 @@ bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const { ...@@ -641,7 +642,7 @@ bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const {
// b) We have to wait on the main thread to respond to a main frame. // b) We have to wait on the main thread to respond to a main frame.
// In addition, the deadline task can be cancelled if the main thread // In addition, the deadline task can be cancelled if the main thread
// responds before it runs. // responds before it runs.
if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) if (begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE)
return false; return false;
// If commits are being aborted (which would be the common case for a // If commits are being aborted (which would be the common case for a
...@@ -658,8 +659,8 @@ bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const { ...@@ -658,8 +659,8 @@ bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const {
return true; return true;
// If the main frame was already sent, wait for the main thread to respond. // If the main frame was already sent, wait for the main thread to respond.
if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_SENT || if (begin_main_frame_state_ == BeginMainFrameState::SENT ||
begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_STARTED) begin_main_frame_state_ == BeginMainFrameState::STARTED)
return true; return true;
// If the main thread committed during the last frame, i.e. it was not // If the main thread committed during the last frame, i.e. it was not
...@@ -720,7 +721,7 @@ void SchedulerStateMachine::WillSendBeginMainFrame() { ...@@ -720,7 +721,7 @@ void SchedulerStateMachine::WillSendBeginMainFrame() {
DCHECK(visible_); DCHECK(visible_);
DCHECK(!begin_frame_source_paused_); DCHECK(!begin_frame_source_paused_);
DCHECK(!did_send_begin_main_frame_for_current_frame_); DCHECK(!did_send_begin_main_frame_for_current_frame_);
begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; begin_main_frame_state_ = BeginMainFrameState::SENT;
needs_begin_main_frame_ = false; needs_begin_main_frame_ = false;
did_send_begin_main_frame_for_current_frame_ = true; did_send_begin_main_frame_for_current_frame_ = true;
last_frame_number_begin_main_frame_sent_ = current_frame_number_; last_frame_number_begin_main_frame_sent_ = current_frame_number_;
...@@ -741,7 +742,7 @@ void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { ...@@ -741,7 +742,7 @@ void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) {
DCHECK(!has_pending_tree_ || can_have_pending_tree); DCHECK(!has_pending_tree_ || can_have_pending_tree);
commit_count_++; commit_count_++;
last_commit_had_no_updates_ = commit_has_no_updates; last_commit_had_no_updates_ = commit_has_no_updates;
begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; begin_main_frame_state_ = BeginMainFrameState::IDLE;
did_commit_during_frame_ = true; did_commit_during_frame_ = true;
if (!commit_has_no_updates) { if (!commit_has_no_updates) {
...@@ -764,28 +765,30 @@ void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { ...@@ -764,28 +765,30 @@ void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) {
} }
// Update state related to forced draws. // Update state related to forced draws.
if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT) {
forced_redraw_state_ = has_pending_tree_ forced_redraw_state_ =
? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION has_pending_tree_ ? ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION
: FORCED_REDRAW_STATE_WAITING_FOR_DRAW; : ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW;
} }
// Update the output surface state. // Update the output surface state.
if (layer_tree_frame_sink_state_ == if (layer_tree_frame_sink_state_ ==
LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_COMMIT) { LayerTreeFrameSinkState::WAITING_FOR_FIRST_COMMIT) {
layer_tree_frame_sink_state_ = layer_tree_frame_sink_state_ =
has_pending_tree_ ? LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION has_pending_tree_
: LAYER_TREE_FRAME_SINK_ACTIVE; ? LayerTreeFrameSinkState::WAITING_FOR_FIRST_ACTIVATION
: LayerTreeFrameSinkState::ACTIVE;
} }
} }
void SchedulerStateMachine::WillActivate() { void SchedulerStateMachine::WillActivate() {
if (layer_tree_frame_sink_state_ == if (layer_tree_frame_sink_state_ ==
LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) LayerTreeFrameSinkState::WAITING_FOR_FIRST_ACTIVATION)
layer_tree_frame_sink_state_ = LAYER_TREE_FRAME_SINK_ACTIVE; layer_tree_frame_sink_state_ = LayerTreeFrameSinkState::ACTIVE;
if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) if (forced_redraw_state_ ==
forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION)
forced_redraw_state_ = ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW;
has_pending_tree_ = false; has_pending_tree_ = false;
pending_tree_is_ready_for_activation_ = false; pending_tree_is_ready_for_activation_ = false;
...@@ -814,8 +817,8 @@ void SchedulerStateMachine::WillDrawInternal() { ...@@ -814,8 +817,8 @@ void SchedulerStateMachine::WillDrawInternal() {
did_draw_in_last_frame_ = true; did_draw_in_last_frame_ = true;
last_frame_number_draw_performed_ = current_frame_number_; last_frame_number_draw_performed_ = current_frame_number_;
if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; forced_redraw_state_ = ForcedRedrawOnTimeoutState::IDLE;
} }
void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) {
...@@ -827,7 +830,7 @@ void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { ...@@ -827,7 +830,7 @@ void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) {
case DRAW_ABORTED_DRAINING_PIPELINE: case DRAW_ABORTED_DRAINING_PIPELINE:
case DRAW_SUCCESS: case DRAW_SUCCESS:
consecutive_checkerboard_animations_ = 0; consecutive_checkerboard_animations_ = 0;
forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; forced_redraw_state_ = ForcedRedrawOnTimeoutState::IDLE;
break; break;
case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS:
DCHECK(!did_submit_in_last_frame_); DCHECK(!did_submit_in_last_frame_);
...@@ -837,11 +840,11 @@ void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { ...@@ -837,11 +840,11 @@ void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) {
if (consecutive_checkerboard_animations_ >= if (consecutive_checkerboard_animations_ >=
settings_.maximum_number_of_failed_draws_before_draw_is_forced && settings_.maximum_number_of_failed_draws_before_draw_is_forced &&
forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && forced_redraw_state_ == ForcedRedrawOnTimeoutState::IDLE &&
settings_.timeout_and_draw_when_animation_checkerboards) { settings_.timeout_and_draw_when_animation_checkerboards) {
// We need to force a draw, but it doesn't make sense to do this until // We need to force a draw, but it doesn't make sense to do this until
// we've committed and have new textures. // we've committed and have new textures.
forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; forced_redraw_state_ = ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT;
} }
break; break;
case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT:
...@@ -889,13 +892,13 @@ void SchedulerStateMachine::WillPrepareTiles() { ...@@ -889,13 +892,13 @@ void SchedulerStateMachine::WillPrepareTiles() {
} }
void SchedulerStateMachine::WillBeginLayerTreeFrameSinkCreation() { void SchedulerStateMachine::WillBeginLayerTreeFrameSinkCreation() {
DCHECK_EQ(layer_tree_frame_sink_state_, LAYER_TREE_FRAME_SINK_NONE); DCHECK_EQ(layer_tree_frame_sink_state_, LayerTreeFrameSinkState::NONE);
layer_tree_frame_sink_state_ = LAYER_TREE_FRAME_SINK_CREATING; layer_tree_frame_sink_state_ = LayerTreeFrameSinkState::CREATING;
// The following DCHECKs make sure we are in the proper quiescent state. // The following DCHECKs make sure we are in the proper quiescent state.
// The pipeline should be flushed entirely before we start output // The pipeline should be flushed entirely before we start output
// surface creation to avoid complicated corner cases. // surface creation to avoid complicated corner cases.
DCHECK(begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_IDLE); DCHECK(begin_main_frame_state_ == BeginMainFrameState::IDLE);
DCHECK(!has_pending_tree_); DCHECK(!has_pending_tree_);
DCHECK(!active_tree_needs_first_draw_); DCHECK(!active_tree_needs_first_draw_);
} }
...@@ -950,7 +953,7 @@ void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { ...@@ -950,7 +953,7 @@ void SchedulerStateMachine::SetDeferCommits(bool defer_commits) {
bool SchedulerStateMachine::BeginFrameRequiredForAction() const { bool SchedulerStateMachine::BeginFrameRequiredForAction() const {
// The forced draw respects our normal draw scheduling, so we need to // The forced draw respects our normal draw scheduling, so we need to
// request a BeginImplFrame for it. // 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 true;
return needs_redraw_ || needs_one_begin_impl_frame_ || return needs_redraw_ || needs_one_begin_impl_frame_ ||
...@@ -974,8 +977,7 @@ bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { ...@@ -974,8 +977,7 @@ bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
// request frames when commits are disabled, because the frame requests will // request frames when commits are disabled, because the frame requests will
// not provide the needed commit (and will wake up the process when it could // not provide the needed commit (and will wake up the process when it could
// stay idle). // stay idle).
if ((begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) && if ((begin_main_frame_state_ != BeginMainFrameState::IDLE) && !defer_commits_)
!defer_commits_)
return true; return true;
// If the pending tree activates quickly, we'll want a BeginImplFrame soon // If the pending tree activates quickly, we'll want a BeginImplFrame soon
...@@ -1005,7 +1007,7 @@ bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { ...@@ -1005,7 +1007,7 @@ bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
void SchedulerStateMachine::OnBeginImplFrame(uint64_t source_id, void SchedulerStateMachine::OnBeginImplFrame(uint64_t source_id,
uint64_t sequence_number) { uint64_t sequence_number) {
begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; begin_impl_frame_state_ = BeginImplFrameState::INSIDE_BEGIN_FRAME;
current_frame_number_++; current_frame_number_++;
// Cache the values from the previous impl frame before reseting them for this // Cache the values from the previous impl frame before reseting them for this
...@@ -1026,14 +1028,14 @@ void SchedulerStateMachine::OnBeginImplFrame(uint64_t source_id, ...@@ -1026,14 +1028,14 @@ void SchedulerStateMachine::OnBeginImplFrame(uint64_t source_id,
} }
void SchedulerStateMachine::OnBeginImplFrameDeadline() { void SchedulerStateMachine::OnBeginImplFrameDeadline() {
begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; begin_impl_frame_state_ = BeginImplFrameState::INSIDE_DEADLINE;
// Clear funnels for any actions we perform during the deadline. // Clear funnels for any actions we perform during the deadline.
did_draw_ = false; did_draw_ = false;
} }
void SchedulerStateMachine::OnBeginImplFrameIdle() { void SchedulerStateMachine::OnBeginImplFrameIdle() {
begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; begin_impl_frame_state_ = BeginImplFrameState::IDLE;
// Count any prepare tiles that happens in commits in between frames. We want // Count any prepare tiles that happens in commits in between frames. We want
// to prevent a prepare tiles during the next frame's deadline in that case. // to prevent a prepare tiles during the next frame's deadline in that case.
...@@ -1058,19 +1060,19 @@ SchedulerStateMachine::BeginImplFrameDeadlineMode ...@@ -1058,19 +1060,19 @@ SchedulerStateMachine::BeginImplFrameDeadlineMode
SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
if (settings_.using_synchronous_renderer_compositor) { if (settings_.using_synchronous_renderer_compositor) {
// No deadline for synchronous compositor. // No deadline for synchronous compositor.
return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; return BeginImplFrameDeadlineMode::NONE;
} else if (ShouldBlockDeadlineIndefinitely()) { } else if (ShouldBlockDeadlineIndefinitely()) {
return BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED; return BeginImplFrameDeadlineMode::BLOCKED;
} else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) { } else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) {
return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE; return BeginImplFrameDeadlineMode::IMMEDIATE;
} else if (needs_redraw_) { } else if (needs_redraw_) {
// We have an animation or fast input path on the impl thread that wants // 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. // to draw, so don't wait too long for a new active tree.
return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR; return BeginImplFrameDeadlineMode::REGULAR;
} else { } else {
// The impl thread doesn't have anything it wants to draw and we are just // The impl thread doesn't have anything it wants to draw and we are just
// waiting for a new active tree. In short we are blocked. // waiting for a new active tree. In short we are blocked.
return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; return BeginImplFrameDeadlineMode::LATE;
} }
} }
...@@ -1119,7 +1121,7 @@ bool SchedulerStateMachine::ShouldBlockDeadlineIndefinitely() const { ...@@ -1119,7 +1121,7 @@ bool SchedulerStateMachine::ShouldBlockDeadlineIndefinitely() const {
// Avoid blocking for any reason if we don't have a layer tree frame sink or // Avoid blocking for any reason if we don't have a layer tree frame sink or
// are invisible. // are invisible.
if (layer_tree_frame_sink_state_ == LAYER_TREE_FRAME_SINK_NONE) if (layer_tree_frame_sink_state_ == LayerTreeFrameSinkState::NONE)
return false; return false;
if (!visible_) if (!visible_)
...@@ -1136,7 +1138,7 @@ bool SchedulerStateMachine::ShouldBlockDeadlineIndefinitely() const { ...@@ -1136,7 +1138,7 @@ bool SchedulerStateMachine::ShouldBlockDeadlineIndefinitely() const {
if (ShouldSendBeginMainFrame()) if (ShouldSendBeginMainFrame())
return true; return true;
if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) if (begin_main_frame_state_ != BeginMainFrameState::IDLE)
return true; return true;
// Wait for tiles and activation. // Wait for tiles and activation.
...@@ -1193,8 +1195,7 @@ bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const { ...@@ -1193,8 +1195,7 @@ bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const {
bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_; bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_;
bool main_updates_expected = bool main_updates_expected =
needs_begin_main_frame_ || needs_begin_main_frame_ ||
begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE || begin_main_frame_state_ != BeginMainFrameState::IDLE || has_pending_tree_;
has_pending_tree_;
return has_impl_updates && !main_updates_expected; return has_impl_updates && !main_updates_expected;
} }
...@@ -1258,9 +1259,9 @@ void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { ...@@ -1258,9 +1259,9 @@ void SchedulerStateMachine::SetNeedsOneBeginImplFrame() {
} }
void SchedulerStateMachine::NotifyReadyToCommit() { void SchedulerStateMachine::NotifyReadyToCommit() {
DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::STARTED)
<< AsValue()->ToString(); << AsValue()->ToString();
begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; begin_main_frame_state_ = BeginMainFrameState::READY_TO_COMMIT;
// In commit_to_active_tree mode, commit should happen right after BeginFrame, // In commit_to_active_tree mode, commit should happen right after BeginFrame,
// meaning when this function is called, next action should be commit. // meaning when this function is called, next action should be commit.
if (settings_.commit_to_active_tree) if (settings_.commit_to_active_tree)
...@@ -1268,7 +1269,7 @@ void SchedulerStateMachine::NotifyReadyToCommit() { ...@@ -1268,7 +1269,7 @@ void SchedulerStateMachine::NotifyReadyToCommit() {
} }
void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::STARTED);
// If the main thread aborted, it doesn't matter if the main thread missed // If the main thread aborted, it doesn't matter if the main thread missed
// the last deadline since it didn't have an update anyway. // the last deadline since it didn't have an update anyway.
...@@ -1278,7 +1279,7 @@ void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { ...@@ -1278,7 +1279,7 @@ void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
case CommitEarlyOutReason::ABORTED_LAYER_TREE_FRAME_SINK_LOST: case CommitEarlyOutReason::ABORTED_LAYER_TREE_FRAME_SINK_LOST:
case CommitEarlyOutReason::ABORTED_NOT_VISIBLE: case CommitEarlyOutReason::ABORTED_NOT_VISIBLE:
case CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT: case CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT:
begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; begin_main_frame_state_ = BeginMainFrameState::IDLE;
SetNeedsBeginMainFrame(); SetNeedsBeginMainFrame();
return; return;
case CommitEarlyOutReason::FINISHED_NO_UPDATES: case CommitEarlyOutReason::FINISHED_NO_UPDATES:
...@@ -1294,10 +1295,10 @@ void SchedulerStateMachine::DidPrepareTiles() { ...@@ -1294,10 +1295,10 @@ void SchedulerStateMachine::DidPrepareTiles() {
} }
void SchedulerStateMachine::DidLoseLayerTreeFrameSink() { void SchedulerStateMachine::DidLoseLayerTreeFrameSink() {
if (layer_tree_frame_sink_state_ == LAYER_TREE_FRAME_SINK_NONE || if (layer_tree_frame_sink_state_ == LayerTreeFrameSinkState::NONE ||
layer_tree_frame_sink_state_ == LAYER_TREE_FRAME_SINK_CREATING) layer_tree_frame_sink_state_ == LayerTreeFrameSinkState::CREATING)
return; return;
layer_tree_frame_sink_state_ = LAYER_TREE_FRAME_SINK_NONE; layer_tree_frame_sink_state_ = LayerTreeFrameSinkState::NONE;
needs_redraw_ = false; needs_redraw_ = false;
} }
...@@ -1314,8 +1315,9 @@ void SchedulerStateMachine::NotifyReadyToDraw() { ...@@ -1314,8 +1315,9 @@ void SchedulerStateMachine::NotifyReadyToDraw() {
} }
void SchedulerStateMachine::DidCreateAndInitializeLayerTreeFrameSink() { void SchedulerStateMachine::DidCreateAndInitializeLayerTreeFrameSink() {
DCHECK_EQ(layer_tree_frame_sink_state_, LAYER_TREE_FRAME_SINK_CREATING); DCHECK_EQ(layer_tree_frame_sink_state_, LayerTreeFrameSinkState::CREATING);
layer_tree_frame_sink_state_ = LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_COMMIT; layer_tree_frame_sink_state_ =
LayerTreeFrameSinkState::WAITING_FOR_FIRST_COMMIT;
if (did_create_and_initialize_first_layer_tree_frame_sink_) { if (did_create_and_initialize_first_layer_tree_frame_sink_) {
// TODO(boliu): See if we can remove this when impl-side painting is always // TODO(boliu): See if we can remove this when impl-side painting is always
...@@ -1329,19 +1331,19 @@ void SchedulerStateMachine::DidCreateAndInitializeLayerTreeFrameSink() { ...@@ -1329,19 +1331,19 @@ void SchedulerStateMachine::DidCreateAndInitializeLayerTreeFrameSink() {
} }
void SchedulerStateMachine::NotifyBeginMainFrameStarted() { void SchedulerStateMachine::NotifyBeginMainFrameStarted() {
DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_SENT); DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::SENT);
begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_STARTED; begin_main_frame_state_ = BeginMainFrameState::STARTED;
} }
bool SchedulerStateMachine::HasInitializedLayerTreeFrameSink() const { bool SchedulerStateMachine::HasInitializedLayerTreeFrameSink() const {
switch (layer_tree_frame_sink_state_) { switch (layer_tree_frame_sink_state_) {
case LAYER_TREE_FRAME_SINK_NONE: case LayerTreeFrameSinkState::NONE:
case LAYER_TREE_FRAME_SINK_CREATING: case LayerTreeFrameSinkState::CREATING:
return false; return false;
case LAYER_TREE_FRAME_SINK_ACTIVE: case LayerTreeFrameSinkState::ACTIVE:
case LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: case LayerTreeFrameSinkState::WAITING_FOR_FIRST_COMMIT:
case LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: case LayerTreeFrameSinkState::WAITING_FOR_FIRST_ACTIVATION:
return true; return true;
} }
NOTREACHED(); NOTREACHED();
......
...@@ -50,48 +50,48 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -50,48 +50,48 @@ class CC_EXPORT SchedulerStateMachine {
explicit SchedulerStateMachine(const SchedulerSettings& settings); explicit SchedulerStateMachine(const SchedulerSettings& settings);
~SchedulerStateMachine(); ~SchedulerStateMachine();
enum LayerTreeFrameSinkState { enum class LayerTreeFrameSinkState {
LAYER_TREE_FRAME_SINK_NONE, NONE,
LAYER_TREE_FRAME_SINK_ACTIVE, ACTIVE,
LAYER_TREE_FRAME_SINK_CREATING, CREATING,
LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_COMMIT, WAITING_FOR_FIRST_COMMIT,
LAYER_TREE_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION, WAITING_FOR_FIRST_ACTIVATION,
}; };
static const char* LayerTreeFrameSinkStateToString( static const char* LayerTreeFrameSinkStateToString(
LayerTreeFrameSinkState state); LayerTreeFrameSinkState state);
// Note: BeginImplFrameState does not cycle through these states in a fixed // Note: BeginImplFrameState does not cycle through these states in a fixed
// order on all platforms. It's up to the scheduler to set these correctly. // order on all platforms. It's up to the scheduler to set these correctly.
enum BeginImplFrameState { enum class BeginImplFrameState {
BEGIN_IMPL_FRAME_STATE_IDLE, IDLE,
BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME, INSIDE_BEGIN_FRAME,
BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, INSIDE_DEADLINE,
}; };
static const char* BeginImplFrameStateToString(BeginImplFrameState state); static const char* BeginImplFrameStateToString(BeginImplFrameState state);
enum BeginImplFrameDeadlineMode { enum class BeginImplFrameDeadlineMode {
BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE, NONE,
BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE, IMMEDIATE,
BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR, REGULAR,
BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE, LATE,
BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED, BLOCKED,
}; };
static const char* BeginImplFrameDeadlineModeToString( static const char* BeginImplFrameDeadlineModeToString(
BeginImplFrameDeadlineMode mode); BeginImplFrameDeadlineMode mode);
enum BeginMainFrameState { enum class BeginMainFrameState {
BEGIN_MAIN_FRAME_STATE_IDLE, IDLE,
BEGIN_MAIN_FRAME_STATE_SENT, SENT,
BEGIN_MAIN_FRAME_STATE_STARTED, STARTED,
BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT, READY_TO_COMMIT,
}; };
static const char* BeginMainFrameStateToString(BeginMainFrameState state); static const char* BeginMainFrameStateToString(BeginMainFrameState state);
enum ForcedRedrawOnTimeoutState { enum class ForcedRedrawOnTimeoutState {
FORCED_REDRAW_STATE_IDLE, IDLE,
FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, WAITING_FOR_COMMIT,
FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, WAITING_FOR_ACTIVATION,
FORCED_REDRAW_STATE_WAITING_FOR_DRAW, WAITING_FOR_DRAW,
}; };
static const char* ForcedRedrawOnTimeoutStateToString( static const char* ForcedRedrawOnTimeoutStateToString(
ForcedRedrawOnTimeoutState state); ForcedRedrawOnTimeoutState state);
...@@ -101,9 +101,9 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -101,9 +101,9 @@ class CC_EXPORT SchedulerStateMachine {
} }
bool CommitPending() const { bool CommitPending() const {
return begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_SENT || return begin_main_frame_state_ == BeginMainFrameState::SENT ||
begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_STARTED || begin_main_frame_state_ == BeginMainFrameState::STARTED ||
begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; begin_main_frame_state_ == BeginMainFrameState::READY_TO_COMMIT;
} }
bool NewActiveTreeLikely() const { bool NewActiveTreeLikely() const {
...@@ -113,19 +113,19 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -113,19 +113,19 @@ class CC_EXPORT SchedulerStateMachine {
bool RedrawPending() const { return needs_redraw_; } bool RedrawPending() const { return needs_redraw_; }
bool PrepareTilesPending() const { return needs_prepare_tiles_; } bool PrepareTilesPending() const { return needs_prepare_tiles_; }
enum Action { enum class Action {
ACTION_NONE, NONE,
ACTION_SEND_BEGIN_MAIN_FRAME, SEND_BEGIN_MAIN_FRAME,
ACTION_COMMIT, COMMIT,
ACTION_ACTIVATE_SYNC_TREE, ACTIVATE_SYNC_TREE,
ACTION_PERFORM_IMPL_SIDE_INVALIDATION, PERFORM_IMPL_SIDE_INVALIDATION,
ACTION_DRAW_IF_POSSIBLE, DRAW_IF_POSSIBLE,
ACTION_DRAW_FORCED, DRAW_FORCED,
ACTION_DRAW_ABORT, DRAW_ABORT,
ACTION_BEGIN_LAYER_TREE_FRAME_SINK_CREATION, BEGIN_LAYER_TREE_FRAME_SINK_CREATION,
ACTION_PREPARE_TILES, PREPARE_TILES,
ACTION_INVALIDATE_LAYER_TREE_FRAME_SINK, INVALIDATE_LAYER_TREE_FRAME_SINK,
ACTION_NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT, NOTIFY_BEGIN_MAIN_FRAME_NOT_SENT,
}; };
static const char* ActionToString(Action action); static const char* ActionToString(Action action);
...@@ -232,12 +232,12 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -232,12 +232,12 @@ class CC_EXPORT SchedulerStateMachine {
// active). // active).
void SetNeedsOneBeginImplFrame(); void SetNeedsOneBeginImplFrame();
// Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME // Call this only in response to receiving an Action::SEND_BEGIN_MAIN_FRAME
// from NextAction. // from NextAction.
// Indicates that all painting is complete. // Indicates that all painting is complete.
void NotifyReadyToCommit(); void NotifyReadyToCommit();
// Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME // Call this only in response to receiving an Action::SEND_BEGIN_MAIN_FRAME
// from NextAction if the client rejects the BeginMainFrame message. // from NextAction if the client rejects the BeginMainFrame message.
void BeginMainFrameAborted(CommitEarlyOutReason reason); void BeginMainFrameAborted(CommitEarlyOutReason reason);
...@@ -324,10 +324,11 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -324,10 +324,11 @@ class CC_EXPORT SchedulerStateMachine {
const SchedulerSettings settings_; const SchedulerSettings settings_;
LayerTreeFrameSinkState layer_tree_frame_sink_state_ = LayerTreeFrameSinkState layer_tree_frame_sink_state_ =
LAYER_TREE_FRAME_SINK_NONE; LayerTreeFrameSinkState::NONE;
BeginImplFrameState begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; BeginImplFrameState begin_impl_frame_state_ = BeginImplFrameState::IDLE;
BeginMainFrameState begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; BeginMainFrameState begin_main_frame_state_ = BeginMainFrameState::IDLE;
ForcedRedrawOnTimeoutState forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; ForcedRedrawOnTimeoutState forced_redraw_state_ =
ForcedRedrawOnTimeoutState::IDLE;
// These are used for tracing only. // These are used for tracing only.
int commit_count_ = 0; int commit_count_ = 0;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment