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/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 &completion, | 169 &completion, |
170 visible)); | 170 visible)); |
171 completion.Wait(); | 171 completion.Wait(); |
172 } | 172 } |
173 | 173 |
174 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, | 174 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, |
175 bool visible) { | 175 bool visible) { |
176 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); | 176 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); |
177 impl().layer_tree_host_impl->SetVisible(visible); | 177 impl().layer_tree_host_impl->SetVisible(visible); |
178 impl().scheduler->SetVisible(visible); | 178 impl().scheduler->SetVisible(visible); |
| 179 UpdateBackgroundAnimateTicking(); |
179 completion->Signal(); | 180 completion->Signal(); |
180 } | 181 } |
181 | 182 |
| 183 void ThreadProxy::UpdateBackgroundAnimateTicking() { |
| 184 bool should_background_tick = |
| 185 !impl().scheduler->WillDrawIfNeeded() && |
| 186 impl().layer_tree_host_impl->active_tree()->root_layer(); |
| 187 impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking( |
| 188 should_background_tick); |
| 189 } |
| 190 |
182 void ThreadProxy::DidLoseOutputSurface() { | 191 void ThreadProxy::DidLoseOutputSurface() { |
183 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); | 192 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); |
184 DCHECK(IsMainThread()); | 193 DCHECK(IsMainThread()); |
185 layer_tree_host()->DidLoseOutputSurface(); | 194 layer_tree_host()->DidLoseOutputSurface(); |
186 | 195 |
187 { | 196 { |
188 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 197 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
189 | 198 |
190 // Return lost resources to their owners immediately. | 199 // Return lost resources to their owners immediately. |
191 BlockingTaskRunner::CapturePostTasks blocked( | 200 BlockingTaskRunner::CapturePostTasks blocked( |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 351 |
343 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 352 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
344 impl().layer_tree_host_impl->WillBeginImplFrame(args); | 353 impl().layer_tree_host_impl->WillBeginImplFrame(args); |
345 } | 354 } |
346 | 355 |
347 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 356 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
348 TRACE_EVENT1( | 357 TRACE_EVENT1( |
349 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 358 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
350 DCHECK(IsImplThread()); | 359 DCHECK(IsImplThread()); |
351 impl().scheduler->SetCanDraw(can_draw); | 360 impl().scheduler->SetCanDraw(can_draw); |
| 361 UpdateBackgroundAnimateTicking(); |
352 } | 362 } |
353 | 363 |
354 void ThreadProxy::NotifyReadyToActivate() { | 364 void ThreadProxy::NotifyReadyToActivate() { |
355 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); | 365 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); |
356 impl().scheduler->NotifyReadyToActivate(); | 366 impl().scheduler->NotifyReadyToActivate(); |
357 } | 367 } |
358 | 368 |
359 void ThreadProxy::SetNeedsCommitOnImplThread() { | 369 void ThreadProxy::SetNeedsCommitOnImplThread() { |
360 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); | 370 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); |
361 DCHECK(IsImplThread()); | 371 DCHECK(IsImplThread()); |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 if (did_handle) | 920 if (did_handle) |
911 SetInputThrottledUntilCommitOnImplThread(false); | 921 SetInputThrottledUntilCommitOnImplThread(false); |
912 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); | 922 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); |
913 impl().scheduler->BeginMainFrameAborted(did_handle); | 923 impl().scheduler->BeginMainFrameAborted(did_handle); |
914 } | 924 } |
915 | 925 |
916 void ThreadProxy::ScheduledActionAnimate() { | 926 void ThreadProxy::ScheduledActionAnimate() { |
917 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 927 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
918 DCHECK(IsImplThread()); | 928 DCHECK(IsImplThread()); |
919 | 929 |
920 // Don't animate if there is no root layer. | |
921 // TODO(mithro): Both Animate and UpdateAnimationState already have a | |
922 // "!active_tree_->root_layer()" check? | |
923 if (!impl().layer_tree_host_impl->active_tree()->root_layer()) { | |
924 return; | |
925 } | |
926 | |
927 impl().animation_time = | 930 impl().animation_time = |
928 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time; | 931 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time; |
929 impl().layer_tree_host_impl->Animate(impl().animation_time); | 932 impl().layer_tree_host_impl->Animate(impl().animation_time); |
930 | |
931 // If animations are not visible, update the state now as | |
932 // ScheduledActionDrawAndSwapIfPossible will never be called. | |
933 if (!impl().layer_tree_host_impl->AnimationsAreVisible()) { | |
934 impl().layer_tree_host_impl->UpdateAnimationState(true); | |
935 } | |
936 } | 933 } |
937 | 934 |
938 void ThreadProxy::ScheduledActionCommit() { | 935 void ThreadProxy::ScheduledActionCommit() { |
939 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 936 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
940 DCHECK(IsImplThread()); | 937 DCHECK(IsImplThread()); |
941 DCHECK(IsMainThreadBlocked()); | 938 DCHECK(IsMainThreadBlocked()); |
942 DCHECK(impl().commit_completion_event); | 939 DCHECK(impl().commit_completion_event); |
943 DCHECK(impl().current_resource_update_controller); | 940 DCHECK(impl().current_resource_update_controller); |
944 | 941 |
945 // Complete all remaining texture updates. | 942 // Complete all remaining texture updates. |
(...skipping 23 matching lines...) Expand all Loading... |
969 impl().commit_completion_event->Signal(); | 966 impl().commit_completion_event->Signal(); |
970 impl().commit_completion_event = NULL; | 967 impl().commit_completion_event = NULL; |
971 } | 968 } |
972 | 969 |
973 // Delay this step until afer the main thread has been released as it's | 970 // Delay this step until afer the main thread has been released as it's |
974 // often a good bit of work to update the tree and prepare the new frame. | 971 // often a good bit of work to update the tree and prepare the new frame. |
975 impl().layer_tree_host_impl->CommitComplete(); | 972 impl().layer_tree_host_impl->CommitComplete(); |
976 | 973 |
977 SetInputThrottledUntilCommitOnImplThread(false); | 974 SetInputThrottledUntilCommitOnImplThread(false); |
978 | 975 |
| 976 UpdateBackgroundAnimateTicking(); |
| 977 |
979 impl().next_frame_is_newly_committed_frame = true; | 978 impl().next_frame_is_newly_committed_frame = true; |
980 | 979 |
981 impl().timing_history.DidCommit(); | 980 impl().timing_history.DidCommit(); |
982 } | 981 } |
983 | 982 |
984 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { | 983 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { |
985 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles"); | 984 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles"); |
986 DCHECK(IsImplThread()); | 985 DCHECK(IsImplThread()); |
987 impl().layer_tree_host_impl->UpdateVisibleTiles(); | 986 impl().layer_tree_host_impl->UpdateVisibleTiles(); |
988 } | 987 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 DCHECK(IsImplThread()); | 1345 DCHECK(IsImplThread()); |
1347 | 1346 |
1348 if (impl().completion_event_for_commit_held_on_tree_activation) { | 1347 if (impl().completion_event_for_commit_held_on_tree_activation) { |
1349 TRACE_EVENT_INSTANT0( | 1348 TRACE_EVENT_INSTANT0( |
1350 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1349 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
1351 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | 1350 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); |
1352 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1351 impl().completion_event_for_commit_held_on_tree_activation->Signal(); |
1353 impl().completion_event_for_commit_held_on_tree_activation = NULL; | 1352 impl().completion_event_for_commit_held_on_tree_activation = NULL; |
1354 } | 1353 } |
1355 | 1354 |
| 1355 UpdateBackgroundAnimateTicking(); |
| 1356 |
1356 impl().timing_history.DidActivateSyncTree(); | 1357 impl().timing_history.DidActivateSyncTree(); |
1357 } | 1358 } |
1358 | 1359 |
1359 void ThreadProxy::DidManageTiles() { | 1360 void ThreadProxy::DidManageTiles() { |
1360 DCHECK(IsImplThread()); | 1361 DCHECK(IsImplThread()); |
1361 impl().scheduler->DidManageTiles(); | 1362 impl().scheduler->DidManageTiles(); |
1362 } | 1363 } |
1363 | 1364 |
1364 } // namespace cc | 1365 } // namespace cc |
OLD | NEW |