Index: cc/scheduler/scheduler_state_machine.cc |
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc |
index 9a08819081ec08e1aac732abc73f56c41e97a4c3..d4e54387619e9061a6cfd185379b845dd7261260 100644 |
--- a/cc/scheduler/scheduler_state_machine.cc |
+++ b/cc/scheduler/scheduler_state_machine.cc |
@@ -22,12 +22,14 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
readback_state_(READBACK_STATE_IDLE), |
commit_count_(0), |
current_frame_number_(0), |
+ last_frame_number_animate_performed_(-1), |
last_frame_number_swap_performed_(-1), |
last_frame_number_begin_main_frame_sent_(-1), |
last_frame_number_update_visible_tiles_was_called_(-1), |
manage_tiles_funnel_(0), |
consecutive_checkerboard_animations_(0), |
needs_redraw_(false), |
+ needs_animate_(false), |
needs_manage_tiles_(false), |
swap_used_incomplete_tile_(false), |
needs_commit_(false), |
@@ -44,7 +46,8 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
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) {} |
+ needs_back_to_back_readback_(false) { |
+} |
const char* SchedulerStateMachine::OutputSurfaceStateToString( |
OutputSurfaceState state) { |
@@ -141,6 +144,8 @@ const char* SchedulerStateMachine::ActionToString(Action action) { |
switch (action) { |
case ACTION_NONE: |
return "ACTION_NONE"; |
+ case ACTION_ANIMATE: |
+ return "ACTION_ANIMATE"; |
case ACTION_SEND_BEGIN_MAIN_FRAME: |
return "ACTION_SEND_BEGIN_MAIN_FRAME"; |
case ACTION_COMMIT: |
@@ -214,6 +219,8 @@ scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { |
minor_state->SetInteger("commit_count", commit_count_); |
minor_state->SetInteger("current_frame_number", current_frame_number_); |
+ minor_state->SetInteger("last_frame_number_animate_performed", |
+ last_frame_number_animate_performed_); |
minor_state->SetInteger("last_frame_number_swap_performed", |
last_frame_number_swap_performed_); |
minor_state->SetInteger( |
@@ -227,6 +234,7 @@ scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { |
minor_state->SetInteger("consecutive_checkerboard_animations", |
consecutive_checkerboard_animations_); |
minor_state->SetBoolean("needs_redraw", needs_redraw_); |
+ minor_state->SetBoolean("needs_animate_", needs_animate_); |
minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_); |
minor_state->SetBoolean("swap_used_incomplete_tile", |
swap_used_incomplete_tile_); |
@@ -419,6 +427,20 @@ bool SchedulerStateMachine::ShouldUpdateVisibleTiles() const { |
return false; |
} |
+bool SchedulerStateMachine::ShouldAnimate() const { |
+ if (!can_draw_) |
+ return false; |
+ |
+ if (last_frame_number_animate_performed_ == current_frame_number_) |
+ return false; |
+ |
+ if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && |
+ begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
+ return false; |
+ |
+ return needs_redraw_ || needs_animate_; |
+} |
+ |
bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { |
if (!needs_commit_) |
return false; |
@@ -518,6 +540,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { |
return ACTION_ACTIVATE_PENDING_TREE; |
if (ShouldCommit()) |
return ACTION_COMMIT; |
+ if (ShouldAnimate()) |
+ return ACTION_ANIMATE; |
if (ShouldDraw()) { |
if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) |
return ACTION_DRAW_AND_READBACK; |
@@ -558,6 +582,14 @@ void SchedulerStateMachine::UpdateState(Action action) { |
UpdateStateOnActivation(); |
return; |
+ case ACTION_ANIMATE: |
+ last_frame_number_animate_performed_ = current_frame_number_; |
+ needs_animate_ = false; |
+ // TODO(skyostil): Instead of assuming this, require the client to tell |
+ // us. |
+ SetNeedsRedraw(); |
+ return; |
+ |
case ACTION_SEND_BEGIN_MAIN_FRAME: |
DCHECK(!has_pending_tree_ || |
settings_.main_frame_before_activation_enabled); |
@@ -823,6 +855,9 @@ bool SchedulerStateMachine::BeginFrameNeededToDraw() const { |
if (swap_used_incomplete_tile_) |
return true; |
+ if (needs_animate_) |
brianderson
2014/04/18 01:10:54
If the BeginFrame is needed to advance the animati
Sami
2014/04/22 10:34:33
It feels like an animation request is a stronger s
|
+ return true; |
+ |
return needs_redraw_; |
} |
@@ -988,6 +1023,10 @@ void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; } |
void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } |
+void SchedulerStateMachine::SetNeedsAnimate() { |
+ needs_animate_ = true; |
+} |
+ |
void SchedulerStateMachine::SetNeedsManageTiles() { |
if (!needs_manage_tiles_) { |
TRACE_EVENT0("cc", |