Chromium Code Reviews| 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 } | 670 } |
| 671 | 671 |
| 672 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { | 672 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { |
| 673 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 673 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
| 674 DCHECK(IsImplThread()); | 674 DCHECK(IsImplThread()); |
| 675 impl().layer_tree_host_impl->FinishAllRendering(); | 675 impl().layer_tree_host_impl->FinishAllRendering(); |
| 676 completion->Signal(); | 676 completion->Signal(); |
| 677 } | 677 } |
| 678 | 678 |
| 679 void ThreadProxy::ScheduledActionSendBeginMainFrame() { | 679 void ThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 680 VLOG(2) << "ThreadProxy::ScheduledActionSendBeginMainFrame"; | |
| 680 unsigned int begin_frame_id = nextBeginFrameId++; | 681 unsigned int begin_frame_id = nextBeginFrameId++; |
| 681 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 682 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 682 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); | 683 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); |
| 683 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( | 684 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
| 684 new BeginMainFrameAndCommitState); | 685 new BeginMainFrameAndCommitState); |
| 685 begin_main_frame_state->begin_frame_id = begin_frame_id; | 686 begin_main_frame_state->begin_frame_id = begin_frame_id; |
| 686 begin_main_frame_state->begin_frame_args = | 687 begin_main_frame_state->begin_frame_args = |
| 687 impl().layer_tree_host_impl->CurrentBeginFrameArgs(); | 688 impl().layer_tree_host_impl->CurrentBeginFrameArgs(); |
| 688 begin_main_frame_state->scroll_info = | 689 begin_main_frame_state->scroll_info = |
| 689 impl().layer_tree_host_impl->ProcessScrollDeltas(); | 690 impl().layer_tree_host_impl->ProcessScrollDeltas(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 708 } | 709 } |
| 709 | 710 |
| 710 void ThreadProxy::BeginMainFrame( | 711 void ThreadProxy::BeginMainFrame( |
| 711 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 712 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 712 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 713 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 713 benchmark_instrumentation::kDoBeginFrame, | 714 benchmark_instrumentation::kDoBeginFrame, |
| 714 begin_main_frame_state->begin_frame_id); | 715 begin_main_frame_state->begin_frame_id); |
| 715 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); | 716 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
| 716 DCHECK(IsMainThread()); | 717 DCHECK(IsMainThread()); |
| 717 | 718 |
| 719 VLOG(2) << "ThreadProxy::BeginMainFrame - BEGIN"; | |
| 720 | |
| 718 if (main().defer_commits) { | 721 if (main().defer_commits) { |
| 719 main().pending_deferred_commit = begin_main_frame_state.Pass(); | 722 main().pending_deferred_commit = begin_main_frame_state.Pass(); |
| 720 layer_tree_host()->DidDeferCommit(); | 723 layer_tree_host()->DidDeferCommit(); |
| 721 TRACE_EVENT_INSTANT0( | 724 TRACE_EVENT_INSTANT0( |
| 722 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); | 725 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); |
| 726 VLOG(2) << "ThreadProxy::BeginMainFrame: EarlyOut_DeferCommits"; | |
| 723 return; | 727 return; |
| 724 } | 728 } |
| 725 | 729 |
| 726 // If the commit finishes, LayerTreeHost will transfer its swap promises to | 730 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
| 727 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the | 731 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the |
| 728 // remaining swap promises. | 732 // remaining swap promises. |
| 729 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); | 733 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); |
| 730 | 734 |
| 731 main().commit_requested = false; | 735 main().commit_requested = false; |
| 732 main().commit_request_sent_to_impl_thread = false; | 736 main().commit_request_sent_to_impl_thread = false; |
| 733 main().animate_requested = false; | 737 main().animate_requested = false; |
| 734 | 738 |
| 735 if (!layer_tree_host()->visible()) { | 739 if (!layer_tree_host()->visible()) { |
| 736 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 740 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
| 741 VLOG(2) << "ThreadProxy::BeginMainFrame: EarlyOut_NotVisible"; | |
| 737 bool did_handle = false; | 742 bool did_handle = false; |
| 738 Proxy::ImplThreadTaskRunner()->PostTask( | 743 Proxy::ImplThreadTaskRunner()->PostTask( |
| 739 FROM_HERE, | 744 FROM_HERE, |
| 740 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 745 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 741 impl_thread_weak_ptr_, | 746 impl_thread_weak_ptr_, |
| 742 did_handle)); | 747 did_handle)); |
| 743 return; | 748 return; |
| 744 } | 749 } |
| 745 | 750 |
| 746 if (layer_tree_host()->output_surface_lost()) { | 751 if (layer_tree_host()->output_surface_lost()) { |
| 747 TRACE_EVENT_INSTANT0( | 752 TRACE_EVENT_INSTANT0( |
| 748 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); | 753 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); |
| 754 VLOG(2) << "ThreadProxy::BeginMainFrame: EarlyOut_OutputSurfaceLost"; | |
| 749 bool did_handle = false; | 755 bool did_handle = false; |
| 750 Proxy::ImplThreadTaskRunner()->PostTask( | 756 Proxy::ImplThreadTaskRunner()->PostTask( |
| 751 FROM_HERE, | 757 FROM_HERE, |
| 752 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 758 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 753 impl_thread_weak_ptr_, | 759 impl_thread_weak_ptr_, |
| 754 did_handle)); | 760 did_handle)); |
| 755 return; | 761 return; |
| 756 } | 762 } |
| 757 | 763 |
| 758 // Do not notify the impl thread of commit requests that occur during | 764 // Do not notify the impl thread of commit requests that occur during |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 | 816 |
| 811 bool updated = layer_tree_host()->UpdateLayers(queue.get()); | 817 bool updated = layer_tree_host()->UpdateLayers(queue.get()); |
| 812 | 818 |
| 813 layer_tree_host()->WillCommit(); | 819 layer_tree_host()->WillCommit(); |
| 814 | 820 |
| 815 // Before calling animate, we set main().animate_requested to false. If it is | 821 // Before calling animate, we set main().animate_requested to false. If it is |
| 816 // true now, it means SetNeedAnimate was called again, but during a state when | 822 // true now, it means SetNeedAnimate was called again, but during a state when |
| 817 // main().commit_request_sent_to_impl_thread = true. We need to force that | 823 // main().commit_request_sent_to_impl_thread = true. We need to force that |
| 818 // call to happen again now so that the commit request is sent to the impl | 824 // call to happen again now so that the commit request is sent to the impl |
| 819 // thread. | 825 // thread. |
| 820 if (main().animate_requested) { | 826 if (main().animate_requested) { |
|
Ken Russell (switch to Gerrit)
2014/08/29 22:25:43
Should this branch be instrumented too? As well as
Zhenyao Mo
2014/08/29 23:11:11
The logging I added are on the direct call stack t
| |
| 821 // Forces SetNeedsAnimate to consider posting a commit task. | 827 // Forces SetNeedsAnimate to consider posting a commit task. |
| 822 main().animate_requested = false; | 828 main().animate_requested = false; |
| 823 SetNeedsAnimate(); | 829 SetNeedsAnimate(); |
| 824 } | 830 } |
| 825 | 831 |
| 826 if (!updated && can_cancel_this_commit) { | 832 if (!updated && can_cancel_this_commit) { |
| 827 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); | 833 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); |
| 834 VLOG(2) << "ThreadProxy::BeginMainFrame: EarlyOut_NoUpdates"; | |
| 828 bool did_handle = true; | 835 bool did_handle = true; |
| 829 Proxy::ImplThreadTaskRunner()->PostTask( | 836 Proxy::ImplThreadTaskRunner()->PostTask( |
| 830 FROM_HERE, | 837 FROM_HERE, |
| 831 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 838 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 832 impl_thread_weak_ptr_, | 839 impl_thread_weak_ptr_, |
| 833 did_handle)); | 840 did_handle)); |
| 834 | 841 |
| 835 // Although the commit is internally aborted, this is because it has been | 842 // Although the commit is internally aborted, this is because it has been |
| 836 // detected to be a no-op. From the perspective of an embedder, this commit | 843 // detected to be a no-op. From the perspective of an embedder, this commit |
| 837 // went through, and input should no longer be throttled, etc. | 844 // went through, and input should no longer be throttled, etc. |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1390 | 1397 |
| 1391 impl().timing_history.DidActivateSyncTree(); | 1398 impl().timing_history.DidActivateSyncTree(); |
| 1392 } | 1399 } |
| 1393 | 1400 |
| 1394 void ThreadProxy::DidManageTiles() { | 1401 void ThreadProxy::DidManageTiles() { |
| 1395 DCHECK(IsImplThread()); | 1402 DCHECK(IsImplThread()); |
| 1396 impl().scheduler->DidManageTiles(); | 1403 impl().scheduler->DidManageTiles(); |
| 1397 } | 1404 } |
| 1398 | 1405 |
| 1399 } // namespace cc | 1406 } // namespace cc |
| OLD | NEW |