| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/debug/trace_event_synthetic_delay.h" |
| 12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 13 #include "cc/base/swap_promise.h" | 14 #include "cc/base/swap_promise.h" |
| 14 #include "cc/debug/benchmark_instrumentation.h" | 15 #include "cc/debug/benchmark_instrumentation.h" |
| 15 #include "cc/input/input_handler.h" | 16 #include "cc/input/input_handler.h" |
| 16 #include "cc/output/context_provider.h" | 17 #include "cc/output/context_provider.h" |
| 17 #include "cc/output/output_surface.h" | 18 #include "cc/output/output_surface.h" |
| 18 #include "cc/quads/draw_quad.h" | 19 #include "cc/quads/draw_quad.h" |
| 19 #include "cc/resources/prioritized_resource_manager.h" | 20 #include "cc/resources/prioritized_resource_manager.h" |
| 20 #include "cc/scheduler/delay_based_time_source.h" | 21 #include "cc/scheduler/delay_based_time_source.h" |
| 21 #include "cc/scheduler/frame_rate_controller.h" | 22 #include "cc/scheduler/frame_rate_controller.h" |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 if (begin_main_frame_sent_completion_event_on_impl_thread_) { | 752 if (begin_main_frame_sent_completion_event_on_impl_thread_) { |
| 752 begin_main_frame_sent_completion_event_on_impl_thread_->Signal(); | 753 begin_main_frame_sent_completion_event_on_impl_thread_->Signal(); |
| 753 begin_main_frame_sent_completion_event_on_impl_thread_ = NULL; | 754 begin_main_frame_sent_completion_event_on_impl_thread_ = NULL; |
| 754 } | 755 } |
| 755 begin_main_frame_sent_time_ = base::TimeTicks::HighResNow(); | 756 begin_main_frame_sent_time_ = base::TimeTicks::HighResNow(); |
| 756 } | 757 } |
| 757 | 758 |
| 758 void ThreadProxy::BeginMainFrame( | 759 void ThreadProxy::BeginMainFrame( |
| 759 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 760 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 760 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame"); | 761 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame"); |
| 762 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
| 761 DCHECK(IsMainThread()); | 763 DCHECK(IsMainThread()); |
| 762 | 764 |
| 763 if (!layer_tree_host()) | 765 if (!layer_tree_host()) |
| 764 return; | 766 return; |
| 765 | 767 |
| 766 if (defer_commits_) { | 768 if (defer_commits_) { |
| 767 pending_deferred_commit_ = begin_main_frame_state.Pass(); | 769 pending_deferred_commit_ = begin_main_frame_state.Pass(); |
| 768 layer_tree_host()->DidDeferCommit(); | 770 layer_tree_host()->DidDeferCommit(); |
| 769 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); | 771 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
| 770 return; | 772 return; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 | 834 |
| 833 // Recreate all UI resources if there were evicted UI resources when the impl | 835 // Recreate all UI resources if there were evicted UI resources when the impl |
| 834 // thread initiated the commit. | 836 // thread initiated the commit. |
| 835 bool evicted_ui_resources = begin_main_frame_state | 837 bool evicted_ui_resources = begin_main_frame_state |
| 836 ? begin_main_frame_state->evicted_ui_resources | 838 ? begin_main_frame_state->evicted_ui_resources |
| 837 : false; | 839 : false; |
| 838 if (evicted_ui_resources) | 840 if (evicted_ui_resources) |
| 839 layer_tree_host()->RecreateUIResources(); | 841 layer_tree_host()->RecreateUIResources(); |
| 840 | 842 |
| 841 layer_tree_host()->Layout(); | 843 layer_tree_host()->Layout(); |
| 844 TRACE_EVENT_SYNTHETIC_DELAY_END("cc.BeginMainFrame"); |
| 842 | 845 |
| 843 // Clear the commit flag after updating animations and layout here --- objects | 846 // Clear the commit flag after updating animations and layout here --- objects |
| 844 // that only layout when painted will trigger another SetNeedsCommit inside | 847 // that only layout when painted will trigger another SetNeedsCommit inside |
| 845 // UpdateLayers. | 848 // UpdateLayers. |
| 846 commit_requested_ = false; | 849 commit_requested_ = false; |
| 847 commit_request_sent_to_impl_thread_ = false; | 850 commit_request_sent_to_impl_thread_ = false; |
| 848 bool can_cancel_this_commit = | 851 bool can_cancel_this_commit = |
| 849 can_cancel_commit_ && | 852 can_cancel_commit_ && |
| 850 !in_composite_and_readback_ && | 853 !in_composite_and_readback_ && |
| 851 !evicted_ui_resources; | 854 !evicted_ui_resources; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 Proxy::MainThreadTaskRunner()->PostTask( | 1073 Proxy::MainThreadTaskRunner()->PostTask( |
| 1071 FROM_HERE, | 1074 FROM_HERE, |
| 1072 base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, | 1075 base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, |
| 1073 main_thread_weak_ptr_)); | 1076 main_thread_weak_ptr_)); |
| 1074 } | 1077 } |
| 1075 | 1078 |
| 1076 DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( | 1079 DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( |
| 1077 bool forced_draw, | 1080 bool forced_draw, |
| 1078 bool swap_requested, | 1081 bool swap_requested, |
| 1079 bool readback_requested) { | 1082 bool readback_requested) { |
| 1083 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
| 1080 DrawSwapReadbackResult result; | 1084 DrawSwapReadbackResult result; |
| 1081 result.did_draw = false; | 1085 result.did_draw = false; |
| 1082 result.did_swap = false; | 1086 result.did_swap = false; |
| 1083 result.did_readback = false; | 1087 result.did_readback = false; |
| 1084 DCHECK(IsImplThread()); | 1088 DCHECK(IsImplThread()); |
| 1085 DCHECK(layer_tree_host_impl_.get()); | 1089 DCHECK(layer_tree_host_impl_.get()); |
| 1086 if (!layer_tree_host_impl_) | 1090 if (!layer_tree_host_impl_) |
| 1087 return result; | 1091 return result; |
| 1088 | 1092 |
| 1089 DCHECK(layer_tree_host_impl_->renderer()); | 1093 DCHECK(layer_tree_host_impl_->renderer()); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 commit_to_activate_duration_history_.InsertSample( | 1646 commit_to_activate_duration_history_.InsertSample( |
| 1643 base::TimeTicks::HighResNow() - commit_complete_time_); | 1647 base::TimeTicks::HighResNow() - commit_complete_time_); |
| 1644 } | 1648 } |
| 1645 | 1649 |
| 1646 void ThreadProxy::DidManageTiles() { | 1650 void ThreadProxy::DidManageTiles() { |
| 1647 DCHECK(IsImplThread()); | 1651 DCHECK(IsImplThread()); |
| 1648 scheduler_on_impl_thread_->DidManageTiles(); | 1652 scheduler_on_impl_thread_->DidManageTiles(); |
| 1649 } | 1653 } |
| 1650 | 1654 |
| 1651 } // namespace cc | 1655 } // namespace cc |
| OLD | NEW |