Commit 79a18a95 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

[cleanup] cc: Remove a state from the state-machine.

To track the state of a BeginMainFrame, SENT and STARTED serve the same
purpose: they indicate that a BeginMainFrame has been issued to the
main-thread, and the main-thread has not responded to that yet. So
remove STARTED state, and use only SENT instead.

Document these states, and also ForcedRedrawOnTimeoutState.

BUG=none

Change-Id: I200337cfe0a8ec7544961b01abf22fbc56eea5d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1709153
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678945}
parent 889e0ce7
......@@ -222,7 +222,6 @@ void Scheduler::DidCreateAndInitializeLayerTreeFrameSink() {
void Scheduler::NotifyBeginMainFrameStarted(
base::TimeTicks main_thread_start_time) {
TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
state_machine_.NotifyBeginMainFrameStarted();
compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time);
}
......@@ -1011,11 +1010,9 @@ bool Scheduler::CanBeginMainFrameAndActivateBeforeDeadline(
return estimated_draw_time < args.deadline;
}
bool Scheduler::IsBeginMainFrameSentOrStarted() const {
return (state_machine_.begin_main_frame_state() ==
SchedulerStateMachine::BeginMainFrameState::SENT ||
state_machine_.begin_main_frame_state() ==
SchedulerStateMachine::BeginMainFrameState::STARTED);
bool Scheduler::IsBeginMainFrameSent() const {
return state_machine_.begin_main_frame_state() ==
SchedulerStateMachine::BeginMainFrameState::SENT;
}
viz::BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const {
......
......@@ -240,7 +240,7 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase {
void ClearHistory();
bool IsBeginMainFrameSentOrStarted() const;
bool IsBeginMainFrameSent() const;
protected:
// Virtual for testing.
......
......@@ -79,8 +79,6 @@ const char* SchedulerStateMachine::BeginMainFrameStateToString(
return "BeginMainFrameState::IDLE";
case BeginMainFrameState::SENT:
return "BeginMainFrameState::SENT";
case BeginMainFrameState::STARTED:
return "BeginMainFrameState::STARTED";
case BeginMainFrameState::READY_TO_COMMIT:
return "BeginMainFrameState::READY_TO_COMMIT";
}
......@@ -719,8 +717,7 @@ bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const {
return true;
// If the main frame was already sent, wait for the main thread to respond.
if (begin_main_frame_state_ == BeginMainFrameState::SENT ||
begin_main_frame_state_ == BeginMainFrameState::STARTED)
if (begin_main_frame_state_ == BeginMainFrameState::SENT)
return true;
// If the main thread committed during the last frame, i.e. it was not
......@@ -1147,8 +1144,7 @@ void SchedulerStateMachine::OnBeginImplFrameIdle() {
main_thread_missed_last_deadline_ =
CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_;
main_thread_failed_to_respond_last_deadline_ =
begin_main_frame_state_ == BeginMainFrameState::SENT ||
begin_main_frame_state_ == BeginMainFrameState::STARTED;
begin_main_frame_state_ == BeginMainFrameState::SENT;
// If we're entering a state where we won't get BeginFrames set all the
// funnels so that we don't perform any actions that we shouldn't.
......@@ -1377,7 +1373,7 @@ void SchedulerStateMachine::SetNeedsOneBeginImplFrame() {
}
void SchedulerStateMachine::NotifyReadyToCommit() {
DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::STARTED)
DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::SENT)
<< AsValue()->ToString();
begin_main_frame_state_ = BeginMainFrameState::READY_TO_COMMIT;
// In commit_to_active_tree mode, commit should happen right after BeginFrame,
......@@ -1387,7 +1383,7 @@ void SchedulerStateMachine::NotifyReadyToCommit() {
}
void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::STARTED);
DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::SENT);
// 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.
......@@ -1493,11 +1489,6 @@ void SchedulerStateMachine::DidCreateAndInitializeLayerTreeFrameSink() {
main_thread_missed_last_deadline_ = false;
}
void SchedulerStateMachine::NotifyBeginMainFrameStarted() {
DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::SENT);
begin_main_frame_state_ = BeginMainFrameState::STARTED;
}
bool SchedulerStateMachine::HasInitializedLayerTreeFrameSink() const {
switch (layer_tree_frame_sink_state_) {
case LayerTreeFrameSinkState::NONE:
......
......@@ -88,13 +88,15 @@ class CC_EXPORT SchedulerStateMachine {
BeginImplFrameDeadlineMode mode);
enum class BeginMainFrameState {
IDLE,
SENT,
STARTED,
READY_TO_COMMIT,
IDLE, // A new BeginMainFrame can start.
SENT, // A BeginMainFrame has already been issued.
READY_TO_COMMIT, // A previously issued BeginMainFrame has been processed,
// and is ready to commit.
};
static const char* BeginMainFrameStateToString(BeginMainFrameState state);
// When a redraw is forced, it goes through a complete commit -> activation ->
// draw cycle. Until a redraw has been forced, it remains in IDLE state.
enum class ForcedRedrawOnTimeoutState {
IDLE,
WAITING_FOR_COMMIT,
......@@ -109,9 +111,7 @@ class CC_EXPORT SchedulerStateMachine {
}
bool CommitPending() const {
return begin_main_frame_state_ == BeginMainFrameState::SENT ||
begin_main_frame_state_ == BeginMainFrameState::STARTED ||
begin_main_frame_state_ == BeginMainFrameState::READY_TO_COMMIT;
return begin_main_frame_state_ != BeginMainFrameState::IDLE;
}
bool NewActiveTreeLikely() const {
......@@ -271,9 +271,6 @@ class CC_EXPORT SchedulerStateMachine {
// frame sink is not ready to receive frames.
void SetSkipDraw(bool skip);
// Indicates that scheduled BeginMainFrame is started.
void NotifyBeginMainFrameStarted();
// Indicates that the pending tree is ready for activation. Returns whether
// the notification received updated the state for the current pending tree,
// if any.
......@@ -383,6 +380,9 @@ class CC_EXPORT SchedulerStateMachine {
LayerTreeFrameSinkState::NONE;
BeginImplFrameState begin_impl_frame_state_ = BeginImplFrameState::IDLE;
BeginMainFrameState begin_main_frame_state_ = BeginMainFrameState::IDLE;
// A redraw is forced when too many checkerboarded-frames are produced during
// an animation.
ForcedRedrawOnTimeoutState forced_redraw_state_ =
ForcedRedrawOnTimeoutState::IDLE;
......
......@@ -395,7 +395,7 @@ bool ProxyImpl::IsBeginMainFrameExpected() {
// not responded to a previously dispatched BeginMainFrame, then assume that
// main-thread would want to produce an update for the current frame too.
return scheduler_->needs_begin_main_frame() ||
scheduler_->IsBeginMainFrameSentOrStarted();
scheduler_->IsBeginMainFrameSent();
}
void ProxyImpl::RenewTreePriority() {
......
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