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