| Index: cc/trees/thread_proxy.cc
|
| diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
|
| index c39c80775d2a17f1767eb82e1adedd84afe34d2d..099093d031619a36275dc38e3cf8d1034bedbd23 100644
|
| --- a/cc/trees/thread_proxy.cc
|
| +++ b/cc/trees/thread_proxy.cc
|
| @@ -77,16 +77,17 @@ ThreadProxy::ThreadProxy(
|
| manage_tiles_pending_(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),
|
| completion_event_for_commit_held_on_tree_activation_(NULL),
|
| texture_acquisition_completion_event_on_impl_thread_(NULL),
|
| next_frame_is_newly_committed_frame_on_impl_thread_(false),
|
| - throttle_frame_production_(
|
| - layer_tree_host->settings().throttle_frame_production),
|
| - begin_frame_scheduling_enabled_(
|
| - layer_tree_host->settings().begin_frame_scheduling_enabled),
|
| + throttle_frame_production_(layer_tree_host->settings()
|
| + .throttle_frame_production),
|
| + begin_frame_scheduling_enabled_(layer_tree_host->settings()
|
| + .begin_frame_scheduling_enabled),
|
| using_synchronous_renderer_compositor_(
|
| layer_tree_host->settings().using_synchronous_renderer_compositor),
|
| inside_draw_(false),
|
| @@ -393,14 +394,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(
|
| @@ -950,6 +972,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());
|
| }
|
| @@ -991,16 +1017,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);
|
| @@ -1016,15 +1032,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)) {
|
| @@ -1033,15 +1046,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,
|
| @@ -1049,7 +1060,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) {
|
| @@ -1185,9 +1195,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() {
|
| @@ -1208,6 +1217,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();
|
| @@ -1278,6 +1295,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;
|
| @@ -1285,6 +1304,7 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
|
| settings.using_synchronous_renderer_compositor;
|
| scheduler_settings.throttle_frame_production =
|
| settings.throttle_frame_production;
|
| + scheduler_settings.use_begin_frame_workaround_for_crbug_249806 = true;
|
| scheduler_on_impl_thread_ = Scheduler::Create(this, scheduler_settings);
|
| scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
|
|
|
|
|