| Index: cc/trees/thread_proxy.cc
|
| diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
|
| index 7f590f06be330d2f445f013eafa1aac4364045b6..7f1c833b174965e5b95c8fe9d5c49fc0a211bf2f 100644
|
| --- a/cc/trees/thread_proxy.cc
|
| +++ b/cc/trees/thread_proxy.cc
|
| @@ -397,14 +397,24 @@ void ThreadProxy::SetNeedsBeginFrameOnImplThread(bool enable) {
|
| TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrameOnImplThread",
|
| "enable", enable);
|
| layer_tree_host_impl_->SetNeedsBeginFrame(enable);
|
| + UpdateBackgroundAnimateTicking();
|
| }
|
|
|
| void ThreadProxy::BeginFrameOnImplThread(const BeginFrameArgs& args) {
|
| DCHECK(IsImplThread());
|
| TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread");
|
| +
|
| + // Sample the frame time now. This time will be used for updating animations
|
| + // when we draw.
|
| + layer_tree_host_impl_->CurrentFrameTimeTicks();
|
| +
|
| scheduler_on_impl_thread_->BeginFrame(args);
|
| }
|
|
|
| +void ThreadProxy::DidBeginFrameDeadlineOnImplThread() {
|
| + layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
|
| +}
|
| +
|
| void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
|
| DCHECK(IsImplThread());
|
| TRACE_EVENT1(
|
| @@ -1035,19 +1045,15 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
|
| if (!layer_tree_host_impl_->renderer())
|
| return result;
|
|
|
| + base::TimeTicks start_time = base::TimeTicks::HighResNow();
|
| + base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
|
| + base::AutoReset<bool> mark_inside(&inside_draw_, true);
|
| +
|
| + // Advance our animations.
|
| base::TimeTicks monotonic_time =
|
| layer_tree_host_impl_->CurrentFrameTimeTicks();
|
| base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
|
| -
|
| - // TODO(enne): This should probably happen post-animate.
|
| - if (layer_tree_host_impl_->pending_tree())
|
| - layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
|
| layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
|
| - UpdateBackgroundAnimateTicking();
|
| -
|
| - base::TimeTicks start_time = base::TimeTicks::HighResNow();
|
| - base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
|
| - base::AutoReset<bool> mark_inside(&inside_draw_, true);
|
|
|
| // 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
|
| @@ -1060,15 +1066,12 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
|
| // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
|
| // CanDraw() as well.
|
|
|
| - // readback_request_on_impl_thread_ may be for the pending tree, do
|
| - // not perform the readback unless explicitly requested.
|
| bool drawing_for_readback =
|
| readback_requested && !!readback_request_on_impl_thread_;
|
| bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels();
|
|
|
| LayerTreeHostImpl::FrameData frame;
|
| bool draw_frame = false;
|
| - bool start_ready_animations = true;
|
|
|
| if (layer_tree_host_impl_->CanDraw() &&
|
| (!drawing_for_readback || can_do_readback)) {
|
| @@ -1077,13 +1080,9 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
|
| if (drawing_for_readback)
|
| readback_rect = readback_request_on_impl_thread_->rect;
|
|
|
| - // Do not start animations if we skip drawing the frame to avoid
|
| - // checkerboarding.
|
| if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) ||
|
| forced_draw)
|
| draw_frame = true;
|
| - else
|
| - start_ready_animations = false;
|
| }
|
|
|
| if (draw_frame) {
|
| @@ -1093,6 +1092,8 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
|
| result.did_draw = true;
|
| }
|
| layer_tree_host_impl_->DidDrawAllLayers(frame);
|
| +
|
| + bool start_ready_animations = draw_frame;
|
| layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
|
|
|
| // Check for a pending CompositeAndReadback.
|
| @@ -1233,9 +1234,8 @@ DrawSwapReadbackResult ThreadProxy::ScheduledActionDrawAndReadback() {
|
|
|
| void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
|
| if (current_resource_update_controller_on_impl_thread_)
|
| - current_resource_update_controller_on_impl_thread_
|
| - ->PerformMoreUpdates(time);
|
| - layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
|
| + current_resource_update_controller_on_impl_thread_->PerformMoreUpdates(
|
| + time);
|
| }
|
|
|
| base::TimeDelta ThreadProxy::DrawDurationEstimate() {
|
| @@ -1256,6 +1256,14 @@ base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() {
|
| kCommitAndActivationDurationEstimationPercentile);
|
| }
|
|
|
| +void ThreadProxy::PostBeginFrameDeadline(const base::Closure& closure,
|
| + base::TimeTicks deadline) {
|
| + base::TimeDelta delta = deadline - base::TimeTicks::Now();
|
| + if (delta <= base::TimeDelta())
|
| + delta = base::TimeDelta();
|
| + Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta);
|
| +}
|
| +
|
| void ThreadProxy::ReadyToFinalizeTextureUpdates() {
|
| DCHECK(IsImplThread());
|
| scheduler_on_impl_thread_->FinishCommit();
|
| @@ -1326,6 +1334,8 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
|
| layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
|
| const LayerTreeSettings& settings = layer_tree_host_->settings();
|
| SchedulerSettings scheduler_settings;
|
| + scheduler_settings.deadline_scheduling_enabled =
|
| + settings.deadline_scheduling_enabled;
|
| scheduler_settings.impl_side_painting = settings.impl_side_painting;
|
| scheduler_settings.timeout_and_draw_when_animation_checkerboards =
|
| settings.timeout_and_draw_when_animation_checkerboards;
|
|
|