| Index: cc/scheduler/scheduler_state_machine.cc
|
| diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
|
| index cb14cadf52acd3beeb3a7f91f6b7c89c8f4308f1..dbafc244f1c5559875ec29ffd736c6c2571ed2d8 100644
|
| --- a/cc/scheduler/scheduler_state_machine.cc
|
| +++ b/cc/scheduler/scheduler_state_machine.cc
|
| @@ -15,6 +15,7 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
|
| commit_state_(COMMIT_STATE_IDLE),
|
| commit_count_(0),
|
| current_frame_number_(0),
|
| + last_frame_number_where_begin_frame_sent_to_main_thread_(-1),
|
| last_frame_number_where_draw_was_called_(-1),
|
| last_frame_number_where_tree_activation_attempted_(-1),
|
| last_frame_number_where_check_for_completed_tile_uploads_called_(-1),
|
| @@ -184,7 +185,7 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
|
| return ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD;
|
|
|
| switch (commit_state_) {
|
| - case COMMIT_STATE_IDLE:
|
| + case COMMIT_STATE_IDLE: {
|
| if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE &&
|
| needs_forced_redraw_)
|
| return ACTION_DRAW_FORCED;
|
| @@ -205,14 +206,18 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
|
| return needs_forced_redraw_ ? ACTION_DRAW_FORCED
|
| : ACTION_DRAW_IF_POSSIBLE;
|
| }
|
| - if (needs_commit_ &&
|
| - ((visible_ && output_surface_state_ == OUTPUT_SURFACE_ACTIVE)
|
| - || needs_forced_commit_))
|
| + bool can_commit_this_frame =
|
| + visible_ &&
|
| + current_frame_number_ >
|
| + last_frame_number_where_begin_frame_sent_to_main_thread_;
|
| + if (needs_commit_ && ((can_commit_this_frame &&
|
| + output_surface_state_ == OUTPUT_SURFACE_ACTIVE) ||
|
| + needs_forced_commit_))
|
| // TODO(enne): Should probably drop the active tree on force commit.
|
| return has_pending_tree_ ? ACTION_NONE
|
| : ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD;
|
| return ACTION_NONE;
|
| -
|
| + }
|
| case COMMIT_STATE_FRAME_IN_PROGRESS:
|
| if (ShouldCheckForCompletedTileUploads())
|
| return ACTION_CHECK_FOR_COMPLETED_TILE_UPLOADS;
|
| @@ -276,10 +281,16 @@ void SchedulerStateMachine::UpdateState(Action action) {
|
|
|
| case ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD:
|
| DCHECK(!has_pending_tree_);
|
| - DCHECK(visible_ || needs_forced_commit_);
|
| + if (!needs_forced_commit_) {
|
| + DCHECK(visible_);
|
| + DCHECK_GT(current_frame_number_,
|
| + last_frame_number_where_begin_frame_sent_to_main_thread_);
|
| + }
|
| commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS;
|
| needs_commit_ = false;
|
| needs_forced_commit_ = false;
|
| + last_frame_number_where_begin_frame_sent_to_main_thread_ =
|
| + current_frame_number_;
|
| return;
|
|
|
| case ACTION_COMMIT:
|
| @@ -422,10 +433,12 @@ void SchedulerStateMachine::FinishCommit() {
|
| commit_state_ = COMMIT_STATE_READY_TO_COMMIT;
|
| }
|
|
|
| -void SchedulerStateMachine::BeginFrameAbortedByMainThread() {
|
| +void SchedulerStateMachine::BeginFrameAbortedByMainThread(bool cancel_commit) {
|
| DCHECK_EQ(commit_state_, COMMIT_STATE_FRAME_IN_PROGRESS);
|
| if (expect_immediate_begin_frame_for_main_thread_) {
|
| expect_immediate_begin_frame_for_main_thread_ = false;
|
| + } else if (cancel_commit) {
|
| + commit_state_ = COMMIT_STATE_IDLE;
|
| } else {
|
| commit_state_ = COMMIT_STATE_IDLE;
|
| SetNeedsCommit();
|
|
|