summaryrefslogtreecommitdiffstats
path: root/cc/scheduler
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 19:16:05 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 19:16:05 +0000
commit7cdbf5052f48103600f646dfbde9a1f96a7a9c2a (patch)
treea93c2215fa39751ecd24f91e762ad038f3587a2c /cc/scheduler
parent9e3223381bfc0f198beb5e4057adac1e79ba3284 (diff)
downloadchromium_src-7cdbf5052f48103600f646dfbde9a1f96a7a9c2a.zip
chromium_src-7cdbf5052f48103600f646dfbde9a1f96a7a9c2a.tar.gz
chromium_src-7cdbf5052f48103600f646dfbde9a1f96a7a9c2a.tar.bz2
Remove forced commit and readback from the scheduler.
This removes CompositeAndReadback support from the scheduler, since the code path is now removed. R=brianderson BUG=251936 Review URL: https://codereview.chromium.org/292533002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/scheduler')
-rw-r--r--cc/scheduler/draw_result.h2
-rw-r--r--cc/scheduler/scheduler.cc12
-rw-r--r--cc/scheduler/scheduler.h5
-rw-r--r--cc/scheduler/scheduler_state_machine.cc206
-rw-r--r--cc/scheduler/scheduler_state_machine.h23
-rw-r--r--cc/scheduler/scheduler_state_machine_unittest.cc695
-rw-r--r--cc/scheduler/scheduler_unittest.cc52
7 files changed, 195 insertions, 800 deletions
diff --git a/cc/scheduler/draw_result.h b/cc/scheduler/draw_result.h
index 6154b35..0809a41 100644
--- a/cc/scheduler/draw_result.h
+++ b/cc/scheduler/draw_result.h
@@ -12,8 +12,6 @@ enum DrawResult {
DRAW_SUCCESS,
DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
- // TODO(danakj): Remove this.
- DRAW_ABORTED_CANT_READBACK,
DRAW_ABORTED_CONTEXT_LOST,
DRAW_ABORTED_CANT_DRAW,
};
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index f73efec..e924d33 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -164,11 +164,6 @@ void Scheduler::SetNeedsCommit() {
ProcessScheduledActions();
}
-void Scheduler::SetNeedsForcedCommitForReadback() {
- state_machine_.SetNeedsForcedCommitForReadback();
- ProcessScheduledActions();
-}
-
void Scheduler::SetNeedsRedraw() {
state_machine_.SetNeedsRedraw();
ProcessScheduledActions();
@@ -192,9 +187,6 @@ void Scheduler::SetMaxSwapsPending(int max) {
void Scheduler::DidSwapBuffers() {
state_machine_.DidSwapBuffers();
- // Swap should not occur inside readback operation.
- DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_DRAW_AND_READBACK));
-
// There is no need to call ProcessScheduledActions here because
// swapping should not trigger any new actions.
if (!inside_process_scheduled_actions_) {
@@ -618,7 +610,6 @@ void Scheduler::ProcessScheduledActions() {
SchedulerStateMachine::Action action;
do {
- state_machine_.CheckInvariants();
action = state_machine_.NextAction();
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
"SchedulerStateMachine",
@@ -655,9 +646,6 @@ void Scheduler::ProcessScheduledActions() {
// No action is actually performed, but this allows the state machine to
// advance out of its waiting to draw state without actually drawing.
break;
- case SchedulerStateMachine::ACTION_DRAW_AND_READBACK:
- client_->ScheduledActionDrawAndReadback();
- break;
case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
client_->ScheduledActionBeginOutputSurfaceCreation();
break;
diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h
index aeb5e0b..a80d449 100644
--- a/cc/scheduler/scheduler.h
+++ b/cc/scheduler/scheduler.h
@@ -32,7 +32,6 @@ class SchedulerClient {
virtual void ScheduledActionSendBeginMainFrame() = 0;
virtual DrawResult ScheduledActionDrawAndSwapIfPossible() = 0;
virtual DrawResult ScheduledActionDrawAndSwapForced() = 0;
- virtual DrawResult ScheduledActionDrawAndReadback() = 0;
virtual void ScheduledActionAnimate() = 0;
virtual void ScheduledActionCommit() = 0;
virtual void ScheduledActionUpdateVisibleTiles() = 0;
@@ -76,10 +75,6 @@ class CC_EXPORT Scheduler {
void SetNeedsCommit();
- // Like SetNeedsCommit(), but ensures a commit will definitely happen even if
- // we are not visible. Will eventually result in a forced draw internally.
- void SetNeedsForcedCommitForReadback();
-
void SetNeedsRedraw();
void SetNeedsAnimate();
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
index 84a6185..febe1ff 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -19,7 +19,6 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE),
commit_state_(COMMIT_STATE_IDLE),
forced_redraw_state_(FORCED_REDRAW_STATE_IDLE),
- readback_state_(READBACK_STATE_IDLE),
commit_count_(0),
current_frame_number_(0),
last_frame_number_animate_performed_(-1),
@@ -47,8 +46,7 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
smoothness_takes_priority_(false),
skip_next_begin_main_frame_to_reduce_latency_(false),
skip_begin_main_frame_to_reduce_latency_(false),
- continuous_painting_(false),
- needs_back_to_back_readback_(false) {
+ continuous_painting_(false) {
}
const char* SchedulerStateMachine::OutputSurfaceStateToString(
@@ -104,28 +102,6 @@ const char* SchedulerStateMachine::CommitStateToString(CommitState state) {
return "???";
}
-const char* SchedulerStateMachine::SynchronousReadbackStateToString(
- SynchronousReadbackState state) {
- switch (state) {
- case READBACK_STATE_IDLE:
- return "READBACK_STATE_IDLE";
- case READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME:
- return "READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME";
- case READBACK_STATE_WAITING_FOR_COMMIT:
- return "READBACK_STATE_WAITING_FOR_COMMIT";
- case READBACK_STATE_WAITING_FOR_ACTIVATION:
- return "READBACK_STATE_WAITING_FOR_ACTIVATION";
- case READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK:
- return "READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK";
- case READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT:
- return "READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT";
- case READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION:
- return "READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION";
- }
- NOTREACHED();
- return "???";
-}
-
const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
ForcedRedrawOnTimeoutState state) {
switch (state) {
@@ -162,8 +138,6 @@ const char* SchedulerStateMachine::ActionToString(Action action) {
return "ACTION_DRAW_AND_SWAP_FORCED";
case ACTION_DRAW_AND_SWAP_ABORT:
return "ACTION_DRAW_AND_SWAP_ABORT";
- case ACTION_DRAW_AND_READBACK:
- return "ACTION_DRAW_AND_READBACK";
case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION";
case ACTION_MANAGE_TILES:
@@ -186,8 +160,6 @@ scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const {
major_state->SetString(
"forced_redraw_state",
ForcedRedrawOnTimeoutStateToString(forced_redraw_state_));
- major_state->SetString("readback_state",
- SynchronousReadbackStateToString(readback_state_));
state->Set("major_state", major_state.release());
scoped_ptr<base::DictionaryValue> timestamps_state(new base::DictionaryValue);
@@ -348,8 +320,7 @@ bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const {
// We want to clear the pipline of any pending draws and activations
// before starting output surface initialization. This allows us to avoid
// weird corner cases where we abort draws or force activation while we
- // are initializing the output surface and can potentially have a pending
- // readback.
+ // are initializing the output surface.
if (active_tree_needs_first_draw_ || has_pending_tree_)
return false;
@@ -359,16 +330,6 @@ bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const {
}
bool SchedulerStateMachine::ShouldDraw() const {
- // After a readback, make sure not to draw again until we've replaced the
- // readback commit with a real one.
- if (readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT ||
- readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION)
- return false;
-
- // Draw immediately for readbacks to unblock the main thread quickly.
- if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK)
- return true;
-
// If we need to abort draws, we should do so ASAP since the draw could
// be blocking other important actions (like output surface initialization),
// from occuring. If we are waiting for the first draw, then perfom the
@@ -469,15 +430,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
return false;
}
- // We want to handle readback commits immediately to unblock the main thread.
- // Note: This BeginMainFrame will correspond to the replacement commit that
- // comes after the readback commit itself, so we only send the BeginMainFrame
- // if a commit isn't already pending behind the readback.
- if (readback_state_ == READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME)
- return !CommitPending();
-
- // We do not need commits if we are not visible, unless there's a
- // request for a readback.
+ // We do not need commits if we are not visible.
if (!visible_)
return false;
@@ -561,9 +514,7 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
if (ShouldAnimate())
return ACTION_ANIMATE;
if (ShouldDraw()) {
- if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK)
- return ACTION_DRAW_AND_READBACK;
- else if (PendingDrawsShouldBeAborted())
+ 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;
@@ -579,13 +530,6 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
return ACTION_NONE;
}
-void SchedulerStateMachine::CheckInvariants() {
- // We should never try to perform a draw for readback and forced draw due to
- // timeout simultaneously.
- DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW &&
- readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK));
-}
-
void SchedulerStateMachine::UpdateState(Action action) {
switch (action) {
case ACTION_NONE:
@@ -613,12 +557,9 @@ void SchedulerStateMachine::UpdateState(Action action) {
settings_.main_frame_before_activation_enabled);
DCHECK(!active_tree_needs_first_draw_ ||
settings_.main_frame_before_draw_enabled);
- DCHECK(visible_ ||
- readback_state_ == READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME);
+ DCHECK(visible_);
commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
needs_commit_ = false;
- if (readback_state_ == READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME)
- readback_state_ = READBACK_STATE_WAITING_FOR_COMMIT;
last_frame_number_begin_main_frame_sent_ =
current_frame_number_;
return;
@@ -636,8 +577,7 @@ void SchedulerStateMachine::UpdateState(Action action) {
return;
}
- case ACTION_DRAW_AND_SWAP_ABORT:
- case ACTION_DRAW_AND_READBACK: {
+ case ACTION_DRAW_AND_SWAP_ABORT: {
bool did_request_swap = false;
UpdateStateOnDraw(did_request_swap);
return;
@@ -678,52 +618,28 @@ void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) {
// mostly as if we are not impl-side-painting since there is no pending tree.
has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted;
- // Update state related to readbacks.
- if (readback_state_ == READBACK_STATE_WAITING_FOR_COMMIT) {
- // Update the state if this is the readback commit.
- readback_state_ = has_pending_tree_
- ? READBACK_STATE_WAITING_FOR_ACTIVATION
- : READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK;
- } else if (readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT) {
- // Update the state if this is the commit replacing the readback commit.
- readback_state_ = has_pending_tree_
- ? READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION
- : READBACK_STATE_IDLE;
- } else {
- DCHECK(readback_state_ == READBACK_STATE_IDLE);
+ // 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;
}
- // Readbacks can interrupt output surface initialization and forced draws,
- // so we do not want to advance those states if we are in the middle of a
- // readback. Note: It is possible for the readback's replacement commit to
- // be the output surface's first commit and/or the forced redraw's commit.
- if (readback_state_ == READBACK_STATE_IDLE ||
- readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) {
- // 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;
- }
-
- // 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) {
- if (has_pending_tree_) {
- output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION;
- } else {
- output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
- needs_redraw_ = true;
- }
+ // 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) {
+ if (has_pending_tree_) {
+ output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION;
+ } else {
+ output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
+ needs_redraw_ = true;
}
}
// Update state if we have a new active tree to draw, or if the active tree
- // was unchanged but we need to do a readback or forced draw.
+ // was unchanged but we need to do a forced draw.
if (!has_pending_tree_ &&
(!commit_was_aborted ||
- readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK ||
forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)) {
needs_redraw_ = true;
active_tree_needs_first_draw_ = true;
@@ -746,27 +662,6 @@ void SchedulerStateMachine::UpdateStateOnActivation() {
if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION)
forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
- if (readback_state_ == READBACK_STATE_WAITING_FOR_ACTIVATION) {
- readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK;
- } else if (readback_state_ ==
- READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) {
- if (needs_back_to_back_readback_) {
- if (commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT) {
- // If main_frame_before_activation_enabled is true, it is possible that
- // we will have already sent the BeginMainFrame here.
- readback_state_ = READBACK_STATE_WAITING_FOR_COMMIT;
- } else {
- // Replacement commit for incoming forced commit should be scheduled
- // after current commit's draw & swap is finished.
- needs_commit_ = true;
- readback_state_ = READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME;
- }
- needs_back_to_back_readback_ = false;
- } else {
- readback_state_ = READBACK_STATE_IDLE;
- }
- }
-
has_pending_tree_ = false;
pending_tree_is_ready_for_activation_ = false;
active_tree_needs_first_draw_ = true;
@@ -774,22 +669,8 @@ void SchedulerStateMachine::UpdateStateOnActivation() {
}
void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) {
- DCHECK(readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT &&
- readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION)
- << *AsValue();
-
- if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) {
- // The draw corresponds to a readback commit.
- // We are blocking commits from the main thread until after this draw, so
- // we should not have a pending tree.
- DCHECK(!has_pending_tree_);
- // We transition to COMMIT_STATE_BEGIN_MAIN_FRAME_SENT because there is a
- // pending BeginMainFrame behind the readback request.
- commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
- readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT;
- } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) {
+ if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
- }
if (!has_pending_tree_ &&
commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) {
@@ -948,11 +829,6 @@ void SchedulerStateMachine::OnBeginImplFrameIdle() {
bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineEarly() const {
// TODO(brianderson): This should take into account multiple commit sources.
- // If we are in the middle of the readback, we won't swap, so there is
- // no reason to trigger the deadline early.
- if (readback_state_ != READBACK_STATE_IDLE)
- return false;
-
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)
return false;
@@ -1086,7 +962,6 @@ void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
NOTREACHED() << "Uninitialized DrawResult.";
break;
case DRAW_ABORTED_CANT_DRAW:
- case DRAW_ABORTED_CANT_READBACK:
case DRAW_ABORTED_CONTEXT_LOST:
NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:"
<< result;
@@ -1126,39 +1001,6 @@ void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; }
-void SchedulerStateMachine::SetNeedsForcedCommitForReadback() {
- // If this is called in READBACK_STATE_IDLE, this is a "first" readback
- // request.
- // If this is called in READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT, this
- // is a back-to-back readback request that started before the replacement
- // commit had a chance to land.
- // If this is called in READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION,
- // this is a readback-commit-readback request when replacement commit is in
- // impl-side painting.
- DCHECK(readback_state_ == READBACK_STATE_IDLE ||
- readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT ||
- readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION);
-
- if (readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) {
- // If new forced commit is requested when impl-side painting of replacement
- // commit is in progress, it should not interrupt the draw & swap of current
- // commit(replacement commit). New commit(incoming forced commit) should be
- // started after current commit is finished.
- needs_back_to_back_readback_ = true;
- } else if (commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT) {
- // If there is already a commit in progress when we get the readback request
- // then we don't need to send a BeginMainFrame for the replacement commit,
- // since there's already a BeginMainFrame behind the readback request. In
- // that case, we can skip READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME and go
- // directly to READBACK_STATE_WAITING_FOR_COMMIT.
- readback_state_ = READBACK_STATE_WAITING_FOR_COMMIT;
- } else {
- // Set needs_commit_ to true to trigger scheduling BeginMainFrame().
- needs_commit_ = true;
- readback_state_ = READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME;
- }
-}
-
void SchedulerStateMachine::NotifyReadyToCommit() {
DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED) << *AsValue();
commit_state_ = COMMIT_STATE_READY_TO_COMMIT;
@@ -1170,7 +1012,6 @@ void SchedulerStateMachine::BeginMainFrameAborted(bool did_handle) {
bool commit_was_aborted = true;
UpdateStateOnCommit(commit_was_aborted);
} else {
- DCHECK_NE(readback_state_, READBACK_STATE_WAITING_FOR_COMMIT);
commit_state_ = COMMIT_STATE_IDLE;
SetNeedsCommit();
}
@@ -1210,11 +1051,6 @@ void SchedulerStateMachine::DidCreateAndInitializeOutputSurface() {
void SchedulerStateMachine::NotifyBeginMainFrameStarted() {
DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
-
- DCHECK(readback_state_ == READBACK_STATE_IDLE ||
- readback_state_ == READBACK_STATE_WAITING_FOR_COMMIT ||
- readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT);
-
commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED;
}
diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h
index 9df9c08..a2a8b59 100644
--- a/cc/scheduler/scheduler_state_machine.h
+++ b/cc/scheduler/scheduler_state_machine.h
@@ -68,18 +68,6 @@ class CC_EXPORT SchedulerStateMachine {
};
static const char* CommitStateToString(CommitState state);
- enum SynchronousReadbackState {
- READBACK_STATE_IDLE,
- READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME,
- READBACK_STATE_WAITING_FOR_COMMIT,
- READBACK_STATE_WAITING_FOR_ACTIVATION,
- READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK,
- READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT,
- READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION,
- };
- static const char* SynchronousReadbackStateToString(
- SynchronousReadbackState state);
-
enum ForcedRedrawOnTimeoutState {
FORCED_REDRAW_STATE_IDLE,
FORCED_REDRAW_STATE_WAITING_FOR_COMMIT,
@@ -109,7 +97,6 @@ class CC_EXPORT SchedulerStateMachine {
ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
ACTION_DRAW_AND_SWAP_FORCED,
ACTION_DRAW_AND_SWAP_ABORT,
- ACTION_DRAW_AND_READBACK,
ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
ACTION_MANAGE_TILES,
};
@@ -120,8 +107,6 @@ class CC_EXPORT SchedulerStateMachine {
Action NextAction() const;
void UpdateState(Action action);
- void CheckInvariants();
-
// Indicates whether the impl thread needs a BeginImplFrame callback in order
// to make progress.
bool BeginFrameNeeded() const;
@@ -200,12 +185,6 @@ class CC_EXPORT SchedulerStateMachine {
// thread to main.
void SetNeedsCommit();
- // As SetNeedsCommit(), but ensures the BeginMainFrame will be sent even
- // if we are not visible. After this call we expect to go through
- // the forced commit flow and then return to waiting for a non-forced
- // BeginMainFrame to finish.
- void SetNeedsForcedCommitForReadback();
-
// Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME
// from NextAction.
// Indicates that all painting is complete.
@@ -285,7 +264,6 @@ class CC_EXPORT SchedulerStateMachine {
BeginImplFrameState begin_impl_frame_state_;
CommitState commit_state_;
ForcedRedrawOnTimeoutState forced_redraw_state_;
- SynchronousReadbackState readback_state_;
BeginFrameArgs begin_impl_frame_args_;
@@ -322,7 +300,6 @@ class CC_EXPORT SchedulerStateMachine {
bool skip_next_begin_main_frame_to_reduce_latency_;
bool skip_begin_main_frame_to_reduce_latency_;
bool continuous_painting_;
- bool needs_back_to_back_readback_;
private:
DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc
index b39d50d..299a1fd 100644
--- a/cc/scheduler/scheduler_state_machine_unittest.cc
+++ b/cc/scheduler/scheduler_state_machine_unittest.cc
@@ -74,9 +74,6 @@ class StateMachine : public SchedulerStateMachine {
return output_surface_state_;
}
- void SetReadbackState(SynchronousReadbackState rs) { readback_state_ = rs; }
- SynchronousReadbackState readback_state() const { return readback_state_; }
-
bool NeedsCommit() const { return needs_commit_; }
void SetNeedsRedraw(bool b) { needs_redraw_ = b; }
@@ -89,15 +86,6 @@ class StateMachine : public SchedulerStateMachine {
return forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE;
}
- void SetNeedsForcedRedrawForReadback() {
- readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK;
- active_tree_needs_first_draw_ = true;
- }
-
- bool NeedsForcedRedrawForReadback() const {
- return readback_state_ != READBACK_STATE_IDLE;
- }
-
void SetActiveTreeNeedsFirstDraw(bool needs_first_draw) {
active_tree_needs_first_draw_ = needs_first_draw;
}
@@ -710,51 +698,36 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) {
// When in BeginImplFrame deadline we should always draw for SetNeedsRedraw
// except if we're ready to commit, in which case we expect a commit first.
- // SetNeedsForcedRedrawForReadback should take precedence over all and
- // issue a readback.
for (size_t i = 0; i < num_commit_states; ++i) {
- for (size_t j = 0; j < 2; ++j) {
- bool request_readback = j;
+ StateMachine state(default_scheduler_settings);
+ state.SetCanStart();
+ state.UpdateState(state.NextAction());
+ state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
+ state.SetCanDraw(true);
+ state.SetCommitState(all_commit_states[i]);
+ state.SetBeginImplFrameState(
+ SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
- StateMachine state(default_scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetCanDraw(true);
- state.SetCommitState(all_commit_states[i]);
- state.SetBeginImplFrameState(
- SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
-
- if (request_readback) {
- state.SetNeedsForcedRedrawForReadback();
- } else {
- state.SetNeedsRedraw(true);
- state.SetVisible(true);
- }
+ state.SetNeedsRedraw(true);
+ state.SetVisible(true);
- SchedulerStateMachine::Action expected_action;
- if (request_readback) {
- expected_action = SchedulerStateMachine::ACTION_DRAW_AND_READBACK;
- } else if (all_commit_states[i] ==
- SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) {
- expected_action = SchedulerStateMachine::ACTION_COMMIT;
- } else {
- expected_action =
- SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE;
- EXPECT_EQ(state.NextAction(), SchedulerStateMachine::ACTION_ANIMATE)
- << *state.AsValue();
- state.UpdateState(state.NextAction());
- }
+ SchedulerStateMachine::Action expected_action;
+ if (all_commit_states[i] ==
+ SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) {
+ expected_action = SchedulerStateMachine::ACTION_COMMIT;
+ } else {
+ expected_action = SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE;
+ EXPECT_EQ(state.NextAction(), SchedulerStateMachine::ACTION_ANIMATE)
+ << *state.AsValue();
+ state.UpdateState(state.NextAction());
+ }
- // Case 1: needs_commit=false.
- EXPECT_NE(state.BeginFrameNeeded(), request_readback) << *state.AsValue();
- EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
+ // Case 1: needs_commit=false.
+ EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
- // Case 2: needs_commit=true.
- state.SetNeedsCommit();
- EXPECT_NE(state.BeginFrameNeeded(), request_readback) << *state.AsValue();
- EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
- }
+ // Case 2: needs_commit=true.
+ state.SetNeedsCommit();
+ EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
}
}
@@ -1155,6 +1128,152 @@ TEST(SchedulerStateMachineTest, AbortBeginMainFrameAndCancelCommit) {
state.NextAction());
}
+TEST(SchedulerStateMachineTest,
+ AbortBeginMainFrameAndCancelCommitWhenInvisible) {
+ SchedulerSettings default_scheduler_settings;
+ StateMachine state(default_scheduler_settings);
+ state.SetCanStart();
+ state.UpdateState(state.NextAction());
+ state.DidCreateAndInitializeOutputSurface();
+ state.SetVisible(true);
+ state.SetCanDraw(true);
+
+ // Get into a begin frame / commit state.
+ state.SetNeedsCommit();
+
+ EXPECT_ACTION_UPDATE_STATE(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
+ state.CommitState());
+ EXPECT_FALSE(state.NeedsCommit());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+
+ // Become invisible and abort BeginMainFrame.
+ state.SetVisible(false);
+ state.BeginMainFrameAborted(true);
+
+ // Verify that another commit doesn't start on the same frame.
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+ EXPECT_FALSE(state.NeedsCommit());
+
+ // Become visible and start a new frame.
+ state.SetVisible(true);
+ state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
+ EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
+ EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
+
+ // Draw because this is the first frame since output surface init'd.
+ state.OnBeginImplFrameDeadline();
+ EXPECT_ACTION_UPDATE_STATE(
+ SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
+ state.DidSwapBuffers();
+ state.DidSwapBuffersComplete();
+
+ // Verify another commit doesn't start on another frame either.
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+ EXPECT_FALSE(state.NeedsCommit());
+
+ // Verify another commit can start if requested, though.
+ state.SetNeedsCommit();
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME,
+ state.NextAction());
+}
+
+TEST(SchedulerStateMachineTest,
+ AbortBeginMainFrameAndRequestCommitWhenInvisible) {
+ SchedulerSettings default_scheduler_settings;
+ StateMachine state(default_scheduler_settings);
+ state.SetCanStart();
+ state.UpdateState(state.NextAction());
+ state.DidCreateAndInitializeOutputSurface();
+ state.SetVisible(true);
+ state.SetCanDraw(true);
+
+ // Get into a begin frame / commit state.
+ state.SetNeedsCommit();
+
+ EXPECT_ACTION_UPDATE_STATE(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
+ state.CommitState());
+ EXPECT_FALSE(state.NeedsCommit());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+
+ // Become invisible and abort BeginMainFrame.
+ state.SetVisible(false);
+ state.BeginMainFrameAborted(true);
+
+ // Verify that another commit doesn't start on the same frame.
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+ EXPECT_FALSE(state.NeedsCommit());
+
+ // Asking for a commit while not visible won't make it happen.
+ state.SetNeedsCommit();
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+ EXPECT_TRUE(state.NeedsCommit());
+
+ // Become visible but nothing happens until the next frame.
+ state.SetVisible(true);
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+ EXPECT_TRUE(state.NeedsCommit());
+
+ // We should get that commit when we begin the next frame.
+ state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
+ EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
+ EXPECT_ACTION_UPDATE_STATE(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
+}
+
+TEST(SchedulerStateMachineTest,
+ AbortBeginMainFrameAndRequestCommitAndBeginImplFrameWhenInvisible) {
+ SchedulerSettings default_scheduler_settings;
+ StateMachine state(default_scheduler_settings);
+ state.SetCanStart();
+ state.UpdateState(state.NextAction());
+ state.DidCreateAndInitializeOutputSurface();
+ state.SetVisible(true);
+ state.SetCanDraw(true);
+
+ // Get into a begin frame / commit state.
+ state.SetNeedsCommit();
+
+ EXPECT_ACTION_UPDATE_STATE(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
+ state.CommitState());
+ EXPECT_FALSE(state.NeedsCommit());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+
+ // Become invisible and abort BeginMainFrame.
+ state.SetVisible(false);
+ state.BeginMainFrameAborted(true);
+
+ // Asking for a commit while not visible won't make it happen.
+ state.SetNeedsCommit();
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+ EXPECT_TRUE(state.NeedsCommit());
+
+ // Begin a frame when not visible, the scheduler animates but does not commit.
+ state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
+ EXPECT_TRUE(state.NeedsCommit());
+
+ // Become visible and the requested commit happens immediately.
+ state.SetVisible(true);
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
+ EXPECT_ACTION_UPDATE_STATE(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
+}
+
TEST(SchedulerStateMachineTest, TestFirstContextCreation) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
@@ -1430,51 +1549,6 @@ TEST(SchedulerStateMachineTest,
EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
}
-TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) {
- SchedulerSettings default_scheduler_settings;
- StateMachine state(default_scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(true);
-
- // Cause a lost context lost.
- state.DidLoseOutputSurface();
-
- // Ask a forced redraw for readback and verify it ocurrs.
- state.SetNeedsForcedRedrawForReadback();
- state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- // Forced redraws for readbacks need to be followed by a new commit
- // to replace the readback commit.
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
- state.CommitState());
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-
- // We don't yet have an output surface, so we the draw and swap should abort.
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
-
- // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE
- EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
-
- state.OnBeginImplFrameDeadline();
- EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
-
- state.OnBeginImplFrameIdle();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
-
- // Ask a readback and verify it occurs.
- state.SetNeedsForcedRedrawForReadback();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-}
-
TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
@@ -1528,73 +1602,15 @@ TEST(SchedulerStateMachineTest,
EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
}
-TEST(SchedulerStateMachineTest,
- TestSendBeginMainFrameWhenInvisibleAndForceCommit) {
+TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
state.UpdateState(state.NextAction());
state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
state.SetVisible(false);
- state.SetNeedsForcedCommitForReadback();
- EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME,
- state.NextAction());
-}
-
-TEST(SchedulerStateMachineTest,
- TestSendBeginMainFrameWhenCanStartFalseAndForceCommit) {
- SchedulerSettings default_scheduler_settings;
- StateMachine state(default_scheduler_settings);
- state.SetVisible(true);
- state.SetCanDraw(true);
- state.SetNeedsForcedCommitForReadback();
- EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME,
- state.NextAction());
-}
-
-// If new commit is not requested explicitly after starting forced commit,
-// new commit should not scheduled after drawing the replacement commit.
-TEST(SchedulerStateMachineTest, DontMakeNewCommitAfterDrawingReplaceCommit) {
- SchedulerSettings default_scheduler_settings;
- StateMachine state(default_scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(true);
-
- // There is a scheduled commit.
- state.SetCommitState(
- SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
-
- // Request a forced commit.
- state.SetNeedsForcedCommitForReadback();
-
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
- EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_AND_READBACK,
- state.NextAction());
- state.UpdateState(state.NextAction());
- EXPECT_EQ(
- SchedulerStateMachine::READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT,
- state.readback_state());
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
- state.CommitState());
-
- // Finish the replacement commit.
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-
- state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
- state.OnBeginImplFrameDeadline();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
- EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_IDLE, state.readback_state());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
+ state.SetNeedsCommit();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) {
@@ -1617,214 +1633,6 @@ TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) {
EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
}
-TEST(SchedulerStateMachineTest, TestFinishCommitWhenForcedCommitInProgress) {
- SchedulerSettings default_scheduler_settings;
- StateMachine state(default_scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(false);
- state.SetCommitState(
- SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
- state.SetNeedsForcedCommitForReadback();
-
- // The commit for readback interupts the normal commit.
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-
- EXPECT_TRUE(state.active_tree_needs_first_draw());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
-
- // When the readback interrupts the normal commit, we should not get
- // another BeginMainFrame when the readback completes.
- EXPECT_NE(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME,
- state.NextAction());
-
- // The normal commit can then proceed.
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-}
-
-void TestForceCommitWhenReplacementActivationInProgress(
- bool main_frame_before_draw_enabled) {
- SchedulerSettings settings;
- settings.impl_side_painting = true;
- settings.main_frame_before_draw_enabled = main_frame_before_draw_enabled;
- StateMachine state(settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(true);
-
- // Impl-side painting of replacement commit is in-progress.
- if (settings.main_frame_before_draw_enabled) {
- state.SetCommitState(
- SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_ACTIVATION);
- } else {
- state.SetCommitState(
- SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
- }
- state.SetReadbackState(
- SchedulerStateMachine::READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION);
- state.SetHasPendingTree(true);
-
- // Forced commit is requested during the impl-side painting.
- state.SetNeedsForcedCommitForReadback();
- EXPECT_FALSE(state.NeedsCommit());
-
- state.NotifyReadyToActivate();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE);
- // New replacement commit is needed for incoming forced commit.
- EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME,
- state.readback_state());
- EXPECT_TRUE(state.NeedsCommit());
- if (settings.main_frame_before_draw_enabled) {
- // New replacement commit is scheduled.
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
- // Forced commit is started.
- EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_WAITING_FOR_COMMIT,
- state.readback_state());
- }
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
- // Perform the draw & swap of replacement commit.
- state.OnBeginImplFrameDeadline();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
- state.DidSwapBuffers();
- state.DidSwapBuffersComplete();
- if (!settings.main_frame_before_draw_enabled) {
- // New replacement commit is scheduled.
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
- // Forced commit is started.
- EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_WAITING_FOR_COMMIT,
- state.readback_state());
- }
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_NONE);
-
- // Finish the forced commit and draw it.
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
- state.NotifyReadyToActivate();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK)
- EXPECT_EQ(
- SchedulerStateMachine::READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT,
- state.readback_state());
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
- state.CommitState());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- // Finish the replacement commit and draw it.
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
- state.NotifyReadyToActivate();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE);
- state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
- state.OnBeginImplFrameDeadline();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
- state.DidSwapBuffers();
- state.DidSwapBuffersComplete();
- EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_IDLE, state.readback_state());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-}
-
-// Explicitly test when main_frame_before_draw_enabled = true.
-TEST(SchedulerStateMachineTest,
- ForceCommitWhenReplacementActivationInProgressAndMainFrameEnabled) {
- bool main_frame_before_draw_enabled = true;
- TestForceCommitWhenReplacementActivationInProgress(
- main_frame_before_draw_enabled);
-}
-
-// Explicitly test when main_frame_before_draw_enabled = false.
-TEST(SchedulerStateMachineTest,
- ForceCommitWhenReplacementActivationInProgressAndMainFrameDisabled) {
- bool main_frame_before_draw_enabled = false;
- TestForceCommitWhenReplacementActivationInProgress(
- main_frame_before_draw_enabled);
-}
-
-// Test with main_frame_before_activation_enable = true;
-TEST(SchedulerStateMachineTest,
- ForceCommitWhenReplacementActivationInProgressWithMFBA) {
- SchedulerSettings settings;
- settings.impl_side_painting = true;
- settings.main_frame_before_activation_enabled = true;
- StateMachine state(settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(true);
-
- // When impl-side painting of replacement commit is in-progress, commit state
- // is idle because main_frame_before_activation is enabled.
- state.SetCommitState(
- SchedulerStateMachine::COMMIT_STATE_IDLE);
- state.SetReadbackState(
- SchedulerStateMachine::READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION);
- state.SetHasPendingTree(true);
-
- // New commit is requested and scheduled when impl-side painting is in
- // progress.
- state.SetNeedsCommit();
- state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- // Forced commit is requested during the impl-side painting.
- state.SetNeedsForcedCommitForReadback();
- EXPECT_FALSE(state.NeedsCommit());
-
- state.OnBeginImplFrameDeadline();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- state.NotifyReadyToActivate();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE);
- // Replacement commit for requested forced commit is already scheduled.
- EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_WAITING_FOR_COMMIT,
- state.readback_state());
- EXPECT_FALSE(state.NeedsCommit());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
- // Perform the draw & swap of replacement commit.
- state.OnBeginImplFrameDeadline();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
- state.DidSwapBuffers();
- state.DidSwapBuffersComplete();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_NONE);
-
- // forced commit is started.
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-}
-
TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
@@ -1851,161 +1659,6 @@ TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) {
state.SetVisible(false);
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction())
<< *state.AsValue();
-
- // If there is a forced commit, however, we could be blocking a readback
- // on the main thread, so we need to unblock it before we can get our
- // output surface, even if we are not visible.
- state.SetNeedsForcedCommitForReadback();
- EXPECT_EQ(
- SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME, state.NextAction())
- << *state.AsValue();
-}
-
-TEST(SchedulerStateMachineTest, TestImmediateFinishCommit) {
- SchedulerSettings default_scheduler_settings;
- StateMachine state(default_scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(true);
-
- // Schedule a readback, commit it, draw it.
- state.SetNeedsForcedCommitForReadback();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
-
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
-
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
- state.CommitState());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-
- EXPECT_TRUE(state.active_tree_needs_first_draw());
-
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
- state.DidSwapBuffers();
- state.DidDrawIfPossibleCompleted(DRAW_SUCCESS);
- state.DidSwapBuffersComplete();
-
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- // Should be waiting for the normal BeginMainFrame.
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
- state.CommitState());
-}
-
-TEST(SchedulerStateMachineTest, TestImmediateFinishCommitDuringCommit) {
- SchedulerSettings scheduler_settings;
- StateMachine state(scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(true);
-
- // Start a normal commit.
- state.SetNeedsCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- // Schedule a readback, commit it, draw it.
- state.SetNeedsForcedCommitForReadback();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
- state.CommitState());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-
- EXPECT_TRUE(state.active_tree_needs_first_draw());
-
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
- state.DidSwapBuffers();
- state.DidDrawIfPossibleCompleted(DRAW_SUCCESS);
- state.DidSwapBuffersComplete();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- // Should be waiting for the normal BeginMainFrame.
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
- state.CommitState())
- << *state.AsValue();
-}
-
-TEST(SchedulerStateMachineTest, ImmediateBeginMainFrameAbortedWhileInvisible) {
- SchedulerSettings scheduler_settings;
- StateMachine state(scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(true);
-
- state.SetNeedsCommit();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- state.SetNeedsForcedCommitForReadback();
- EXPECT_ACTION_UPDATE_STATE(
- SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
-
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
- state.CommitState());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-
- EXPECT_TRUE(state.active_tree_needs_first_draw());
-
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
- state.DidSwapBuffers();
- state.DidDrawIfPossibleCompleted(DRAW_SUCCESS);
- state.DidSwapBuffersComplete();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
-
- // Should be waiting for BeginMainFrame.
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
- state.CommitState())
- << *state.AsValue();
-
- // Become invisible and abort BeginMainFrame.
- state.SetVisible(false);
- state.BeginMainFrameAborted(false);
-
- // Should be back in the idle state, but needing a commit.
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
- EXPECT_TRUE(state.NeedsCommit());
-}
-
-TEST(SchedulerStateMachineTest, ImmediateFinishCommitWhileCantDraw) {
- SchedulerSettings default_scheduler_settings;
- StateMachine state(default_scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
- state.SetVisible(true);
- state.SetCanDraw(false);
-
- state.SetNeedsCommit();
- state.UpdateState(state.NextAction());
-
- state.SetNeedsForcedCommitForReadback();
- state.UpdateState(state.NextAction());
- state.NotifyBeginMainFrameStarted();
- state.NotifyReadyToCommit();
-
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
- state.CommitState());
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
-
- EXPECT_TRUE(state.active_tree_needs_first_draw());
-
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK);
- state.DidSwapBuffers();
- state.DidDrawIfPossibleCompleted(DRAW_SUCCESS);
- state.DidSwapBuffersComplete();
- EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
}
TEST(SchedulerStateMachineTest, ReportIfNotDrawing) {
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index c3d9f38..071fa58 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -134,11 +134,6 @@ class FakeSchedulerClient : public SchedulerClient {
states_.push_back(scheduler_->AsValue().release());
return DRAW_SUCCESS;
}
- virtual DrawResult ScheduledActionDrawAndReadback() OVERRIDE {
- actions_.push_back("ScheduledActionDrawAndReadback");
- states_.push_back(scheduler_->AsValue().release());
- return DRAW_SUCCESS;
- }
virtual void ScheduledActionCommit() OVERRIDE {
actions_.push_back("ScheduledActionCommit");
states_.push_back(scheduler_->AsValue().release());
@@ -645,53 +640,6 @@ TEST(SchedulerTest, NoSwapWhenDrawFails) {
EXPECT_EQ(2, client.num_draws());
}
-TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) {
- FakeSchedulerClient client;
- SchedulerSettings default_scheduler_settings;
- Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
-
- // Tell the client that it will fail to swap.
- client.SetDrawWillHappen(true);
- client.SetSwapWillHappenIfDrawHappens(false);
-
- // Get the compositor to do a ScheduledActionDrawAndReadback.
- scheduler->SetCanDraw(true);
- scheduler->SetNeedsRedraw();
- scheduler->SetNeedsForcedCommitForReadback();
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
- EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
-}
-
-TEST(SchedulerTest, BackToBackReadbackAllowed) {
- // Some clients call readbacks twice in a row before the replacement
- // commit comes in. Make sure it is allowed.
- FakeSchedulerClient client;
- SchedulerSettings default_scheduler_settings;
- Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
-
- // Get the compositor to do 2 ScheduledActionDrawAndReadbacks before
- // the replacement commit comes in.
- scheduler->SetCanDraw(true);
- scheduler->SetNeedsRedraw();
- scheduler->SetNeedsForcedCommitForReadback();
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
- EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
-
- client.Reset();
- scheduler->SetNeedsForcedCommitForReadback();
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
- EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
-
- // The replacement commit comes in after 2 readbacks.
- client.Reset();
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
-}
-
-
class SchedulerClientNeedsManageTilesInDraw : public FakeSchedulerClient {
public:
virtual DrawResult ScheduledActionDrawAndSwapIfPossible()