| Index: cc/trees/thread_proxy.cc
|
| diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
|
| index 14e218194e026d57cf300dd7a41a58ac21cb5b8b..0f7a2a3dee6baae9dd219c6d3c02f36c4025af2e 100644
|
| --- a/cc/trees/thread_proxy.cc
|
| +++ b/cc/trees/thread_proxy.cc
|
| @@ -48,22 +48,27 @@ struct ThreadProxy::SchedulerStateRequest {
|
| scoped_ptr<Proxy> ThreadProxy::Create(
|
| 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));
|
| + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
|
| + scoped_ptr<BeginFrameSource> external_begin_frame_source) {
|
| + return make_scoped_ptr(new ThreadProxy(layer_tree_host,
|
| + main_task_runner,
|
| + impl_task_runner,
|
| + external_begin_frame_source.Pass()));
|
| }
|
|
|
| ThreadProxy::ThreadProxy(
|
| LayerTreeHost* layer_tree_host,
|
| scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
|
| - scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
|
| + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
|
| + scoped_ptr<BeginFrameSource> external_begin_frame_source)
|
| : Proxy(main_task_runner, impl_task_runner),
|
| main_thread_only_vars_unsafe_(this, layer_tree_host->id()),
|
| main_thread_or_blocked_vars_unsafe_(layer_tree_host),
|
| compositor_thread_vars_unsafe_(
|
| this,
|
| layer_tree_host->id(),
|
| - layer_tree_host->rendering_stats_instrumentation()) {
|
| + layer_tree_host->rendering_stats_instrumentation(),
|
| + external_begin_frame_source.Pass()) {
|
| TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
|
| DCHECK(IsMainThread());
|
| DCHECK(this->layer_tree_host());
|
| @@ -99,7 +104,8 @@ ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() {
|
| ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(
|
| ThreadProxy* proxy,
|
| int layer_tree_host_id,
|
| - RenderingStatsInstrumentation* rendering_stats_instrumentation)
|
| + RenderingStatsInstrumentation* rendering_stats_instrumentation,
|
| + scoped_ptr<BeginFrameSource> external_begin_frame_source)
|
| : layer_tree_host_id(layer_tree_host_id),
|
| contents_texture_manager(NULL),
|
| commit_completion_event(NULL),
|
| @@ -113,6 +119,7 @@ ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(
|
| base::TimeDelta::FromMilliseconds(
|
| kSmoothnessTakesPriorityExpirationDelay * 1000)),
|
| timing_history(rendering_stats_instrumentation),
|
| + external_begin_frame_source(external_begin_frame_source.Pass()),
|
| weak_factory(proxy) {
|
| }
|
|
|
| @@ -176,18 +183,9 @@ void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion,
|
| TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread");
|
| impl().layer_tree_host_impl->SetVisible(visible);
|
| impl().scheduler->SetVisible(visible);
|
| - UpdateBackgroundAnimateTicking();
|
| completion->Signal();
|
| }
|
|
|
| -void ThreadProxy::UpdateBackgroundAnimateTicking() {
|
| - bool should_background_tick =
|
| - !impl().scheduler->WillDrawIfNeeded() &&
|
| - impl().layer_tree_host_impl->active_tree()->root_layer();
|
| - impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking(
|
| - should_background_tick);
|
| -}
|
| -
|
| void ThreadProxy::DidLoseOutputSurface() {
|
| TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface");
|
| DCHECK(IsMainThread());
|
| @@ -345,10 +343,6 @@ void ThreadProxy::DidSwapBuffersCompleteOnImplThread() {
|
| base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
|
| }
|
|
|
| -BeginFrameSource* ThreadProxy::ExternalBeginFrameSource() {
|
| - return impl().layer_tree_host_impl.get();
|
| -}
|
| -
|
| void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
|
| impl().layer_tree_host_impl->WillBeginImplFrame(args);
|
| }
|
| @@ -358,7 +352,6 @@ void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
|
| "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
|
| DCHECK(IsImplThread());
|
| impl().scheduler->SetCanDraw(can_draw);
|
| - UpdateBackgroundAnimateTicking();
|
| }
|
|
|
| void ThreadProxy::NotifyReadyToActivate() {
|
| @@ -366,6 +359,11 @@ void ThreadProxy::NotifyReadyToActivate() {
|
| impl().scheduler->NotifyReadyToActivate();
|
| }
|
|
|
| +void ThreadProxy::NotifyReadyToDraw() {
|
| + TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToDraw");
|
| + impl().scheduler->NotifyReadyToDraw();
|
| +}
|
| +
|
| void ThreadProxy::SetNeedsCommitOnImplThread() {
|
| TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread");
|
| DCHECK(IsImplThread());
|
| @@ -851,12 +849,6 @@ void ThreadProxy::BeginMainFrame(
|
| &completion,
|
| queue.release()));
|
| completion.Wait();
|
| -
|
| - RenderingStatsInstrumentation* stats_instrumentation =
|
| - layer_tree_host()->rendering_stats_instrumentation();
|
| - benchmark_instrumentation::IssueMainThreadRenderingStatsEvent(
|
| - stats_instrumentation->main_thread_rendering_stats());
|
| - stats_instrumentation->AccumulateAndClearMainThreadStats();
|
| }
|
|
|
| layer_tree_host()->CommitComplete();
|
| @@ -933,9 +925,22 @@ void ThreadProxy::ScheduledActionAnimate() {
|
| TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
|
| DCHECK(IsImplThread());
|
|
|
| + // Don't animate if there is no root layer.
|
| + // TODO(mithro): Both Animate and UpdateAnimationState already have a
|
| + // "!active_tree_->root_layer()" check?
|
| + if (!impl().layer_tree_host_impl->active_tree()->root_layer()) {
|
| + return;
|
| + }
|
| +
|
| impl().animation_time =
|
| impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time;
|
| impl().layer_tree_host_impl->Animate(impl().animation_time);
|
| +
|
| + // If animations are not visible, update the state now as
|
| + // ScheduledActionDrawAndSwapIfPossible will never be called.
|
| + if (!impl().layer_tree_host_impl->AnimationsAreVisible()) {
|
| + impl().layer_tree_host_impl->UpdateAnimationState(true);
|
| + }
|
| }
|
|
|
| void ThreadProxy::ScheduledActionCommit() {
|
| @@ -979,8 +984,6 @@ void ThreadProxy::ScheduledActionCommit() {
|
|
|
| SetInputThrottledUntilCommitOnImplThread(false);
|
|
|
| - UpdateBackgroundAnimateTicking();
|
| -
|
| impl().next_frame_is_newly_committed_frame = true;
|
|
|
| impl().timing_history.DidCommit();
|
| @@ -1149,13 +1152,14 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
|
| impl().layer_tree_host_impl =
|
| layer_tree_host()->CreateLayerTreeHostImpl(this);
|
| SchedulerSettings scheduler_settings(layer_tree_host()->settings());
|
| - impl().scheduler = Scheduler::Create(this,
|
| - scheduler_settings,
|
| - impl().layer_tree_host_id,
|
| - ImplThreadTaskRunner(),
|
| - base::PowerMonitor::Get());
|
| + impl().scheduler = Scheduler::Create(
|
| + this,
|
| + scheduler_settings,
|
| + impl().layer_tree_host_id,
|
| + ImplThreadTaskRunner(),
|
| + base::PowerMonitor::Get(),
|
| + impl().external_begin_frame_source.Pass());
|
| impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
|
| -
|
| impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
|
| completion->Signal();
|
| }
|
| @@ -1213,7 +1217,6 @@ void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
|
| layer_tree_host()->DeleteContentsTexturesOnImplThread(
|
| impl().layer_tree_host_impl->resource_provider());
|
| 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();
|
| @@ -1358,8 +1361,6 @@ void ThreadProxy::DidActivateSyncTree() {
|
| impl().completion_event_for_commit_held_on_tree_activation = NULL;
|
| }
|
|
|
| - UpdateBackgroundAnimateTicking();
|
| -
|
| impl().timing_history.DidActivateSyncTree();
|
| }
|
|
|
|
|