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