diff options
author | skyostil@google.com <skyostil@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-29 15:50:04 +0000 |
---|---|---|
committer | skyostil@google.com <skyostil@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-29 15:50:04 +0000 |
commit | 0c543754c61af2c6c038b7b6facb56a301c2dbbb (patch) | |
tree | 9de65b9e432e077aaab51f75dbfccaac292095bd /cc | |
parent | 07b8fe1ca6539d166b95e90464aac504879c8204 (diff) | |
download | chromium_src-0c543754c61af2c6c038b7b6facb56a301c2dbbb.zip chromium_src-0c543754c61af2c6c038b7b6facb56a301c2dbbb.tar.gz chromium_src-0c543754c61af2c6c038b7b6facb56a301c2dbbb.tar.bz2 |
Revert 266624 "cc: Split animating and drawing into separate act..."
> cc: Split animating and drawing into separate actions
>
> Split impl-side animating and drawing into separate actions. This is
> needed to allow for the possibility of a commit between animating and
> drawing so that the main thread gets a chance to consume the new
> animation state. In particular this allows the main thread to
> synchronize with a fling animation using an onscroll handler.
>
> BUG=347366
>
> Review URL: https://codereview.chromium.org/206793003
Reason for revert: Broke some downstream unit tests.
TBR=skyostil@chromium.org
BUG=368064
Review URL: https://codereview.chromium.org/254883004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/animation/layer_animation_controller.cc | 1 | ||||
-rw-r--r-- | cc/input/input_handler.h | 2 | ||||
-rw-r--r-- | cc/scheduler/scheduler.cc | 8 | ||||
-rw-r--r-- | cc/scheduler/scheduler.h | 3 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine.cc | 51 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine.h | 9 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine_unittest.cc | 111 | ||||
-rw-r--r-- | cc/scheduler/scheduler_unittest.cc | 52 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_impl_client.h | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 37 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 46 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_animation.cc | 64 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 4 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 1 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 41 | ||||
-rw-r--r-- | cc/trees/thread_proxy.h | 13 |
17 files changed, 67 insertions, 385 deletions
diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc index 5a9337c..464801c 100644 --- a/cc/animation/layer_animation_controller.cc +++ b/cc/animation/layer_animation_controller.cc @@ -205,7 +205,6 @@ void LayerAnimationController::UpdateState(bool start_ready_animations, if (!HasActiveValueObserver()) return; - DCHECK(last_tick_time_); if (start_ready_animations) PromoteStartedAnimations(last_tick_time_, events); diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h index e78a8d1..774e011 100644 --- a/cc/input/input_handler.h +++ b/cc/input/input_handler.h @@ -125,7 +125,7 @@ class CC_EXPORT InputHandler { base::TimeDelta duration) = 0; // Request another callback to InputHandlerClient::Animate(). - virtual void SetNeedsAnimate() = 0; + virtual void ScheduleAnimation() = 0; virtual bool HaveTouchEventHandlersAt(const gfx::Point& viewport_point) = 0; diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc index 2417455..df7f166 100644 --- a/cc/scheduler/scheduler.cc +++ b/cc/scheduler/scheduler.cc @@ -174,11 +174,6 @@ void Scheduler::SetNeedsRedraw() { ProcessScheduledActions(); } -void Scheduler::SetNeedsAnimate() { - state_machine_.SetNeedsAnimate(); - ProcessScheduledActions(); -} - void Scheduler::SetNeedsManageTiles() { DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_MANAGE_TILES)); state_machine_.SetNeedsManageTiles(); @@ -635,9 +630,6 @@ void Scheduler::ProcessScheduledActions() { switch (action) { case SchedulerStateMachine::ACTION_NONE: break; - case SchedulerStateMachine::ACTION_ANIMATE: - client_->ScheduledActionAnimate(); - break; case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: client_->ScheduledActionSendBeginMainFrame(); break; diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h index 1e59192..0d34f03 100644 --- a/cc/scheduler/scheduler.h +++ b/cc/scheduler/scheduler.h @@ -33,7 +33,6 @@ class SchedulerClient { virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() = 0; virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() = 0; virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0; - virtual void ScheduledActionAnimate() = 0; virtual void ScheduledActionCommit() = 0; virtual void ScheduledActionUpdateVisibleTiles() = 0; virtual void ScheduledActionActivatePendingTree() = 0; @@ -82,8 +81,6 @@ class CC_EXPORT Scheduler { void SetNeedsRedraw(); - void SetNeedsAnimate(); - void SetNeedsManageTiles(); void SetMaxSwapsPending(int max); diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc index 0ddaa30..647af71 100644 --- a/cc/scheduler/scheduler_state_machine.cc +++ b/cc/scheduler/scheduler_state_machine.cc @@ -22,7 +22,6 @@ 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), @@ -31,7 +30,6 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) max_pending_swaps_(1), pending_swaps_(0), needs_redraw_(false), - needs_animate_(false), needs_manage_tiles_(false), swap_used_incomplete_tile_(false), needs_commit_(false), @@ -48,8 +46,7 @@ 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) { @@ -146,8 +143,6 @@ 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: @@ -221,8 +216,6 @@ 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( @@ -238,7 +231,6 @@ scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { minor_state->SetInteger("max_pending_swaps_", max_pending_swaps_); minor_state->SetInteger("pending_swaps_", pending_swaps_); 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_); @@ -435,20 +427,6 @@ 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; @@ -553,8 +531,6 @@ 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; @@ -595,14 +571,6 @@ 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); @@ -815,9 +783,9 @@ bool SchedulerStateMachine::BeginFrameNeeded() const { // To poll for state with the synchronous compositor without having to draw, // we rely on ShouldPollForAnticipatedDrawTriggers instead. if (!SupportsProactiveBeginFrame()) - return BeginFrameNeededToAnimateOrDraw(); + return BeginFrameNeededToDraw(); - return BeginFrameNeededToAnimateOrDraw() || ProactiveBeginFrameWanted(); + return BeginFrameNeededToDraw() || ProactiveBeginFrameWanted(); } bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { @@ -825,7 +793,7 @@ bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { // ProactiveBeginFrameWanted when we are using the synchronous // compositor. if (!SupportsProactiveBeginFrame()) { - return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted(); + return !BeginFrameNeededToDraw() && ProactiveBeginFrameWanted(); } // Non synchronous compositors should rely on @@ -844,8 +812,8 @@ bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { } // These are the cases where we definitely (or almost definitely) have a -// new frame to animate and/or draw and can draw. -bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { +// new frame to draw and can draw. +bool SchedulerStateMachine::BeginFrameNeededToDraw() const { // The output surface is the provider of BeginImplFrames, so we are not going // to get them even if we ask for them. if (!HasInitializedOutputSurface()) @@ -870,9 +838,6 @@ bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { if (swap_used_incomplete_tile_) return true; - if (needs_animate_) - return true; - return needs_redraw_; } @@ -1042,10 +1007,6 @@ 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", diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h index e7d05e6..2779264 100644 --- a/cc/scheduler/scheduler_state_machine.h +++ b/cc/scheduler/scheduler_state_machine.h @@ -101,7 +101,6 @@ class CC_EXPORT SchedulerStateMachine { enum Action { ACTION_NONE, - ACTION_ANIMATE, ACTION_SEND_BEGIN_MAIN_FRAME, ACTION_COMMIT, ACTION_UPDATE_VISIBLE_TILES, @@ -165,9 +164,6 @@ class CC_EXPORT SchedulerStateMachine { void SetNeedsRedraw(); bool needs_redraw() const { return needs_redraw_; } - void SetNeedsAnimate(); - bool needs_animate() const { return needs_animate_; } - // Indicates that manage-tiles is required. This guarantees another // ManageTiles will occur shortly (even if no redraw is required). void SetNeedsManageTiles(); @@ -252,13 +248,12 @@ class CC_EXPORT SchedulerStateMachine { } protected: - bool BeginFrameNeededToAnimateOrDraw() const; + bool BeginFrameNeededToDraw() const; bool ProactiveBeginFrameWanted() const; // True if we need to force activations to make forward progress. bool PendingActivationsShouldBeForced() const; - bool ShouldAnimate() const; bool ShouldBeginOutputSurfaceCreation() const; bool ShouldDrawForced() const; bool ShouldDraw() const; @@ -291,7 +286,6 @@ class CC_EXPORT SchedulerStateMachine { int commit_count_; int current_frame_number_; - int last_frame_number_animate_performed_; int last_frame_number_swap_performed_; int last_frame_number_begin_main_frame_sent_; int last_frame_number_update_visible_tiles_was_called_; @@ -305,7 +299,6 @@ class CC_EXPORT SchedulerStateMachine { int max_pending_swaps_; int pending_swaps_; bool needs_redraw_; - bool needs_animate_; bool needs_manage_tiles_; bool swap_used_incomplete_tile_; bool needs_commit_; diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc index 3dfe934..060269d 100644 --- a/cc/scheduler/scheduler_state_machine_unittest.cc +++ b/cc/scheduler/scheduler_state_machine_unittest.cc @@ -237,7 +237,6 @@ TEST(SchedulerStateMachineTest, MainFrameBeforeDrawDisabled) { EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE); @@ -309,7 +308,6 @@ TEST(SchedulerStateMachineTest, MainFrameBeforeActivationEnabled) { EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); @@ -330,7 +328,6 @@ TEST(SchedulerStateMachineTest, EXPECT_TRUE(state.RedrawPending()); EXPECT_TRUE(state.BeginFrameNeeded()); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -346,7 +343,6 @@ TEST(SchedulerStateMachineTest, state.DidDrawIfPossibleCompleted( DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_TRUE(state.RedrawPending()); @@ -366,7 +362,6 @@ TEST(SchedulerStateMachineTest, TestFailedDrawForMissingHighResNeedsCommit) { EXPECT_TRUE(state.BeginFrameNeeded()); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_ACTION_UPDATE_STATE( @@ -399,7 +394,6 @@ TEST(SchedulerStateMachineTest, EXPECT_TRUE(state.RedrawPending()); EXPECT_TRUE(state.BeginFrameNeeded()); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -419,7 +413,6 @@ TEST(SchedulerStateMachineTest, state.DidDrawIfPossibleCompleted( DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_TRUE(state.RedrawPending()); @@ -450,7 +443,6 @@ void TestFailedDrawsEventuallyForceDrawAfterNextCommit( // Then initiate a draw. state.SetNeedsRedraw(true); state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); @@ -473,7 +465,6 @@ void TestFailedDrawsEventuallyForceDrawAfterNextCommit( // The redraw should be forced at the end of the next BeginImplFrame. state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); if (main_frame_before_draw_enabled) { EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -523,7 +514,6 @@ TEST(SchedulerStateMachineTest, TestFailedDrawsDoNotRestartForcedDraw) { // Then initiate a draw. state.SetNeedsRedraw(true); state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); @@ -576,7 +566,6 @@ TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { state.SetNeedsRedraw(true); EXPECT_TRUE(state.BeginFrameNeeded()); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_TRUE(state.RedrawPending()); @@ -594,7 +583,6 @@ TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { // We should not be trying to draw again now, but we have a commit pending. EXPECT_TRUE(state.BeginFrameNeeded()); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // We should try to draw again at the end of the next BeginImplFrame on @@ -618,7 +606,6 @@ TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { // Draw the first frame. EXPECT_TRUE(state.BeginFrameNeeded()); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -636,7 +623,6 @@ TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { EXPECT_TRUE(state.BeginFrameNeeded()); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -700,7 +686,6 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { state.SetCommitState(all_commit_states[i]); state.SetBeginImplFrameState( SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); - if (request_readback) { state.SetNeedsForcedRedrawForReadback(); } else { @@ -717,9 +702,6 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { } 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. @@ -877,7 +859,6 @@ void TestSetNeedsCommitIsNotLost(bool main_frame_before_draw_enabled) { // Finish the commit, then make sure we start the next commit immediately // and draw on the next BeginImplFrame. EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); if (main_frame_before_draw_enabled) { EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -944,7 +925,6 @@ TEST(SchedulerStateMachineTest, TestFullCycle) { // At BeginImplFrame deadline, draw. state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); @@ -996,7 +976,6 @@ TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) { // At BeginImplFrame deadline, draw. state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); @@ -1105,7 +1084,6 @@ TEST(SchedulerStateMachineTest, AbortBeginMainFrameAndCancelCommit) { // Start a new frame; draw because this is the first frame since output // surface init'd. state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_ACTION_UPDATE_STATE( @@ -1231,7 +1209,6 @@ TEST(SchedulerStateMachineTest, // Once the context is recreated, whether we draw should be based on // SetCanDraw. state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, @@ -1259,7 +1236,6 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) { // Set damage and expect a draw. state.SetNeedsRedraw(true); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1324,7 +1300,6 @@ TEST(SchedulerStateMachineTest, // Set damage and expect a draw. state.SetNeedsRedraw(true); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1386,7 +1361,6 @@ TEST(SchedulerStateMachineTest, EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1550,7 +1524,6 @@ TEST(SchedulerStateMachineTest, DontMakeNewCommitAfterDrawingReplaceCommit) { EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_ACTION_UPDATE_STATE( @@ -1655,7 +1628,6 @@ void TestForceCommitWhenReplacementActivationInProgress( EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Perform the draw & swap of replacement commit. state.OnBeginImplFrameDeadline(); @@ -1695,7 +1667,6 @@ void TestForceCommitWhenReplacementActivationInProgress( EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_ACTION_UPDATE_STATE( @@ -1766,7 +1737,6 @@ TEST(SchedulerStateMachineTest, EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Perform the draw & swap of replacement commit. state.OnBeginImplFrameDeadline(); @@ -2004,7 +1974,6 @@ TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyAfterAbortedCommit) { state.SetNeedsCommit(); // We should start the commit normally. - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -2033,7 +2002,6 @@ TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyForSmoothness) { state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); state.SetNeedsRedraw(true); state.SetNeedsCommit(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -2044,84 +2012,5 @@ TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyForSmoothness) { EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); } -TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { - SchedulerSettings settings; - settings.impl_side_painting = true; - StateMachine state(settings); - state.SetCanStart(); - state.UpdateState(state.NextAction()); - state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); - state.SetVisible(true); - state.SetCanDraw(true); - - // Test requesting an animation that, when run, causes us to draw. - state.SetNeedsAnimate(); - EXPECT_TRUE(state.BeginFrameNeeded()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); - - state.OnBeginImplFrameDeadlinePending(); - state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE( - SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); -} - -TEST(SchedulerStateMachineTest, TestAnimateBeforeCommit) { - SchedulerSettings settings; - settings.impl_side_painting = true; - StateMachine state(settings); - state.SetCanStart(); - state.UpdateState(state.NextAction()); - state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); - state.SetVisible(true); - state.SetCanDraw(true); - - // Check that animations are updated before we start a commit. - state.SetNeedsAnimate(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - state.SetNeedsCommit(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - EXPECT_TRUE(state.BeginFrameNeeded()); - - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); - EXPECT_ACTION_UPDATE_STATE( - SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); - - state.OnBeginImplFrameDeadlinePending(); - state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE( - SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); -} - -TEST(SchedulerStateMachineTest, TestSetNeedsAnimateAfterAnimate) { - SchedulerSettings settings; - settings.impl_side_painting = true; - StateMachine state(settings); - state.SetCanStart(); - state.UpdateState(state.NextAction()); - state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); - state.SetVisible(true); - state.SetCanDraw(true); - - // Test requesting an animation after we have already animated during this - // frame. - state.SetNeedsRedraw(true); - EXPECT_TRUE(state.BeginFrameNeeded()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); - - state.SetNeedsAnimate(); - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - - state.OnBeginImplFrameDeadline(); - EXPECT_ACTION_UPDATE_STATE( - SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); -} - } // namespace } // namespace cc diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc index 921b94a..a5d279b 100644 --- a/cc/scheduler/scheduler_unittest.cc +++ b/cc/scheduler/scheduler_unittest.cc @@ -109,10 +109,6 @@ class FakeSchedulerClient : public SchedulerClient { actions_.push_back("ScheduledActionSendBeginMainFrame"); states_.push_back(scheduler_->StateAsValue().release()); } - virtual void ScheduledActionAnimate() OVERRIDE { - actions_.push_back("ScheduledActionAnimate"); - states_.push_back(scheduler_->StateAsValue().release()); - } virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE { actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); @@ -290,8 +286,7 @@ TEST(SchedulerTest, RequestCommit) { // BeginImplFrame should prepare the draw. scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -353,8 +348,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); - EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); // Because we just swapped, the Scheduler should also request the next @@ -377,8 +371,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); - EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -745,8 +738,7 @@ TEST(SchedulerTest, ManageTiles) { // the deadline task. client.Reset(); scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); // On the deadline, he actions should have occured in the right order. @@ -773,8 +765,7 @@ TEST(SchedulerTest, ManageTiles) { // the deadline task. client.Reset(); scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); // Draw. The draw will trigger SetNeedsManageTiles, and @@ -841,8 +832,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsRedraw(); client.Reset(); scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(scheduler->ManageTilesPending()); @@ -863,8 +853,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsRedraw(); client.Reset(); scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); @@ -886,8 +875,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsRedraw(); client.Reset(); scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(scheduler->ManageTilesPending()); @@ -909,8 +897,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsRedraw(); client.Reset(); scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(scheduler->ManageTilesPending()); @@ -928,8 +915,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsRedraw(); client.Reset(); scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); @@ -1185,8 +1171,7 @@ TEST(SchedulerTest, BeginRetroFrame) { // BeginImplFrame should prepare the draw. client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -1259,8 +1244,7 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { // Swapping will put us into a swap throttled state. client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); - EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -1292,8 +1276,7 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { // BeginImplFrame deadline should draw. scheduler->SetNeedsRedraw(); client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); - EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -1345,8 +1328,7 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, // BeginImplFrame should prepare the draw. client.task_runner().RunPendingTasks(); // Run posted BeginFrame. - EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); - EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_FALSE(client.needs_begin_frame()); client.Reset(); @@ -1435,8 +1417,7 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled, // Swapping will put us into a swap throttled state. client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); - EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_FALSE(client.needs_begin_frame()); client.Reset(); @@ -1460,8 +1441,7 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled, // BeginImplFrame deadline should draw. scheduler->SetNeedsRedraw(); client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); - EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_FALSE(client.needs_begin_frame()); client.Reset(); diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h index 3944bf7..57350bf 100644 --- a/cc/test/fake_layer_tree_host_impl_client.h +++ b/cc/test/fake_layer_tree_host_impl_client.h @@ -27,7 +27,6 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient { virtual void SetNeedsRedrawOnImplThread() OVERRIDE {} virtual void SetNeedsRedrawRectOnImplThread( const gfx::Rect& damage_rect) OVERRIDE {} - virtual void SetNeedsAnimateOnImplThread() OVERRIDE {} virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE {} virtual void SetNeedsCommitOnImplThread() OVERRIDE {} virtual void SetNeedsManageTilesOnImplThread() OVERRIDE {} diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 34e20d3..3ed0aee 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -470,11 +470,15 @@ void LayerTreeHostImpl::StartPageScaleAnimation( duration.InSecondsF()); } - SetNeedsAnimate(); + SetNeedsRedraw(); client_->SetNeedsCommitOnImplThread(); client_->RenewTreePriority(); } +void LayerTreeHostImpl::ScheduleAnimation() { + SetNeedsRedraw(); +} + bool LayerTreeHostImpl::HaveTouchEventHandlersAt( const gfx::Point& viewport_point) { if (!settings_.touch_hit_testing) @@ -1728,11 +1732,6 @@ void LayerTreeHostImpl::SetVisible(bool visible) { renderer_->SetVisible(visible); } -void LayerTreeHostImpl::SetNeedsAnimate() { - NotifySwapPromiseMonitorsOfSetNeedsRedraw(); - client_->SetNeedsAnimateOnImplThread(); -} - void LayerTreeHostImpl::SetNeedsRedraw() { NotifySwapPromiseMonitorsOfSetNeedsRedraw(); client_->SetNeedsRedrawOnImplThread(); @@ -2728,8 +2727,6 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { page_scale_animation_.reset(); client_->SetNeedsCommitOnImplThread(); client_->RenewTreePriority(); - } else { - SetNeedsAnimate(); } } @@ -2739,12 +2736,14 @@ void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { gfx::Vector2dF scroll = top_controls_manager_->Animate(time); if (active_tree_->TotalScrollOffset().y() == 0.f) return; - if (!scroll.IsZero()) { + if (scroll.IsZero()) { + // This may happen on the first animation step. Force redraw otherwise + // the animation would stop because of no new frames. + SetNeedsRedraw(); + } else { ScrollViewportBy(gfx::ScaleVector2d( scroll, 1.f / active_tree_->total_page_scale_factor())); - SetNeedsRedraw(); } - SetNeedsAnimate(); } void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { @@ -2766,7 +2765,7 @@ void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { ++iter) (*iter).second->Animate(monotonic_time_for_cc_animations); - SetNeedsAnimate(); + SetNeedsRedraw(); } void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { @@ -2788,8 +2787,6 @@ void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { if (!events->empty()) { client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); } - - SetNeedsAnimate(); } base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const { @@ -2863,10 +2860,9 @@ void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, layer->scrollbar_animation_controller(); if (scrollbar_controller && scrollbar_controller->Animate(time)) { TRACE_EVENT_INSTANT0( - "cc", - "LayerTreeHostImpl::SetNeedsAnimate due to AnimateScrollbars", + "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars", TRACE_EVENT_SCOPE_THREAD); - SetNeedsAnimate(); + SetNeedsRedraw(); } for (size_t i = 0; i < layer->children().size(); ++i) @@ -2887,11 +2883,10 @@ void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, layer->scrollbar_animation_controller(); if (scrollbar_controller && scrollbar_controller->IsAnimating()) { base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time); - if (delay > base::TimeDelta()) { + if (delay > base::TimeDelta()) client_->RequestScrollbarAnimationOnImplThread(delay); - } else if (scrollbar_controller->Animate(time)) { - SetNeedsAnimate(); - } + else if (scrollbar_controller->Animate(time)) + SetNeedsRedraw(); } for (size_t i = 0; i < layer->children().size(); ++i) diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 3598a9d..aa02278 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -72,12 +72,10 @@ class LayerTreeHostImplClient { virtual void BeginFrame(const BeginFrameArgs& args) = 0; virtual void OnCanDrawStateChanged(bool can_draw) = 0; virtual void NotifyReadyToActivate() = 0; - // Please call these 3 functions through - // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and - // SetNeedsAnimate(). + // Please call these 2 functions through + // LayerTreeHostImpl's SetNeedsRedraw() and SetNeedsRedrawRect(). virtual void SetNeedsRedrawOnImplThread() = 0; virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0; - virtual void SetNeedsAnimateOnImplThread() = 0; virtual void DidInitializeVisibleTileOnImplThread() = 0; virtual void SetNeedsCommitOnImplThread() = 0; virtual void SetNeedsManageTilesOnImplThread() = 0; @@ -140,7 +138,7 @@ class CC_EXPORT LayerTreeHostImpl bool anchor_point, float page_scale, base::TimeDelta duration) OVERRIDE; - virtual void SetNeedsAnimate() OVERRIDE; + virtual void ScheduleAnimation() OVERRIDE; virtual bool HaveTouchEventHandlersAt(const gfx::Point& viewport_port) OVERRIDE; virtual scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index f9a4f79..fc7645d 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -85,7 +85,6 @@ class LayerTreeHostImplTest : public testing::Test, did_notify_ready_to_activate_(false), did_request_commit_(false), did_request_redraw_(false), - did_request_animate_(false), did_request_manage_tiles_(false), did_upload_visible_tile_(false), reduce_memory_result_(true), @@ -132,9 +131,6 @@ class LayerTreeHostImplTest : public testing::Test, const gfx::Rect& damage_rect) OVERRIDE { did_request_redraw_ = true; } - virtual void SetNeedsAnimateOnImplThread() OVERRIDE { - did_request_animate_ = true; - } virtual void SetNeedsManageTilesOnImplThread() OVERRIDE { did_request_manage_tiles_ = true; } @@ -400,7 +396,6 @@ class LayerTreeHostImplTest : public testing::Test, bool did_notify_ready_to_activate_; bool did_request_commit_; bool did_request_redraw_; - bool did_request_animate_; bool did_request_manage_tiles_; bool did_upload_visible_tile_; bool reduce_memory_result_; @@ -909,7 +904,6 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { scroll_layer->FixedContainerSizeDelta()); host_impl_->PinchGestureEnd(); host_impl_->ScrollEnd(); - EXPECT_FALSE(did_request_animate_); EXPECT_TRUE(did_request_redraw_); EXPECT_TRUE(did_request_commit_); EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); @@ -976,7 +970,6 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) { host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); host_impl_->PinchGestureEnd(); host_impl_->ScrollEnd(); - EXPECT_FALSE(did_request_animate_); EXPECT_TRUE(did_request_redraw_); EXPECT_TRUE(did_request_commit_); @@ -1118,30 +1111,19 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { max_page_scale); scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); - did_request_redraw_ = false; - did_request_animate_ = false; host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration); - EXPECT_FALSE(did_request_redraw_); - EXPECT_TRUE(did_request_animate_); - did_request_redraw_ = false; - did_request_animate_ = false; host_impl_->Animate(start_time); EXPECT_TRUE(did_request_redraw_); - EXPECT_TRUE(did_request_animate_); did_request_redraw_ = false; - did_request_animate_ = false; host_impl_->Animate(halfway_through_animation); EXPECT_TRUE(did_request_redraw_); - EXPECT_TRUE(did_request_animate_); did_request_redraw_ = false; - did_request_animate_ = false; did_request_commit_ = false; host_impl_->Animate(end_time); EXPECT_TRUE(did_request_commit_); - EXPECT_FALSE(did_request_animate_); scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); @@ -1156,25 +1138,16 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { max_page_scale); scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); - did_request_redraw_ = false; - did_request_animate_ = false; host_impl_->StartPageScaleAnimation( gfx::Vector2d(25, 25), true, min_page_scale, duration); - EXPECT_FALSE(did_request_redraw_); - EXPECT_TRUE(did_request_animate_); - did_request_redraw_ = false; - did_request_animate_ = false; host_impl_->Animate(start_time); EXPECT_TRUE(did_request_redraw_); - EXPECT_TRUE(did_request_animate_); did_request_redraw_ = false; did_request_commit_ = false; - did_request_animate_ = false; host_impl_->Animate(end_time); EXPECT_TRUE(did_request_redraw_); - EXPECT_FALSE(did_request_animate_); EXPECT_TRUE(did_request_commit_); scoped_ptr<ScrollAndScaleSet> scroll_info = @@ -1328,12 +1301,10 @@ TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); host_impl_->ScrollEnd(); did_request_redraw_ = false; - did_request_animate_ = false; host_impl_->StartScrollbarAnimation(); EXPECT_LT(base::TimeDelta::FromMilliseconds(19), requested_scrollbar_animation_delay_); EXPECT_FALSE(did_request_redraw_); - EXPECT_FALSE(did_request_animate_); requested_scrollbar_animation_delay_ = base::TimeDelta(); // After the fade begins, we should start getting redraws instead of a @@ -1342,8 +1313,8 @@ TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); host_impl_->StartScrollbarAnimation(); EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); - EXPECT_TRUE(did_request_animate_); - did_request_animate_ = false; + EXPECT_TRUE(did_request_redraw_); + did_request_redraw_ = false; // If no scroll happened recently, StartScrollbarAnimation should have no // effect. @@ -1360,7 +1331,6 @@ TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { EXPECT_LT(base::TimeDelta::FromMilliseconds(19), requested_scrollbar_animation_delay_); EXPECT_FALSE(did_request_redraw_); - EXPECT_FALSE(did_request_animate_); requested_scrollbar_animation_delay_ = base::TimeDelta(); // None of the above should have called CurrentFrameTimeTicks, so if we call @@ -1388,7 +1358,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { // effect. host_impl_->StartScrollbarAnimation(); EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); - EXPECT_FALSE(did_request_animate_); + EXPECT_FALSE(did_request_redraw_); // If no scroll happened during a scroll gesture, StartScrollbarAnimation // should have no effect. @@ -1396,7 +1366,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { host_impl_->ScrollEnd(); host_impl_->StartScrollbarAnimation(); EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); - EXPECT_FALSE(did_request_animate_); + EXPECT_FALSE(did_request_redraw_); // After a scroll, no fade animation should be scheduled. host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); @@ -1405,7 +1375,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { did_request_redraw_ = false; host_impl_->StartScrollbarAnimation(); EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); - EXPECT_FALSE(did_request_animate_); + EXPECT_FALSE(did_request_redraw_); requested_scrollbar_animation_delay_ = base::TimeDelta(); // We should not see any draw requests. @@ -1413,7 +1383,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); host_impl_->StartScrollbarAnimation(); EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); - EXPECT_FALSE(did_request_animate_); + EXPECT_FALSE(did_request_redraw_); // Make page scale > min so that subsequent scrolls will trigger fades. host_impl_->active_tree()->SetPageScaleDelta(1.1f); @@ -1426,7 +1396,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { host_impl_->StartScrollbarAnimation(); EXPECT_LT(base::TimeDelta::FromMilliseconds(19), requested_scrollbar_animation_delay_); - EXPECT_FALSE(did_request_animate_); + EXPECT_FALSE(did_request_redraw_); requested_scrollbar_animation_delay_ = base::TimeDelta(); // After the fade begins, we should start getting redraws instead of a @@ -1435,7 +1405,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); host_impl_->StartScrollbarAnimation(); EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); - EXPECT_TRUE(did_request_animate_); + EXPECT_TRUE(did_request_redraw_); } void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc index d546e1b..aeeb4f5 100644 --- a/cc/trees/layer_tree_host_unittest_animation.cc +++ b/cc/trees/layer_tree_host_unittest_animation.cc @@ -1244,69 +1244,5 @@ class LayerTreeHostAnimationTestFrozenAnimationTickTime // Only the non-impl-paint multi-threaded compositor freezes animations. MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); -class LayerTreeHostAnimationTestAddAnimationAfterAnimating - : public LayerTreeHostAnimationTest { - public: - LayerTreeHostAnimationTestAddAnimationAfterAnimating() - : num_swap_buffers_(0) {} - - virtual void SetupTree() OVERRIDE { - LayerTreeHostAnimationTest::SetupTree(); - content_ = Layer::Create(); - content_->SetBounds(gfx::Size(4, 4)); - layer_tree_host()->root_layer()->AddChild(content_); - } - - virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } - - virtual void DidCommit() OVERRIDE { - switch (layer_tree_host()->source_frame_number()) { - case 1: - // First frame: add an animation to the root layer. - AddAnimatedTransformToLayer(layer_tree_host()->root_layer(), 0.1, 5, 5); - break; - case 2: - // Second frame: add an animation to the content layer. The root layer - // animation has caused us to animate already during this frame. - AddOpacityTransitionToLayer(content_.get(), 0.1, 5, 5, false); - break; - } - } - - virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, - bool result) OVERRIDE { - // The third frame is when both animations have started. Check that both - // have a valid start time. - if (++num_swap_buffers_ == 3) { - EndTest(); - AnimationRegistrar::AnimationControllerMap copy = - host_impl->animation_registrar()->active_animation_controllers(); - EXPECT_EQ(2u, copy.size()); - for (AnimationRegistrar::AnimationControllerMap::iterator iter = - copy.begin(); - iter != copy.end(); - ++iter) { - int id = ((*iter).second->id()); - if (id == host_impl->RootLayer()->id()) { - Animation* anim = (*iter).second->GetAnimation(Animation::Transform); - EXPECT_GT(anim->start_time(), 0); - } else if (id == host_impl->RootLayer()->children()[0]->id()) { - Animation* anim = (*iter).second->GetAnimation(Animation::Opacity); - EXPECT_GT(anim->start_time(), 0); - } - } - } - } - - virtual void AfterTest() OVERRIDE {} - - private: - scoped_refptr<Layer> content_; - int num_swap_buffers_; -}; - -SINGLE_AND_MULTI_THREAD_TEST_F( - LayerTreeHostAnimationTestAddAnimationAfterAnimating); - } // namespace } // namespace cc diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index a920f5a..a70e08f 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -267,10 +267,6 @@ void SingleThreadProxy::SetNeedsRedrawOnImplThread() { client_->ScheduleComposite(); } -void SingleThreadProxy::SetNeedsAnimateOnImplThread() { - SetNeedsRedrawOnImplThread(); -} - void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { // Thread-only/Impl-side-painting-only feature. NOTREACHED(); diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 8f682be..e26e031 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -67,7 +67,6 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { virtual void SetNeedsRedrawOnImplThread() OVERRIDE; virtual void SetNeedsRedrawRectOnImplThread( const gfx::Rect& dirty_rect) OVERRIDE; - virtual void SetNeedsAnimateOnImplThread() OVERRIDE; virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; virtual void SetNeedsCommitOnImplThread() OVERRIDE; diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index 9c97ef6..97a0c94 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -125,10 +125,8 @@ ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy, inside_draw(false), input_throttled_until_commit(false), animations_frozen_until_next_draw(false), - did_commit_after_animating(false), renew_tree_priority_pending(false), - weak_factory(proxy) { -} + weak_factory(proxy) {} ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} @@ -565,12 +563,6 @@ void ThreadProxy::SetNeedsRedrawOnImplThread() { impl().scheduler->SetNeedsRedraw(); } -void ThreadProxy::SetNeedsAnimateOnImplThread() { - TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimateOnImplThread"); - DCHECK(IsImplThread()); - impl().scheduler->SetNeedsAnimate(); -} - void ThreadProxy::SetNeedsManageTilesOnImplThread() { DCHECK(IsImplThread()); impl().scheduler->SetNeedsManageTiles(); @@ -1028,18 +1020,6 @@ void ThreadProxy::BeginMainFrameAbortedOnImplThread(bool did_handle) { impl().scheduler->BeginMainFrameAborted(did_handle); } -void ThreadProxy::ScheduledActionAnimate() { - TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); - DCHECK(IsImplThread()); - - if (!impl().animations_frozen_until_next_draw) { - impl().animation_time = - impl().layer_tree_host_impl->CurrentFrameTimeTicks(); - } - impl().layer_tree_host_impl->Animate(impl().animation_time); - impl().did_commit_after_animating = false; -} - void ThreadProxy::ScheduledActionCommit() { TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); DCHECK(IsImplThread()); @@ -1052,10 +1032,10 @@ void ThreadProxy::ScheduledActionCommit() { impl().current_resource_update_controller.reset(); if (impl().animations_frozen_until_next_draw) { - impl().animation_time = std::max( - impl().animation_time, blocked_main().last_monotonic_frame_begin_time); + impl().animation_freeze_time = + std::max(impl().animation_freeze_time, + blocked_main().last_monotonic_frame_begin_time); } - impl().did_commit_after_animating = true; blocked_main().main_thread_inside_commit = true; impl().layer_tree_host_impl->BeginCommit(); @@ -1129,13 +1109,17 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); base::AutoReset<bool> mark_inside(&impl().inside_draw, true); - if (impl().did_commit_after_animating) { - impl().layer_tree_host_impl->Animate(impl().animation_time); - impl().did_commit_after_animating = false; - } + // Advance our animations. + base::TimeTicks monotonic_time; + if (impl().animations_frozen_until_next_draw) + monotonic_time = impl().animation_freeze_time; + else + monotonic_time = impl().layer_tree_host_impl->CurrentFrameTimeTicks(); + // TODO(enne): This should probably happen post-animate. if (impl().layer_tree_host_impl->pending_tree()) impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); + impl().layer_tree_host_impl->Animate(monotonic_time); // This method is called on a forced draw, regardless of whether we are able // to produce a frame, as the calling site on main thread is blocked until its @@ -1189,6 +1173,7 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( // checkerboarding will be displayed when we force a draw. To avoid this, // we freeze animations until we successfully draw. impl().animations_frozen_until_next_draw = true; + impl().animation_freeze_time = monotonic_time; } else { DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result); } diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 381e2be..aab7a43 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -82,13 +82,11 @@ class ThreadProxy : public Proxy, virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE; virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; virtual void NotifyReadyToActivate() OVERRIDE; - // Please call these 3 functions through - // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and - // SetNeedsAnimate(). + // Please call these 2 functions through + // LayerTreeHostImpl's SetNeedsRedraw() and SetNeedsRedrawRect(). virtual void SetNeedsRedrawOnImplThread() OVERRIDE; virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& dirty_rect) OVERRIDE; - virtual void SetNeedsAnimateOnImplThread() OVERRIDE; virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; virtual void SetNeedsCommitOnImplThread() OVERRIDE; @@ -113,7 +111,6 @@ class ThreadProxy : public Proxy, OVERRIDE; virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE; virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() OVERRIDE; - virtual void ScheduledActionAnimate() OVERRIDE; virtual void ScheduledActionCommit() OVERRIDE; virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE; virtual void ScheduledActionActivatePendingTree() OVERRIDE; @@ -286,11 +283,7 @@ class ThreadProxy : public Proxy, // Set when we freeze animations to avoid checkerboarding. bool animations_frozen_until_next_draw; - base::TimeTicks animation_time; - - // Whether a commit has been completed since the last time animations were - // ticked. If this happens, we need to animate again. - bool did_commit_after_animating; + base::TimeTicks animation_freeze_time; base::TimeTicks smoothness_takes_priority_expiration_time; bool renew_tree_priority_pending; |