| Index: cc/trees/thread_proxy.cc
|
| diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
|
| index 5c6533a43745501937d9987bf48cff0cd98263ef..b8799d5be730e1191293cf9ed178230d26fbb296 100644
|
| --- a/cc/trees/thread_proxy.cc
|
| +++ b/cc/trees/thread_proxy.cc
|
| @@ -80,6 +80,7 @@ ThreadProxy::ThreadProxy(
|
| inside_commit_(false),
|
| weak_factory_on_impl_thread_(this),
|
| weak_factory_(this),
|
| + frame_did_draw_(false),
|
| begin_frame_sent_to_main_thread_completion_event_on_impl_thread_(NULL),
|
| readback_request_on_impl_thread_(NULL),
|
| commit_completion_event_on_impl_thread_(NULL),
|
| @@ -397,14 +398,35 @@ 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");
|
| +
|
| + base::TimeTicks monotonic_time =
|
| + layer_tree_host_impl_->CurrentFrameTimeTicks();
|
| + base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
|
| + if (layer_tree_host_impl_->active_tree()->root_layer())
|
| + layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
|
| +
|
| + // Reinitialize for the current frame.
|
| + frame_did_draw_ = false;
|
| +
|
| scheduler_on_impl_thread_->BeginFrame(args);
|
| }
|
|
|
| +void ThreadProxy::DidBeginFrameDeadlineOnImplThread() {
|
| + // Do not start animations if we skip drawing the frame to avoid
|
| + // checkerboarding.
|
| + if (layer_tree_host_impl_->active_tree()->root_layer()) {
|
| + layer_tree_host_impl_->UpdateAnimationState(
|
| + frame_did_draw_ || !layer_tree_host_impl_->CanDraw());
|
| + }
|
| + layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
|
| +}
|
| +
|
| void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
|
| DCHECK(IsImplThread());
|
| TRACE_EVENT1(
|
| @@ -976,6 +998,10 @@ void ThreadProxy::ScheduledActionCommit() {
|
| begin_frame_to_commit_duration_history_.InsertSample(
|
| commit_complete_time_ - begin_frame_sent_to_main_thread_time_);
|
|
|
| + // The commit may have added animations, requiring us to start
|
| + // background ticking.
|
| + UpdateBackgroundAnimateTicking();
|
| +
|
| // SetVisible kicks off the next scheduler action, so this must be last.
|
| scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
|
| }
|
| @@ -1018,16 +1044,6 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
|
| if (!layer_tree_host_impl_->renderer())
|
| return result;
|
|
|
| - 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);
|
| @@ -1043,15 +1059,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)) {
|
| @@ -1060,15 +1073,13 @@ 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;
|
| }
|
|
|
| + frame_did_draw_ = draw_frame;
|
| +
|
| if (draw_frame) {
|
| layer_tree_host_impl_->DrawLayers(
|
| &frame,
|
| @@ -1076,7 +1087,6 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
|
| result.did_draw = true;
|
| }
|
| layer_tree_host_impl_->DidDrawAllLayers(frame);
|
| - layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
|
|
|
| // Check for a pending CompositeAndReadback.
|
| if (drawing_for_readback) {
|
| @@ -1216,9 +1226,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() {
|
| @@ -1239,6 +1248,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();
|
| @@ -1309,6 +1326,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;
|
|
|