Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1725)

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 22320019: cc: Start commit early and block on tree activation (Closed) Base URL: http://git.chromium.org/chromium/src.git@usedl26
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler_state_machine.cc
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
index dbc026ca9f2e6be8403ec95fc7509ed13adcd6d6..df0ad9b0134d1801854a84f4c26247d5fad1c32c 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -223,6 +223,7 @@ bool SchedulerStateMachine::ShouldDraw() const {
return !active_tree_has_been_drawn_ &&
(commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW ||
commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION ||
+ commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS ||
(output_surface_state_ != OUTPUT_SURFACE_ACTIVE &&
!active_tree_is_null_));
}
@@ -306,12 +307,13 @@ bool SchedulerStateMachine::ShouldSendBeginFrameToMainThread() const {
return false;
// Only send BeginFrame to the main thread when idle.
- if (commit_state_ != COMMIT_STATE_IDLE)
+ if (commit_state_ != COMMIT_STATE_IDLE &&
+ commit_state_ != COMMIT_STATE_WAITING_FOR_ACTIVATION)
return false;
// We can't accept a commit if we have a pending tree.
- if (has_pending_tree_)
- return false;
+ //if (has_pending_tree_)
+ // return false;
// We want to handle readback commits ASAP.
if (readback_state_ == READBACK_STATE_FORCED_COMMIT_REQUESTED)
@@ -381,6 +383,7 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
return ACTION_NONE;
case COMMIT_STATE_FRAME_IN_PROGRESS:
+ case COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS:
if (ShouldUpdateVisibleTiles())
return ACTION_UPDATE_VISIBLE_TILES;
if (ShouldActivatePendingTree())
@@ -398,6 +401,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
return ACTION_COMMIT;
case COMMIT_STATE_WAITING_FOR_ACTIVATION: {
+ if (ShouldSendBeginFrameToMainThread())
+ return ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD;
if (ShouldUpdateVisibleTiles())
return ACTION_UPDATE_VISIBLE_TILES;
if (ShouldActivatePendingTree())
@@ -452,12 +457,15 @@ void SchedulerStateMachine::UpdateState(Action action) {
return;
case ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD:
- DCHECK(!has_pending_tree_);
+ //DCHECK(!has_pending_tree_);
DCHECK(visible_ ||
readback_state_ == READBACK_STATE_FORCED_COMMIT_REQUESTED ||
forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT ||
output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT);
- commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS;
+ if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION)
+ commit_state_ = COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS;
+ else
+ commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS;
needs_commit_ = false;
if (readback_state_ == READBACK_STATE_FORCED_COMMIT_REQUESTED)
readback_state_ = READBACK_STATE_FORCED_COMMIT_PENDING;
@@ -632,7 +640,8 @@ void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; }
void SchedulerStateMachine::SetNeedsForcedCommitForReadback() {
DCHECK(readback_state_ == READBACK_STATE_IDLE ||
readback_state_ == READBACK_STATE_REPLACEMENT_COMMIT_PENDING);
- if (commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS)
+ if (commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS ||
+ commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS)
readback_state_ = READBACK_STATE_FORCED_COMMIT_PENDING;
else
readback_state_ = READBACK_STATE_FORCED_COMMIT_REQUESTED;
@@ -640,13 +649,15 @@ void SchedulerStateMachine::SetNeedsForcedCommitForReadback() {
void SchedulerStateMachine::FinishCommit() {
DCHECK(commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS ||
+ commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS ||
readback_state_ == READBACK_STATE_FORCED_COMMIT_PENDING)
<< ToString();
commit_state_ = COMMIT_STATE_READY_TO_COMMIT;
}
void SchedulerStateMachine::BeginFrameAbortedByMainThread(bool did_handle) {
- DCHECK_EQ(commit_state_, COMMIT_STATE_FRAME_IN_PROGRESS);
+ DCHECK(commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS ||
+ commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS);
if (readback_state_ == READBACK_STATE_FORCED_COMMIT_REQUESTED) {
readback_state_ = READBACK_STATE_IDLE;
} else if (did_handle) {
@@ -688,7 +699,8 @@ void SchedulerStateMachine::SetHasTrees(bool has_pending_tree,
if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION)
output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
- DCHECK_EQ(COMMIT_STATE_WAITING_FOR_ACTIVATION, commit_state_);
+ DCHECK(commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION ||
+ commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS);
if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) {
commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW;
forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
@@ -696,7 +708,10 @@ void SchedulerStateMachine::SetHasTrees(bool has_pending_tree,
commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW;
readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK;
} else {
- commit_state_ = COMMIT_STATE_IDLE;
+ if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION_AND_FRAME_IN_PROGRESS)
+ commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS;
+ else
+ commit_state_ = COMMIT_STATE_IDLE;
if (readback_state_ == READBACK_STATE_REPLACEMENT_COMMIT_ACTIVATING)
readback_state_ = READBACK_STATE_IDLE;
}

Powered by Google App Engine
This is Rietveld 408576698