| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/debug/benchmark_instrumentation.h" | 10 #include "cc/debug/benchmark_instrumentation.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 if (scheduler_on_impl_thread_) | 194 if (scheduler_on_impl_thread_) |
| 195 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); | 195 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void SingleThreadProxy::SetNeedsUpdateLayers() { | 198 void SingleThreadProxy::SetNeedsUpdateLayers() { |
| 199 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 199 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
| 200 DCHECK(Proxy::IsMainThread()); | 200 DCHECK(Proxy::IsMainThread()); |
| 201 SetNeedsCommit(); | 201 SetNeedsCommit(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void SingleThreadProxy::DoAnimate() { | |
| 205 // Don't animate if there is no root layer. | |
| 206 // TODO(mithro): Both Animate and UpdateAnimationState already have a | |
| 207 // "!active_tree_->root_layer()" check? | |
| 208 if (!layer_tree_host_impl_->active_tree()->root_layer()) { | |
| 209 return; | |
| 210 } | |
| 211 | |
| 212 layer_tree_host_impl_->Animate( | |
| 213 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); | |
| 214 | |
| 215 // If animations are not visible, update the animation state now as it | |
| 216 // won't happen in DoComposite. | |
| 217 if (!layer_tree_host_impl_->AnimationsAreVisible()) { | |
| 218 layer_tree_host_impl_->UpdateAnimationState(true); | |
| 219 } | |
| 220 } | |
| 221 | |
| 222 void SingleThreadProxy::DoCommit() { | 204 void SingleThreadProxy::DoCommit() { |
| 223 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); | 205 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); |
| 224 DCHECK(Proxy::IsMainThread()); | 206 DCHECK(Proxy::IsMainThread()); |
| 225 | 207 |
| 226 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is | 208 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is |
| 227 // fixed. | 209 // fixed. |
| 228 tracked_objects::ScopedTracker tracking_profile1( | 210 tracked_objects::ScopedTracker tracking_profile1( |
| 229 FROM_HERE_WITH_EXPLICIT_FUNCTION("461509 SingleThreadProxy::DoCommit1")); | 211 FROM_HERE_WITH_EXPLICIT_FUNCTION("461509 SingleThreadProxy::DoCommit1")); |
| 230 layer_tree_host_->WillCommit(); | 212 layer_tree_host_->WillCommit(); |
| 231 devtools_instrumentation::ScopedCommitTrace commit_task( | 213 devtools_instrumentation::ScopedCommitTrace commit_task( |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 568 |
| 587 // Finish the impl frame. | 569 // Finish the impl frame. |
| 588 { | 570 { |
| 589 DebugScopedSetImplThread impl(this); | 571 DebugScopedSetImplThread impl(this); |
| 590 layer_tree_host_impl_->ActivateSyncTree(); | 572 layer_tree_host_impl_->ActivateSyncTree(); |
| 591 DCHECK( | 573 DCHECK( |
| 592 !layer_tree_host_impl_->active_tree()->needs_update_draw_properties()); | 574 !layer_tree_host_impl_->active_tree()->needs_update_draw_properties()); |
| 593 layer_tree_host_impl_->PrepareTiles(); | 575 layer_tree_host_impl_->PrepareTiles(); |
| 594 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); | 576 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); |
| 595 | 577 |
| 596 DoAnimate(); | 578 // TODO(danakj): Don't do this last... we prepared the wrong things. D: |
| 579 layer_tree_host_impl_->Animate(); |
| 597 | 580 |
| 598 LayerTreeHostImpl::FrameData frame; | 581 LayerTreeHostImpl::FrameData frame; |
| 599 DoComposite(&frame); | 582 DoComposite(&frame); |
| 600 | 583 |
| 601 // DoComposite could abort, but because this is a synchronous composite | 584 // DoComposite could abort, but because this is a synchronous composite |
| 602 // another draw will never be scheduled, so break remaining promises. | 585 // another draw will never be scheduled, so break remaining promises. |
| 603 layer_tree_host_impl_->active_tree()->BreakSwapPromises( | 586 layer_tree_host_impl_->active_tree()->BreakSwapPromises( |
| 604 SwapPromise::SWAP_FAILS); | 587 SwapPromise::SWAP_FAILS); |
| 605 | 588 |
| 606 DidFinishImplFrame(); | 589 DidFinishImplFrame(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 } | 857 } |
| 875 | 858 |
| 876 void SingleThreadProxy::ScheduledActionCommit() { | 859 void SingleThreadProxy::ScheduledActionCommit() { |
| 877 DebugScopedSetMainThread main(this); | 860 DebugScopedSetMainThread main(this); |
| 878 DoCommit(); | 861 DoCommit(); |
| 879 } | 862 } |
| 880 | 863 |
| 881 void SingleThreadProxy::ScheduledActionAnimate() { | 864 void SingleThreadProxy::ScheduledActionAnimate() { |
| 882 TRACE_EVENT0("cc", "ScheduledActionAnimate"); | 865 TRACE_EVENT0("cc", "ScheduledActionAnimate"); |
| 883 DebugScopedSetImplThread impl(this); | 866 DebugScopedSetImplThread impl(this); |
| 884 DoAnimate(); | 867 layer_tree_host_impl_->Animate(); |
| 885 } | 868 } |
| 886 | 869 |
| 887 void SingleThreadProxy::ScheduledActionActivateSyncTree() { | 870 void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
| 888 DebugScopedSetImplThread impl(this); | 871 DebugScopedSetImplThread impl(this); |
| 889 layer_tree_host_impl_->ActivateSyncTree(); | 872 layer_tree_host_impl_->ActivateSyncTree(); |
| 890 } | 873 } |
| 891 | 874 |
| 892 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 875 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
| 893 DebugScopedSetMainThread main(this); | 876 DebugScopedSetMainThread main(this); |
| 894 DCHECK(scheduler_on_impl_thread_); | 877 DCHECK(scheduler_on_impl_thread_); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 920 << "DidFinishImplFrame called while not inside an impl frame!"; | 903 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 921 inside_impl_frame_ = false; | 904 inside_impl_frame_ = false; |
| 922 #endif | 905 #endif |
| 923 } | 906 } |
| 924 | 907 |
| 925 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 908 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
| 926 layer_tree_host_->SendBeginFramesToChildren(args); | 909 layer_tree_host_->SendBeginFramesToChildren(args); |
| 927 } | 910 } |
| 928 | 911 |
| 929 } // namespace cc | 912 } // namespace cc |
| OLD | NEW |