Index: cc/trees/single_thread_proxy.cc |
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc |
index 1af657a3d0ead51ef2076e2a3133121699e800f1..130504639d2c9c65a41bac815c70d457fcbfbde3 100644 |
--- a/cc/trees/single_thread_proxy.cc |
+++ b/cc/trees/single_thread_proxy.cc |
@@ -101,7 +101,6 @@ void SingleThreadProxy::SetVisible(bool visible) { |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
// Changing visibility could change ShouldComposite(). |
- UpdateBackgroundAnimateTicking(); |
} |
void SingleThreadProxy::RequestNewOutputSurface() { |
@@ -161,6 +160,24 @@ void SingleThreadProxy::SetNeedsUpdateLayers() { |
SetNeedsCommit(); |
} |
+void SingleThreadProxy::DoAnimate() { |
+ // Don't animate if there is no root layer. |
+ // TODO(mithro): Both Animate and UpdateAnimationState already have a |
+ // "!active_tree_->root_layer()" check? |
+ if (!layer_tree_host_impl_->active_tree()->root_layer()) { |
+ return; |
+ } |
+ |
+ layer_tree_host_impl_->Animate( |
+ layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); |
+ |
+ // If animations are not visible, update the animation state now as it |
+ // won't happen in DoComposite. |
+ if (!layer_tree_host_impl_->AnimationsAreVisible()) { |
+ layer_tree_host_impl_->UpdateAnimationState(true); |
+ } |
+} |
+ |
void SingleThreadProxy::DoCommit() { |
TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); |
DCHECK(Proxy::IsMainThread()); |
@@ -202,8 +219,6 @@ void SingleThreadProxy::DoCommit() { |
layer_tree_host_impl_->CommitComplete(); |
- UpdateBackgroundAnimateTicking(); |
- |
#if DCHECK_IS_ON |
// In the single-threaded case, the scale and scroll deltas should never be |
// touched on the impl layer tree. |
@@ -328,7 +343,6 @@ void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
TRACE_EVENT1( |
"cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
DCHECK(Proxy::IsImplThread()); |
- UpdateBackgroundAnimateTicking(); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->SetCanDraw(can_draw); |
} |
@@ -347,7 +361,9 @@ void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
} |
void SingleThreadProxy::SetNeedsAnimateOnImplThread() { |
- SetNeedsRedrawOnImplThread(); |
+ client_->ScheduleComposite(); |
brianderson
2014/11/04 23:32:19
Also, why is ScheduleComposite needed instead of S
mithro-old
2014/11/05 00:02:36
The old code use to just delegate to SetNeedsRedra
|
+ if (scheduler_on_impl_thread_) |
+ scheduler_on_impl_thread_->SetNeedsAnimate(); |
brianderson
2014/11/04 18:54:38
Is this just a cleanup, or is it also needed for t
mithro-old
2014/11/04 22:16:50
Both.
Previously, the SetNeedsAnimateOnImplThread
|
} |
void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { |
@@ -420,7 +436,6 @@ void SingleThreadProxy::DidActivateSyncTree() { |
weak_factory_.GetWeakPtr())); |
} |
- UpdateBackgroundAnimateTicking(); |
timing_history_.DidActivateSyncTree(); |
} |
@@ -498,6 +513,8 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); |
} |
+ DoAnimate(); |
+ |
LayerTreeHostImpl::FrameData frame; |
DoComposite(frame_begin_time, &frame); |
@@ -539,12 +556,6 @@ bool SingleThreadProxy::ShouldComposite() const { |
layer_tree_host_impl_->CanDraw(); |
} |
-void SingleThreadProxy::UpdateBackgroundAnimateTicking() { |
- DCHECK(Proxy::IsImplThread()); |
- layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
- !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); |
-} |
- |
void SingleThreadProxy::ScheduleRequestNewOutputSurface() { |
if (output_surface_creation_callback_.IsCancelled() && |
!output_surface_creation_requested_) { |
@@ -572,16 +583,11 @@ DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time, |
// DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
// CanDraw() as well. |
if (!ShouldComposite()) { |
- UpdateBackgroundAnimateTicking(); |
return DRAW_ABORTED_CANT_DRAW; |
} |
timing_history_.DidStartDrawing(); |
- layer_tree_host_impl_->Animate( |
- layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); |
- UpdateBackgroundAnimateTicking(); |
- |
draw_result = layer_tree_host_impl_->PrepareToDraw(frame); |
draw_frame = draw_result == DRAW_SUCCESS; |
if (draw_frame) |
@@ -742,8 +748,8 @@ void SingleThreadProxy::ScheduledActionCommit() { |
void SingleThreadProxy::ScheduledActionAnimate() { |
TRACE_EVENT0("cc", "ScheduledActionAnimate"); |
- layer_tree_host_impl_->Animate( |
- layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); |
+ DebugScopedSetImplThread impl(this); |
+ DoAnimate(); |
} |
void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { |