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/layer_tree_host_in_process.h" | 5 #include "cc/trees/layer_tree_host_in_process.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
24 #include "base/stl_util.h" | 24 #include "base/stl_util.h" |
25 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
28 #include "base/timer/elapsed_timer.h" | 28 #include "base/timer/elapsed_timer.h" |
29 #include "base/trace_event/trace_event.h" | 29 #include "base/trace_event/trace_event.h" |
30 #include "base/trace_event/trace_event_argument.h" | 30 #include "base/trace_event/trace_event_argument.h" |
31 #include "cc/base/histograms.h" | 31 #include "cc/base/histograms.h" |
32 #include "cc/base/math_util.h" | 32 #include "cc/base/math_util.h" |
33 #include "cc/blimp/client_picture_cache.h" | |
34 #include "cc/blimp/engine_picture_cache.h" | |
35 #include "cc/blimp/image_serialization_processor.h" | |
36 #include "cc/blimp/picture_data.h" | |
37 #include "cc/blimp/picture_data_conversions.h" | |
38 #include "cc/debug/devtools_instrumentation.h" | 33 #include "cc/debug/devtools_instrumentation.h" |
39 #include "cc/debug/frame_viewer_instrumentation.h" | 34 #include "cc/debug/frame_viewer_instrumentation.h" |
40 #include "cc/debug/rendering_stats_instrumentation.h" | 35 #include "cc/debug/rendering_stats_instrumentation.h" |
41 #include "cc/input/layer_selection_bound.h" | 36 #include "cc/input/layer_selection_bound.h" |
42 #include "cc/input/page_scale_animation.h" | 37 #include "cc/input/page_scale_animation.h" |
43 #include "cc/layers/heads_up_display_layer.h" | 38 #include "cc/layers/heads_up_display_layer.h" |
44 #include "cc/layers/heads_up_display_layer_impl.h" | 39 #include "cc/layers/heads_up_display_layer_impl.h" |
45 #include "cc/layers/layer.h" | 40 #include "cc/layers/layer.h" |
46 #include "cc/layers/layer_iterator.h" | 41 #include "cc/layers/layer_iterator.h" |
47 #include "cc/layers/painted_scrollbar_layer.h" | 42 #include "cc/layers/painted_scrollbar_layer.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 110 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
116 settings_(*params->settings), | 111 settings_(*params->settings), |
117 debug_state_(settings_.initial_debug_state), | 112 debug_state_(settings_.initial_debug_state), |
118 visible_(false), | 113 visible_(false), |
119 has_gpu_rasterization_trigger_(false), | 114 has_gpu_rasterization_trigger_(false), |
120 content_is_suitable_for_gpu_rasterization_(true), | 115 content_is_suitable_for_gpu_rasterization_(true), |
121 gpu_rasterization_histogram_recorded_(false), | 116 gpu_rasterization_histogram_recorded_(false), |
122 did_complete_scale_animation_(false), | 117 did_complete_scale_animation_(false), |
123 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 118 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
124 task_graph_runner_(params->task_graph_runner), | 119 task_graph_runner_(params->task_graph_runner), |
125 image_serialization_processor_(params->image_serialization_processor), | |
126 image_worker_task_runner_(params->image_worker_task_runner) { | 120 image_worker_task_runner_(params->image_worker_task_runner) { |
127 DCHECK(task_graph_runner_); | 121 DCHECK(task_graph_runner_); |
128 DCHECK(layer_tree_); | 122 DCHECK(layer_tree_); |
129 DCHECK_NE(compositor_mode_, CompositorMode::REMOTE); | |
130 | 123 |
131 rendering_stats_instrumentation_->set_record_rendering_stats( | 124 rendering_stats_instrumentation_->set_record_rendering_stats( |
132 debug_state_.RecordRenderingStats()); | 125 debug_state_.RecordRenderingStats()); |
133 } | 126 } |
134 | 127 |
135 void LayerTreeHostInProcess::InitializeThreaded( | 128 void LayerTreeHostInProcess::InitializeThreaded( |
136 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 129 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
137 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 130 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
138 task_runner_provider_ = | 131 task_runner_provider_ = |
139 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 132 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
140 std::unique_ptr<ProxyMain> proxy_main = | 133 std::unique_ptr<ProxyMain> proxy_main = |
141 base::MakeUnique<ProxyMain>(this, task_runner_provider_.get()); | 134 base::MakeUnique<ProxyMain>(this, task_runner_provider_.get()); |
142 InitializeProxy(std::move(proxy_main)); | 135 InitializeProxy(std::move(proxy_main)); |
143 } | 136 } |
144 | 137 |
145 void LayerTreeHostInProcess::InitializeSingleThreaded( | 138 void LayerTreeHostInProcess::InitializeSingleThreaded( |
146 LayerTreeHostSingleThreadClient* single_thread_client, | 139 LayerTreeHostSingleThreadClient* single_thread_client, |
147 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 140 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { |
148 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | 141 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
149 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, | 142 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, |
150 task_runner_provider_.get())); | 143 task_runner_provider_.get())); |
151 } | 144 } |
152 | 145 |
153 void LayerTreeHostInProcess::InitializeForTesting( | 146 void LayerTreeHostInProcess::InitializeForTesting( |
154 std::unique_ptr<TaskRunnerProvider> task_runner_provider, | 147 std::unique_ptr<TaskRunnerProvider> task_runner_provider, |
155 std::unique_ptr<Proxy> proxy_for_testing) { | 148 std::unique_ptr<Proxy> proxy_for_testing) { |
156 task_runner_provider_ = std::move(task_runner_provider); | 149 task_runner_provider_ = std::move(task_runner_provider); |
157 | |
158 InitializePictureCacheForTesting(); | |
159 | |
160 InitializeProxy(std::move(proxy_for_testing)); | 150 InitializeProxy(std::move(proxy_for_testing)); |
161 } | 151 } |
162 | 152 |
163 void LayerTreeHostInProcess::InitializePictureCacheForTesting() { | |
164 if (!image_serialization_processor_) | |
165 return; | |
166 | |
167 // Initialize both engine and client cache to ensure serialization tests | |
168 // with a single LayerTreeHostInProcess can work correctly. | |
169 engine_picture_cache_ = | |
170 image_serialization_processor_->CreateEnginePictureCache(); | |
171 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); | |
172 client_picture_cache_ = | |
173 image_serialization_processor_->CreateClientPictureCache(); | |
174 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); | |
175 } | |
176 | |
177 void LayerTreeHostInProcess::SetTaskRunnerProviderForTesting( | 153 void LayerTreeHostInProcess::SetTaskRunnerProviderForTesting( |
178 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { | 154 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { |
179 DCHECK(!task_runner_provider_); | 155 DCHECK(!task_runner_provider_); |
180 task_runner_provider_ = std::move(task_runner_provider); | 156 task_runner_provider_ = std::move(task_runner_provider); |
181 } | 157 } |
182 | 158 |
183 void LayerTreeHostInProcess::SetUIResourceManagerForTesting( | 159 void LayerTreeHostInProcess::SetUIResourceManagerForTesting( |
184 std::unique_ptr<UIResourceManager> ui_resource_manager) { | 160 std::unique_ptr<UIResourceManager> ui_resource_manager) { |
185 ui_resource_manager_ = std::move(ui_resource_manager); | 161 ui_resource_manager_ = std::move(ui_resource_manager); |
186 } | 162 } |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 return compositor_mode_ == CompositorMode::SINGLE_THREADED; | 835 return compositor_mode_ == CompositorMode::SINGLE_THREADED; |
860 } | 836 } |
861 | 837 |
862 bool LayerTreeHostInProcess::IsThreaded() const { | 838 bool LayerTreeHostInProcess::IsThreaded() const { |
863 DCHECK(compositor_mode_ != CompositorMode::THREADED || | 839 DCHECK(compositor_mode_ != CompositorMode::THREADED || |
864 task_runner_provider_->HasImplThread()); | 840 task_runner_provider_->HasImplThread()); |
865 return compositor_mode_ == CompositorMode::THREADED; | 841 return compositor_mode_ == CompositorMode::THREADED; |
866 } | 842 } |
867 | 843 |
868 } // namespace cc | 844 } // namespace cc |
OLD | NEW |