LayerTreeHost* layer_tree_host,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
- return make_scoped_ptr(new ThreadProxy(layer_tree_host,
- main_task_runner,
- impl_task_runner)).PassAs<Proxy>();
+ return make_scoped_ptr(
+ new ThreadProxy(layer_tree_host, main_task_runner, impl_task_runner));
}
ThreadProxy::ThreadProxy(
next_frame_is_newly_committed_frame(false),
inside_draw(false),
input_throttled_until_commit(false),
- animations_frozen_until_next_draw(false),
- did_commit_after_animating(false),
smoothness_priority_expiration_notifier(
proxy->ImplThreadTaskRunner(),
base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)),
impl().layer_tree_host_impl->active_tree()->root_layer();
impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking(
should_background_tick);
- if (should_background_tick)
- impl().animations_frozen_until_next_draw = false;
}
void ThreadProxy::DidLoseOutputSurface() {
base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
}
-void ThreadProxy::SetNeedsBeginFrame(bool enable) {
- TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrame", "enable", enable);
- impl().layer_tree_host_impl->SetNeedsBeginFrame(enable);
- UpdateBackgroundAnimateTicking();
-}
-
-void ThreadProxy::BeginFrame(const BeginFrameArgs& args) {
- impl().scheduler->BeginFrame(args);
+BeginFrameSource* ThreadProxy::ExternalBeginFrameSource() {
+ return impl().layer_tree_host_impl.get();
}
void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
layer_tree_host()->BeginMainFrame(begin_main_frame_state->begin_frame_args);
layer_tree_host()->AnimateLayers(
begin_main_frame_state->begin_frame_args.frame_time);
- blocked_main().last_monotonic_frame_begin_time =
- begin_main_frame_state->begin_frame_args.frame_time;
// Unlink any backings that the impl thread has evicted, so that we know to
// re-paint them in UpdateLayers.
TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
DCHECK(IsImplThread());
- if (!impl().animations_frozen_until_next_draw) {
- impl().animation_time =
- impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time;
- }
+ impl().animation_time =
+ impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time;
impl().layer_tree_host_impl->Animate(impl().animation_time);
- impl().did_commit_after_animating = false;
}
void ThreadProxy::ScheduledActionCommit() {
// Complete all remaining texture updates.
impl().current_resource_update_controller->Finalize();
- 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().did_commit_after_animating = true;
+ impl().current_resource_update_controller = nullptr;
blocked_main().main_thread_inside_commit = true;
impl().layer_tree_host_impl->BeginCommit();
impl().timing_history.DidStartDrawing();
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;
- }
-
if (impl().layer_tree_host_impl->pending_tree())
impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties();
impl().layer_tree_host_impl->DrawLayers(
&frame, impl().scheduler->LastBeginImplFrameTime());
result = DRAW_SUCCESS;
- impl().animations_frozen_until_next_draw = false;
- } else if (result == DRAW_ABORTED_CHECKERBOARD_ANIMATIONS &&
- !impl().layer_tree_host_impl->settings().impl_side_painting) {
- // Without impl-side painting, the animated layer that is checkerboarding
- // will continue to checkerboard until the next commit. If this layer
- // continues to move during the commit, it may continue to checkerboard
- // after the commit since the region rasterized during the commit will not
- // match the region that is currently visible; eventually this
- // 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;
} else {
DCHECK_NE(DRAW_SUCCESS, result);
}
impl().scheduler = Scheduler::Create(this,
scheduler_settings,
impl().layer_tree_host_id,
- ImplThreadTaskRunner());
+ ImplThreadTaskRunner(),
+ base::PowerMonitor::Get());
impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
DCHECK(IsMainThreadBlocked());
layer_tree_host()->DeleteContentsTexturesOnImplThread(
impl().layer_tree_host_impl->resource_provider());
- impl().current_resource_update_controller.reset();
- impl().layer_tree_host_impl->SetNeedsBeginFrame(false);
- impl().scheduler.reset();
- impl().layer_tree_host_impl.reset();
+ impl().current_resource_update_controller = nullptr;
+ impl().layer_tree_host_impl->SetNeedsBeginFrames(false);
+ impl().scheduler = nullptr;
+ impl().layer_tree_host_impl = nullptr;
impl().weak_factory.InvalidateWeakPtrs();
- // We need to explicitly cancel the notifier, since it isn't using weak ptrs.
- // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep
- // the convention of having a weak ptr factory initialized last. Alternatively
- // we should moved the notifier (and RenewTreePriority) to LTHI. See
- // crbug.com/411972
- impl().smoothness_priority_expiration_notifier.Cancel();
+ // We need to explicitly shutdown the notifier to destroy any weakptrs it is
+ // holding while still on the compositor thread. This also ensures any
+ // callbacks holding a ThreadProxy pointer are cancelled.
+ impl().smoothness_priority_expiration_notifier.Shutdown();
impl().contents_texture_manager = NULL;
completion->Signal();
}
// Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active
// tree might be freed. We need to set RequiresHighResToDraw to ensure that
// high res tiles will be required to activate pending tree.
- impl().layer_tree_host_impl->active_tree()->SetRequiresHighResToDraw();
+ impl().layer_tree_host_impl->SetRequiresHighResToDraw();
priority = NEW_CONTENT_TAKES_PRIORITY;
}