Index: cc/scheduler/scheduler_state_machine.cc |
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc |
index 009cf4bdb59e61ecaf44ae268efc1359caf24a19..9bd7b8484b0d8ad77c10fd8585ff32c4212fa1f3 100644 |
--- a/cc/scheduler/scheduler_state_machine.cc |
+++ b/cc/scheduler/scheduler_state_machine.cc |
@@ -23,8 +23,10 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
last_frame_number_where_begin_frame_sent_to_main_thread_(-1), |
last_frame_number_swap_performed_(-1), |
last_frame_number_where_update_visible_tiles_was_called_(-1), |
+ last_frame_number_where_manage_tiles_was_called_(-1), |
consecutive_failed_draws_(0), |
needs_redraw_(false), |
+ needs_manage_tiles_(false), |
swap_used_incomplete_tile_(false), |
needs_commit_(false), |
main_thread_needs_layer_textures_(false), |
@@ -146,6 +148,8 @@ const char* SchedulerStateMachine::ActionToString(Action action) { |
return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION"; |
case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: |
return "ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD"; |
+ case ACTION_MANAGE_TILES: |
+ return "ACTION_MANAGE_TILES"; |
} |
NOTREACHED(); |
return "???"; |
@@ -209,6 +213,7 @@ scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { |
minor_state->SetInteger("consecutive_failed_draws", |
consecutive_failed_draws_); |
minor_state->SetBoolean("needs_redraw", needs_redraw_); |
+ minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_); |
minor_state->SetBoolean("swap_used_incomplete_tile", |
swap_used_incomplete_tile_); |
minor_state->SetBoolean("needs_commit", needs_commit_); |
@@ -245,6 +250,11 @@ bool SchedulerStateMachine::HasSentBeginFrameToMainThreadThisFrame() const { |
last_frame_number_where_begin_frame_sent_to_main_thread_; |
} |
+bool SchedulerStateMachine::HasScheduledManageTilesThisFrame() const { |
+ return current_frame_number_ == |
+ last_frame_number_where_manage_tiles_was_called_; |
+} |
+ |
bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { |
// These are all the cases where we normally cannot or do not want to draw |
// but, if needs_redraw_ is true and we do not draw to make forward progress, |
@@ -442,6 +452,12 @@ bool SchedulerStateMachine::ShouldCommit() const { |
return commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
} |
+bool SchedulerStateMachine::ShouldManageTiles() const { |
enne (OOO)
2013/09/13 00:47:01
I liked the previous version of this patch where i
epennerAtGoogle
2013/09/13 00:53:06
Good catch! I was only thinking of the two top lev
brianderson
2013/09/13 00:59:52
The issue with restricting it to occur only inside
|
+ if (HasScheduledManageTilesThisFrame()) |
+ return false; |
+ return needs_manage_tiles_; |
+} |
+ |
SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { |
if (ShouldAcquireLayerTexturesForMainThread()) |
return ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD; |
@@ -461,6 +477,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { |
else |
return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; |
} |
+ if (ShouldManageTiles()) |
+ return ACTION_MANAGE_TILES; |
if (ShouldSendBeginFrameToMainThread()) |
return ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD; |
if (ShouldBeginOutputSurfaceCreation()) |
@@ -536,6 +554,10 @@ void SchedulerStateMachine::UpdateState(Action action) { |
texture_state_ = LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD; |
main_thread_needs_layer_textures_ = false; |
return; |
+ |
+ case ACTION_MANAGE_TILES: |
+ UpdateStateOnManageTiles(); |
+ return; |
} |
} |
@@ -677,6 +699,12 @@ void SchedulerStateMachine::UpdateStateOnDraw(bool did_swap) { |
last_frame_number_swap_performed_ = current_frame_number_; |
} |
+void SchedulerStateMachine::UpdateStateOnManageTiles() { |
+ needs_manage_tiles_ = false; |
+ last_frame_number_where_manage_tiles_was_called_ = |
+ current_frame_number_; |
+} |
+ |
void SchedulerStateMachine::SetMainThreadNeedsLayerTextures() { |
DCHECK(!main_thread_needs_layer_textures_); |
DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); |
@@ -740,6 +768,11 @@ bool SchedulerStateMachine::ProactiveBeginFrameWantedByImplThread() const { |
if (has_pending_tree_) |
return true; |
+ // Changing priorities may allow us to activate (given the new priorities), |
+ // which may result in a new frame. |
+ if (needs_manage_tiles_) |
+ return true; |
+ |
return false; |
} |
@@ -761,6 +794,10 @@ void SchedulerStateMachine::SetVisible(bool visible) { visible_ = visible; } |
void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } |
+void SchedulerStateMachine::SetNeedsManageTiles() { |
+ needs_manage_tiles_ = true; |
+} |
+ |
void SchedulerStateMachine::SetSwapUsedIncompleteTile( |
bool used_incomplete_tile) { |
swap_used_incomplete_tile_ = used_incomplete_tile; |