| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( | 253 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( |
| 254 const RendererCapabilities& capabilities) { | 254 const RendererCapabilities& capabilities) { |
| 255 main().renderer_capabilities_main_thread_copy = capabilities; | 255 main().renderer_capabilities_main_thread_copy = capabilities; |
| 256 } | 256 } |
| 257 | 257 |
| 258 void ThreadProxy::SendCommitRequestToImplThreadIfNeeded() { | 258 void ThreadProxy::SendCommitRequestToImplThreadIfNeeded() { |
| 259 DCHECK(IsMainThread()); | 259 DCHECK(IsMainThread()); |
| 260 VLOG(2) << "ThreadProxy::SendCommitRequestToImplThreadIfNeeded: " |
| 261 << "already_sent = " << main().commit_request_sent_to_impl_thread; |
| 260 if (main().commit_request_sent_to_impl_thread) | 262 if (main().commit_request_sent_to_impl_thread) |
| 261 return; | 263 return; |
| 262 main().commit_request_sent_to_impl_thread = true; | 264 main().commit_request_sent_to_impl_thread = true; |
| 263 Proxy::ImplThreadTaskRunner()->PostTask( | 265 Proxy::ImplThreadTaskRunner()->PostTask( |
| 264 FROM_HERE, | 266 FROM_HERE, |
| 265 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread, | 267 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread, |
| 266 impl_thread_weak_ptr_)); | 268 impl_thread_weak_ptr_)); |
| 267 } | 269 } |
| 268 | 270 |
| 269 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { | 271 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { |
| 270 DCHECK(IsMainThread()); | 272 DCHECK(IsMainThread()); |
| 271 DCHECK(!layer_tree_host()->output_surface_lost()); | 273 DCHECK(!layer_tree_host()->output_surface_lost()); |
| 272 return main().renderer_capabilities_main_thread_copy; | 274 return main().renderer_capabilities_main_thread_copy; |
| 273 } | 275 } |
| 274 | 276 |
| 275 void ThreadProxy::SetNeedsAnimate() { | 277 void ThreadProxy::SetNeedsAnimate() { |
| 276 DCHECK(IsMainThread()); | 278 DCHECK(IsMainThread()); |
| 279 VLOG(2) << "ThreadProxy::SetNeedsAnimate: already_requested = " |
| 280 << main().animate_requested; |
| 277 if (main().animate_requested) | 281 if (main().animate_requested) |
| 278 return; | 282 return; |
| 279 | 283 |
| 280 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimate"); | 284 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimate"); |
| 281 main().animate_requested = true; | 285 main().animate_requested = true; |
| 282 SendCommitRequestToImplThreadIfNeeded(); | 286 SendCommitRequestToImplThreadIfNeeded(); |
| 283 } | 287 } |
| 284 | 288 |
| 285 void ThreadProxy::SetNeedsUpdateLayers() { | 289 void ThreadProxy::SetNeedsUpdateLayers() { |
| 286 DCHECK(IsMainThread()); | 290 DCHECK(IsMainThread()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 UpdateBackgroundAnimateTicking(); | 377 UpdateBackgroundAnimateTicking(); |
| 374 } | 378 } |
| 375 | 379 |
| 376 void ThreadProxy::NotifyReadyToActivate() { | 380 void ThreadProxy::NotifyReadyToActivate() { |
| 377 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); | 381 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); |
| 378 impl().scheduler->NotifyReadyToActivate(); | 382 impl().scheduler->NotifyReadyToActivate(); |
| 379 } | 383 } |
| 380 | 384 |
| 381 void ThreadProxy::SetNeedsCommitOnImplThread() { | 385 void ThreadProxy::SetNeedsCommitOnImplThread() { |
| 382 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); | 386 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); |
| 387 VLOG(2) << "ThreadProxy::SetNeedsCommitOnImplThread"; |
| 383 DCHECK(IsImplThread()); | 388 DCHECK(IsImplThread()); |
| 384 impl().scheduler->SetNeedsCommit(); | 389 impl().scheduler->SetNeedsCommit(); |
| 385 } | 390 } |
| 386 | 391 |
| 387 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 392 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
| 388 scoped_ptr<AnimationEventsVector> events) { | 393 scoped_ptr<AnimationEventsVector> events) { |
| 389 TRACE_EVENT0("cc", | 394 TRACE_EVENT0("cc", |
| 390 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 395 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
| 391 DCHECK(IsImplThread()); | 396 DCHECK(IsImplThread()); |
| 392 Proxy::MainThreadTaskRunner()->PostTask( | 397 Proxy::MainThreadTaskRunner()->PostTask( |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 // Do not notify the impl thread of commit requests that occur during | 770 // Do not notify the impl thread of commit requests that occur during |
| 766 // the apply/animate/layout part of the BeginMainFrameAndCommit process since | 771 // the apply/animate/layout part of the BeginMainFrameAndCommit process since |
| 767 // those commit requests will get painted immediately. Once we have done | 772 // those commit requests will get painted immediately. Once we have done |
| 768 // the paint, main().commit_requested will be set to false to allow new commit | 773 // the paint, main().commit_requested will be set to false to allow new commit |
| 769 // requests to be scheduled. | 774 // requests to be scheduled. |
| 770 // On the other hand, the animate_requested flag should remain cleared | 775 // On the other hand, the animate_requested flag should remain cleared |
| 771 // here so that any animation requests generated by the apply or animate | 776 // here so that any animation requests generated by the apply or animate |
| 772 // callbacks will trigger another frame. | 777 // callbacks will trigger another frame. |
| 773 main().commit_requested = true; | 778 main().commit_requested = true; |
| 774 main().commit_request_sent_to_impl_thread = true; | 779 main().commit_request_sent_to_impl_thread = true; |
| 780 VLOG(2) << "ThreadProxy::BeginMainFrame: Commit requests silenced."; |
| 775 | 781 |
| 776 layer_tree_host()->ApplyScrollAndScale( | 782 layer_tree_host()->ApplyScrollAndScale( |
| 777 begin_main_frame_state->scroll_info.get()); | 783 begin_main_frame_state->scroll_info.get()); |
| 778 | 784 |
| 779 layer_tree_host()->WillBeginMainFrame(); | 785 layer_tree_host()->WillBeginMainFrame(); |
| 780 | 786 |
| 781 layer_tree_host()->BeginMainFrame(begin_main_frame_state->begin_frame_args); | 787 layer_tree_host()->BeginMainFrame(begin_main_frame_state->begin_frame_args); |
| 782 layer_tree_host()->AnimateLayers( | 788 layer_tree_host()->AnimateLayers( |
| 783 begin_main_frame_state->begin_frame_args.frame_time); | 789 begin_main_frame_state->begin_frame_args.frame_time); |
| 784 blocked_main().last_monotonic_frame_begin_time = | 790 blocked_main().last_monotonic_frame_begin_time = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 825 |
| 820 layer_tree_host()->WillCommit(); | 826 layer_tree_host()->WillCommit(); |
| 821 | 827 |
| 822 // Before calling animate, we set main().animate_requested to false. If it is | 828 // Before calling animate, we set main().animate_requested to false. If it is |
| 823 // true now, it means SetNeedAnimate was called again, but during a state when | 829 // true now, it means SetNeedAnimate was called again, but during a state when |
| 824 // main().commit_request_sent_to_impl_thread = true. We need to force that | 830 // main().commit_request_sent_to_impl_thread = true. We need to force that |
| 825 // call to happen again now so that the commit request is sent to the impl | 831 // call to happen again now so that the commit request is sent to the impl |
| 826 // thread. | 832 // thread. |
| 827 if (main().animate_requested) { | 833 if (main().animate_requested) { |
| 828 // Forces SetNeedsAnimate to consider posting a commit task. | 834 // Forces SetNeedsAnimate to consider posting a commit task. |
| 835 VLOG(2) << "ThreadProxy::BeginMainFrame: RAF requested."; |
| 829 main().animate_requested = false; | 836 main().animate_requested = false; |
| 830 SetNeedsAnimate(); | 837 SetNeedsAnimate(); |
| 838 } else { |
| 839 VLOG(2) << "ThreadProxy::BeginMainFrame: RAF NOT requested."; |
| 831 } | 840 } |
| 832 | 841 |
| 833 if (!updated && can_cancel_this_commit) { | 842 if (!updated && can_cancel_this_commit) { |
| 834 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); | 843 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); |
| 835 VLOG(2) << "ThreadProxy::BeginMainFrame: EarlyOut_NoUpdates"; | 844 VLOG(2) << "ThreadProxy::BeginMainFrame: EarlyOut_NoUpdates"; |
| 836 bool did_handle = true; | 845 bool did_handle = true; |
| 837 Proxy::ImplThreadTaskRunner()->PostTask( | 846 Proxy::ImplThreadTaskRunner()->PostTask( |
| 838 FROM_HERE, | 847 FROM_HERE, |
| 839 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 848 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 840 impl_thread_weak_ptr_, | 849 impl_thread_weak_ptr_, |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 | 1419 |
| 1411 impl().timing_history.DidActivateSyncTree(); | 1420 impl().timing_history.DidActivateSyncTree(); |
| 1412 } | 1421 } |
| 1413 | 1422 |
| 1414 void ThreadProxy::DidManageTiles() { | 1423 void ThreadProxy::DidManageTiles() { |
| 1415 DCHECK(IsImplThread()); | 1424 DCHECK(IsImplThread()); |
| 1416 impl().scheduler->DidManageTiles(); | 1425 impl().scheduler->DidManageTiles(); |
| 1417 } | 1426 } |
| 1418 | 1427 |
| 1419 } // namespace cc | 1428 } // namespace cc |
| OLD | NEW |