| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 &completion)); | 147 &completion)); |
| 148 completion.Wait(); | 148 completion.Wait(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool ThreadProxy::IsStarted() const { | 151 bool ThreadProxy::IsStarted() const { |
| 152 DCHECK(Proxy::IsMainThread()); | 152 DCHECK(Proxy::IsMainThread()); |
| 153 return main().started; | 153 return main().started; |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool ThreadProxy::CommitToActiveTree() const { | 156 bool ThreadProxy::CommitToActiveTree() const { |
| 157 // With ThreadProxy and impl-side painting, we use a pending tree and activate | 157 // With ThreadProxy we use a pending tree and activate it once it's ready to |
| 158 // it once it's ready to draw. | 158 // draw. |
| 159 return !impl().layer_tree_host_impl->settings().impl_side_painting; | 159 return false; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void ThreadProxy::SetLayerTreeHostClientReady() { | 162 void ThreadProxy::SetLayerTreeHostClientReady() { |
| 163 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReady"); | 163 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReady"); |
| 164 Proxy::ImplThreadTaskRunner()->PostTask( | 164 Proxy::ImplThreadTaskRunner()->PostTask( |
| 165 FROM_HERE, | 165 FROM_HERE, |
| 166 base::Bind(&ThreadProxy::SetLayerTreeHostClientReadyOnImplThread, | 166 base::Bind(&ThreadProxy::SetLayerTreeHostClientReadyOnImplThread, |
| 167 impl_thread_weak_ptr_)); | 167 impl_thread_weak_ptr_)); |
| 168 } | 168 } |
| 169 | 169 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 Proxy::MainThreadTaskRunner()->PostTask( | 694 Proxy::MainThreadTaskRunner()->PostTask( |
| 695 FROM_HERE, | 695 FROM_HERE, |
| 696 base::Bind(&ThreadProxy::BeginMainFrame, | 696 base::Bind(&ThreadProxy::BeginMainFrame, |
| 697 main_thread_weak_ptr_, | 697 main_thread_weak_ptr_, |
| 698 base::Passed(&begin_main_frame_state))); | 698 base::Passed(&begin_main_frame_state))); |
| 699 devtools_instrumentation::DidRequestMainThreadFrame( | 699 devtools_instrumentation::DidRequestMainThreadFrame( |
| 700 impl().layer_tree_host_id); | 700 impl().layer_tree_host_id); |
| 701 impl().timing_history.DidBeginMainFrame(); | 701 impl().timing_history.DidBeginMainFrame(); |
| 702 } | 702 } |
| 703 | 703 |
| 704 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { | |
| 705 Proxy::MainThreadTaskRunner()->PostTask( | |
| 706 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon, | |
| 707 main_thread_weak_ptr_)); | |
| 708 } | |
| 709 | |
| 710 void ThreadProxy::BeginMainFrame( | 704 void ThreadProxy::BeginMainFrame( |
| 711 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 705 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 712 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 706 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 713 benchmark_instrumentation::kDoBeginFrame, | 707 benchmark_instrumentation::kDoBeginFrame, |
| 714 begin_main_frame_state->begin_frame_id); | 708 begin_main_frame_state->begin_frame_id); |
| 715 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); | 709 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
| 716 DCHECK(IsMainThread()); | 710 DCHECK(IsMainThread()); |
| 717 | 711 |
| 718 if (main().defer_commits) { | 712 if (main().defer_commits) { |
| 719 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 713 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 impl_thread_weak_ptr_, | 854 impl_thread_weak_ptr_, |
| 861 &completion, | 855 &completion, |
| 862 queue.release())); | 856 queue.release())); |
| 863 completion.Wait(); | 857 completion.Wait(); |
| 864 } | 858 } |
| 865 | 859 |
| 866 layer_tree_host()->CommitComplete(); | 860 layer_tree_host()->CommitComplete(); |
| 867 layer_tree_host()->DidBeginMainFrame(); | 861 layer_tree_host()->DidBeginMainFrame(); |
| 868 } | 862 } |
| 869 | 863 |
| 870 void ThreadProxy::BeginMainFrameNotExpectedSoon() { | |
| 871 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); | |
| 872 DCHECK(IsMainThread()); | |
| 873 layer_tree_host()->BeginMainFrameNotExpectedSoon(); | |
| 874 } | |
| 875 | |
| 876 void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion, | 864 void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion, |
| 877 ResourceUpdateQueue* raw_queue) { | 865 ResourceUpdateQueue* raw_queue) { |
| 878 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); | 866 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
| 879 DCHECK(!impl().commit_completion_event); | 867 DCHECK(!impl().commit_completion_event); |
| 880 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 868 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
| 881 DCHECK(impl().scheduler); | 869 DCHECK(impl().scheduler); |
| 882 DCHECK(impl().scheduler->CommitPending()); | 870 DCHECK(impl().scheduler->CommitPending()); |
| 883 | 871 |
| 884 if (!impl().layer_tree_host_impl) { | 872 if (!impl().layer_tree_host_impl) { |
| 885 TRACE_EVENT_INSTANT0( | 873 TRACE_EVENT_INSTANT0( |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 1014 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| 1027 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 1015 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
| 1028 DrawResult result; | 1016 DrawResult result; |
| 1029 | 1017 |
| 1030 DCHECK(IsImplThread()); | 1018 DCHECK(IsImplThread()); |
| 1031 DCHECK(impl().layer_tree_host_impl.get()); | 1019 DCHECK(impl().layer_tree_host_impl.get()); |
| 1032 | 1020 |
| 1033 impl().timing_history.DidStartDrawing(); | 1021 impl().timing_history.DidStartDrawing(); |
| 1034 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 1022 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
| 1035 | 1023 |
| 1036 if (impl().layer_tree_host_impl->pending_tree()) { | 1024 if (impl().layer_tree_host_impl->pending_tree()) |
| 1037 bool update_lcd_text = false; | 1025 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); |
| 1038 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties( | |
| 1039 update_lcd_text); | |
| 1040 } | |
| 1041 | 1026 |
| 1042 // This method is called on a forced draw, regardless of whether we are able | 1027 // This method is called on a forced draw, regardless of whether we are able |
| 1043 // to produce a frame, as the calling site on main thread is blocked until its | 1028 // to produce a frame, as the calling site on main thread is blocked until its |
| 1044 // request completes, and we signal completion here. If CanDraw() is false, we | 1029 // request completes, and we signal completion here. If CanDraw() is false, we |
| 1045 // will indicate success=false to the caller, but we must still signal | 1030 // will indicate success=false to the caller, but we must still signal |
| 1046 // completion to avoid deadlock. | 1031 // completion to avoid deadlock. |
| 1047 | 1032 |
| 1048 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 1033 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
| 1049 // frame, so can only be used when such a frame is possible. Since | 1034 // frame, so can only be used when such a frame is possible. Since |
| 1050 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 1035 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 } | 1374 } |
| 1390 | 1375 |
| 1391 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1376 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 1392 DCHECK(IsImplThread()); | 1377 DCHECK(IsImplThread()); |
| 1393 Proxy::MainThreadTaskRunner()->PostTask( | 1378 Proxy::MainThreadTaskRunner()->PostTask( |
| 1394 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | 1379 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, |
| 1395 main_thread_weak_ptr_)); | 1380 main_thread_weak_ptr_)); |
| 1396 } | 1381 } |
| 1397 | 1382 |
| 1398 } // namespace cc | 1383 } // namespace cc |
| OLD | NEW |