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() { ...@@ -222,7 +222,6 @@ void Scheduler::DidCreateAndInitializeLayerTreeFrameSink() {
void Scheduler::NotifyBeginMainFrameStarted( void Scheduler::NotifyBeginMainFrameStarted(
base::TimeTicks main_thread_start_time) { base::TimeTicks main_thread_start_time) {
TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
state_machine_.NotifyBeginMainFrameStarted();
compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time); compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time);
} }
...@@ -1011,11 +1010,9 @@ bool Scheduler::CanBeginMainFrameAndActivateBeforeDeadline( ...@@ -1011,11 +1010,9 @@ bool Scheduler::CanBeginMainFrameAndActivateBeforeDeadline(
return estimated_draw_time < args.deadline; return estimated_draw_time < args.deadline;
} }
bool Scheduler::IsBeginMainFrameSentOrStarted() const { bool Scheduler::IsBeginMainFrameSent() const {
return (state_machine_.begin_main_frame_state() == return state_machine_.begin_main_frame_state() ==
SchedulerStateMachine::BeginMainFrameState::SENT || SchedulerStateMachine::BeginMainFrameState::SENT;
state_machine_.begin_main_frame_state() ==
SchedulerStateMachine::BeginMainFrameState::STARTED);
} }
viz::BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const { viz::BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const {
......
...@@ -240,7 +240,7 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase { ...@@ -240,7 +240,7 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase {
void ClearHistory(); void ClearHistory();
bool IsBeginMainFrameSentOrStarted() const; bool IsBeginMainFrameSent() const;
protected: protected:
// Virtual for testing. // Virtual for testing.
......
...@@ -79,8 +79,6 @@ const char* SchedulerStateMachine::BeginMainFrameStateToString( ...@@ -79,8 +79,6 @@ const char* SchedulerStateMachine::BeginMainFrameStateToString(
return "BeginMainFrameState::IDLE"; return "BeginMainFrameState::IDLE";
case BeginMainFrameState::SENT: case BeginMainFrameState::SENT:
return "BeginMainFrameState::SENT"; return "BeginMainFrameState::SENT";
case BeginMainFrameState::STARTED:
return "BeginMainFrameState::STARTED";
case BeginMainFrameState::READY_TO_COMMIT: case BeginMainFrameState::READY_TO_COMMIT:
return "BeginMainFrameState::READY_TO_COMMIT"; return "BeginMainFrameState::READY_TO_COMMIT";
} }
...@@ -719,8 +717,7 @@ bool SchedulerStateMachine::ShouldDeferInvalidatingForMainFrame() const { ...@@ -719,8 +717,7 @@ 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_ == BeginMainFrameState::SENT || if (begin_main_frame_state_ == BeginMainFrameState::SENT)
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
...@@ -1147,8 +1144,7 @@ void SchedulerStateMachine::OnBeginImplFrameIdle() { ...@@ -1147,8 +1144,7 @@ void SchedulerStateMachine::OnBeginImplFrameIdle() {
main_thread_missed_last_deadline_ = main_thread_missed_last_deadline_ =
CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_; CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_;
main_thread_failed_to_respond_last_deadline_ = main_thread_failed_to_respond_last_deadline_ =
begin_main_frame_state_ == BeginMainFrameState::SENT || begin_main_frame_state_ == BeginMainFrameState::SENT;
begin_main_frame_state_ == BeginMainFrameState::STARTED;
// If we're entering a state where we won't get BeginFrames set all the // 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. // funnels so that we don't perform any actions that we shouldn't.
...@@ -1377,7 +1373,7 @@ void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { ...@@ -1377,7 +1373,7 @@ void SchedulerStateMachine::SetNeedsOneBeginImplFrame() {
} }
void SchedulerStateMachine::NotifyReadyToCommit() { void SchedulerStateMachine::NotifyReadyToCommit() {
DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::STARTED) DCHECK_EQ(begin_main_frame_state_, BeginMainFrameState::SENT)
<< AsValue()->ToString(); << AsValue()->ToString();
begin_main_frame_state_ = BeginMainFrameState::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,
...@@ -1387,7 +1383,7 @@ void SchedulerStateMachine::NotifyReadyToCommit() { ...@@ -1387,7 +1383,7 @@ void SchedulerStateMachine::NotifyReadyToCommit() {
} }
void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { 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 // 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.
...@@ -1493,11 +1489,6 @@ void SchedulerStateMachine::DidCreateAndInitializeLayerTreeFrameSink() { ...@@ -1493,11 +1489,6 @@ void SchedulerStateMachine::DidCreateAndInitializeLayerTreeFrameSink() {
main_thread_missed_last_deadline_ = false; 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 { bool SchedulerStateMachine::HasInitializedLayerTreeFrameSink() const {
switch (layer_tree_frame_sink_state_) { switch (layer_tree_frame_sink_state_) {
case LayerTreeFrameSinkState::NONE: case LayerTreeFrameSinkState::NONE:
......
...@@ -88,13 +88,15 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -88,13 +88,15 @@ class CC_EXPORT SchedulerStateMachine {
BeginImplFrameDeadlineMode mode); BeginImplFrameDeadlineMode mode);
enum class BeginMainFrameState { enum class BeginMainFrameState {
IDLE, IDLE, // A new BeginMainFrame can start.
SENT, SENT, // A BeginMainFrame has already been issued.
STARTED, READY_TO_COMMIT, // A previously issued BeginMainFrame has been processed,
READY_TO_COMMIT, // and is ready to commit.
}; };
static const char* BeginMainFrameStateToString(BeginMainFrameState state); 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 { enum class ForcedRedrawOnTimeoutState {
IDLE, IDLE,
WAITING_FOR_COMMIT, WAITING_FOR_COMMIT,
...@@ -109,9 +111,7 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -109,9 +111,7 @@ class CC_EXPORT SchedulerStateMachine {
} }
bool CommitPending() const { bool CommitPending() const {
return begin_main_frame_state_ == BeginMainFrameState::SENT || return begin_main_frame_state_ != BeginMainFrameState::IDLE;
begin_main_frame_state_ == BeginMainFrameState::STARTED ||
begin_main_frame_state_ == BeginMainFrameState::READY_TO_COMMIT;
} }
bool NewActiveTreeLikely() const { bool NewActiveTreeLikely() const {
...@@ -271,9 +271,6 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -271,9 +271,6 @@ class CC_EXPORT SchedulerStateMachine {
// frame sink is not ready to receive frames. // frame sink is not ready to receive frames.
void SetSkipDraw(bool skip); void SetSkipDraw(bool skip);
// Indicates that scheduled BeginMainFrame is started.
void NotifyBeginMainFrameStarted();
// Indicates that the pending tree is ready for activation. Returns whether // Indicates that the pending tree is ready for activation. Returns whether
// the notification received updated the state for the current pending tree, // the notification received updated the state for the current pending tree,
// if any. // if any.
...@@ -383,6 +380,9 @@ class CC_EXPORT SchedulerStateMachine { ...@@ -383,6 +380,9 @@ class CC_EXPORT SchedulerStateMachine {
LayerTreeFrameSinkState::NONE; LayerTreeFrameSinkState::NONE;
BeginImplFrameState begin_impl_frame_state_ = BeginImplFrameState::IDLE; BeginImplFrameState begin_impl_frame_state_ = BeginImplFrameState::IDLE;
BeginMainFrameState begin_main_frame_state_ = BeginMainFrameState::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 forced_redraw_state_ =
ForcedRedrawOnTimeoutState::IDLE; ForcedRedrawOnTimeoutState::IDLE;
......
...@@ -395,7 +395,7 @@ bool ProxyImpl::IsBeginMainFrameExpected() { ...@@ -395,7 +395,7 @@ bool ProxyImpl::IsBeginMainFrameExpected() {
// not responded to a previously dispatched BeginMainFrame, then assume that // not responded to a previously dispatched BeginMainFrame, then assume that
// main-thread would want to produce an update for the current frame too. // main-thread would want to produce an update for the current frame too.
return scheduler_->needs_begin_main_frame() || return scheduler_->needs_begin_main_frame() ||
scheduler_->IsBeginMainFrameSentOrStarted(); scheduler_->IsBeginMainFrameSent();
} }
void ProxyImpl::RenewTreePriority() { 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