| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "cc/layers/heads_up_display_layer.h" | 42 #include "cc/layers/heads_up_display_layer.h" |
| 43 #include "cc/layers/heads_up_display_layer_impl.h" | 43 #include "cc/layers/heads_up_display_layer_impl.h" |
| 44 #include "cc/layers/layer.h" | 44 #include "cc/layers/layer.h" |
| 45 #include "cc/layers/layer_iterator.h" | 45 #include "cc/layers/layer_iterator.h" |
| 46 #include "cc/layers/layer_proto_converter.h" | 46 #include "cc/layers/layer_proto_converter.h" |
| 47 #include "cc/layers/painted_scrollbar_layer.h" | 47 #include "cc/layers/painted_scrollbar_layer.h" |
| 48 #include "cc/proto/gfx_conversions.h" | 48 #include "cc/proto/gfx_conversions.h" |
| 49 #include "cc/proto/layer_tree.pb.h" | 49 #include "cc/proto/layer_tree.pb.h" |
| 50 #include "cc/proto/layer_tree_host.pb.h" | 50 #include "cc/proto/layer_tree_host.pb.h" |
| 51 #include "cc/resources/ui_resource_manager.h" | 51 #include "cc/resources/ui_resource_manager.h" |
| 52 #include "cc/scheduler/begin_frame_source.h" | |
| 53 #include "cc/trees/draw_property_utils.h" | 52 #include "cc/trees/draw_property_utils.h" |
| 54 #include "cc/trees/layer_tree_host_client.h" | 53 #include "cc/trees/layer_tree_host_client.h" |
| 55 #include "cc/trees/layer_tree_host_common.h" | 54 #include "cc/trees/layer_tree_host_common.h" |
| 56 #include "cc/trees/layer_tree_host_impl.h" | 55 #include "cc/trees/layer_tree_host_impl.h" |
| 57 #include "cc/trees/layer_tree_impl.h" | 56 #include "cc/trees/layer_tree_impl.h" |
| 58 #include "cc/trees/property_tree_builder.h" | 57 #include "cc/trees/property_tree_builder.h" |
| 59 #include "cc/trees/proxy_main.h" | 58 #include "cc/trees/proxy_main.h" |
| 60 #include "cc/trees/remote_channel_impl.h" | 59 #include "cc/trees/remote_channel_impl.h" |
| 61 #include "cc/trees/single_thread_proxy.h" | 60 #include "cc/trees/single_thread_proxy.h" |
| 62 #include "cc/trees/swap_promise_manager.h" | 61 #include "cc/trees/swap_promise_manager.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 LayerTreeHostInProcess::InitParams::~InitParams() {} | 128 LayerTreeHostInProcess::InitParams::~InitParams() {} |
| 130 | 129 |
| 131 std::unique_ptr<LayerTreeHostInProcess> LayerTreeHostInProcess::CreateThreaded( | 130 std::unique_ptr<LayerTreeHostInProcess> LayerTreeHostInProcess::CreateThreaded( |
| 132 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 131 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 133 InitParams* params) { | 132 InitParams* params) { |
| 134 DCHECK(params->main_task_runner.get()); | 133 DCHECK(params->main_task_runner.get()); |
| 135 DCHECK(impl_task_runner.get()); | 134 DCHECK(impl_task_runner.get()); |
| 136 DCHECK(params->settings); | 135 DCHECK(params->settings); |
| 137 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( | 136 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
| 138 new LayerTreeHostInProcess(params, CompositorMode::THREADED)); | 137 new LayerTreeHostInProcess(params, CompositorMode::THREADED)); |
| 139 layer_tree_host->InitializeThreaded( | 138 layer_tree_host->InitializeThreaded(params->main_task_runner, |
| 140 params->main_task_runner, impl_task_runner, | 139 impl_task_runner); |
| 141 std::move(params->external_begin_frame_source)); | |
| 142 return layer_tree_host; | 140 return layer_tree_host; |
| 143 } | 141 } |
| 144 | 142 |
| 145 std::unique_ptr<LayerTreeHostInProcess> | 143 std::unique_ptr<LayerTreeHostInProcess> |
| 146 LayerTreeHostInProcess::CreateSingleThreaded( | 144 LayerTreeHostInProcess::CreateSingleThreaded( |
| 147 LayerTreeHostSingleThreadClient* single_thread_client, | 145 LayerTreeHostSingleThreadClient* single_thread_client, |
| 148 InitParams* params) { | 146 InitParams* params) { |
| 149 DCHECK(params->settings); | 147 DCHECK(params->settings); |
| 150 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( | 148 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
| 151 new LayerTreeHostInProcess(params, CompositorMode::SINGLE_THREADED)); | 149 new LayerTreeHostInProcess(params, CompositorMode::SINGLE_THREADED)); |
| 152 layer_tree_host->InitializeSingleThreaded( | 150 layer_tree_host->InitializeSingleThreaded(single_thread_client, |
| 153 single_thread_client, params->main_task_runner, | 151 params->main_task_runner); |
| 154 std::move(params->external_begin_frame_source)); | |
| 155 return layer_tree_host; | 152 return layer_tree_host; |
| 156 } | 153 } |
| 157 | 154 |
| 158 std::unique_ptr<LayerTreeHostInProcess> | 155 std::unique_ptr<LayerTreeHostInProcess> |
| 159 LayerTreeHostInProcess::CreateRemoteServer( | 156 LayerTreeHostInProcess::CreateRemoteServer( |
| 160 RemoteProtoChannel* remote_proto_channel, | 157 RemoteProtoChannel* remote_proto_channel, |
| 161 InitParams* params) { | 158 InitParams* params) { |
| 162 DCHECK(params->main_task_runner.get()); | 159 DCHECK(params->main_task_runner.get()); |
| 163 DCHECK(params->settings); | 160 DCHECK(params->settings); |
| 164 DCHECK(remote_proto_channel); | 161 DCHECK(remote_proto_channel); |
| 165 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::CreateRemoteServer"); | 162 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::CreateRemoteServer"); |
| 166 | 163 |
| 167 // Using an external begin frame source is not supported on the server in | |
| 168 // remote mode. | |
| 169 DCHECK(!params->settings->use_external_begin_frame_source); | |
| 170 DCHECK(!params->external_begin_frame_source); | |
| 171 DCHECK(params->image_serialization_processor); | 164 DCHECK(params->image_serialization_processor); |
| 172 | 165 |
| 173 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( | 166 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
| 174 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); | 167 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); |
| 175 layer_tree_host->InitializeRemoteServer(remote_proto_channel, | 168 layer_tree_host->InitializeRemoteServer(remote_proto_channel, |
| 176 params->main_task_runner); | 169 params->main_task_runner); |
| 177 return layer_tree_host; | 170 return layer_tree_host; |
| 178 } | 171 } |
| 179 | 172 |
| 180 std::unique_ptr<LayerTreeHostInProcess> | 173 std::unique_ptr<LayerTreeHostInProcess> |
| 181 LayerTreeHostInProcess::CreateRemoteClient( | 174 LayerTreeHostInProcess::CreateRemoteClient( |
| 182 RemoteProtoChannel* remote_proto_channel, | 175 RemoteProtoChannel* remote_proto_channel, |
| 183 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 176 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 184 InitParams* params) { | 177 InitParams* params) { |
| 185 DCHECK(params->main_task_runner.get()); | 178 DCHECK(params->main_task_runner.get()); |
| 186 DCHECK(params->settings); | 179 DCHECK(params->settings); |
| 187 DCHECK(remote_proto_channel); | 180 DCHECK(remote_proto_channel); |
| 188 | |
| 189 // Using an external begin frame source is not supported in remote mode. | |
| 190 // TODO(khushalsagar): Add support for providing an external begin frame | |
| 191 // source on the client LayerTreeHostInProcess. crbug/576962 | |
| 192 DCHECK(!params->settings->use_external_begin_frame_source); | |
| 193 DCHECK(!params->external_begin_frame_source); | |
| 194 DCHECK(params->image_serialization_processor); | 181 DCHECK(params->image_serialization_processor); |
| 195 | 182 |
| 196 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( | 183 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
| 197 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); | 184 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); |
| 198 layer_tree_host->InitializeRemoteClient( | 185 layer_tree_host->InitializeRemoteClient( |
| 199 remote_proto_channel, params->main_task_runner, impl_task_runner); | 186 remote_proto_channel, params->main_task_runner, impl_task_runner); |
| 200 return layer_tree_host; | 187 return layer_tree_host; |
| 201 } | 188 } |
| 202 | 189 |
| 203 LayerTreeHostInProcess::LayerTreeHostInProcess(InitParams* params, | 190 LayerTreeHostInProcess::LayerTreeHostInProcess(InitParams* params, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 234 image_serialization_processor_(params->image_serialization_processor) { | 221 image_serialization_processor_(params->image_serialization_processor) { |
| 235 DCHECK(task_graph_runner_); | 222 DCHECK(task_graph_runner_); |
| 236 DCHECK(layer_tree_); | 223 DCHECK(layer_tree_); |
| 237 | 224 |
| 238 rendering_stats_instrumentation_->set_record_rendering_stats( | 225 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 239 debug_state_.RecordRenderingStats()); | 226 debug_state_.RecordRenderingStats()); |
| 240 } | 227 } |
| 241 | 228 |
| 242 void LayerTreeHostInProcess::InitializeThreaded( | 229 void LayerTreeHostInProcess::InitializeThreaded( |
| 243 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 230 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 244 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 231 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 245 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 246 task_runner_provider_ = | 232 task_runner_provider_ = |
| 247 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 233 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| 248 std::unique_ptr<ProxyMain> proxy_main = | 234 std::unique_ptr<ProxyMain> proxy_main = |
| 249 ProxyMain::CreateThreaded(this, task_runner_provider_.get()); | 235 ProxyMain::CreateThreaded(this, task_runner_provider_.get()); |
| 250 InitializeProxy(std::move(proxy_main), | 236 InitializeProxy(std::move(proxy_main)); |
| 251 std::move(external_begin_frame_source)); | |
| 252 } | 237 } |
| 253 | 238 |
| 254 void LayerTreeHostInProcess::InitializeSingleThreaded( | 239 void LayerTreeHostInProcess::InitializeSingleThreaded( |
| 255 LayerTreeHostSingleThreadClient* single_thread_client, | 240 LayerTreeHostSingleThreadClient* single_thread_client, |
| 256 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 241 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { |
| 257 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 258 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | 242 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
| 259 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, | 243 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, |
| 260 task_runner_provider_.get()), | 244 task_runner_provider_.get())); |
| 261 std::move(external_begin_frame_source)); | |
| 262 } | 245 } |
| 263 | 246 |
| 264 void LayerTreeHostInProcess::InitializeRemoteServer( | 247 void LayerTreeHostInProcess::InitializeRemoteServer( |
| 265 RemoteProtoChannel* remote_proto_channel, | 248 RemoteProtoChannel* remote_proto_channel, |
| 266 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 249 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { |
| 267 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | 250 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
| 268 | 251 |
| 269 if (image_serialization_processor_) { | 252 if (image_serialization_processor_) { |
| 270 engine_picture_cache_ = | 253 engine_picture_cache_ = |
| 271 image_serialization_processor_->CreateEnginePictureCache(); | 254 image_serialization_processor_->CreateEnginePictureCache(); |
| 272 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); | 255 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); |
| 273 } | 256 } |
| 274 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, | 257 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, |
| 275 task_runner_provider_.get()), | 258 task_runner_provider_.get())); |
| 276 nullptr); | |
| 277 } | 259 } |
| 278 | 260 |
| 279 void LayerTreeHostInProcess::InitializeRemoteClient( | 261 void LayerTreeHostInProcess::InitializeRemoteClient( |
| 280 RemoteProtoChannel* remote_proto_channel, | 262 RemoteProtoChannel* remote_proto_channel, |
| 281 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 263 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 282 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 264 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 283 task_runner_provider_ = | 265 task_runner_provider_ = |
| 284 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 266 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| 285 | 267 |
| 286 if (image_serialization_processor_) { | 268 if (image_serialization_processor_) { |
| 287 client_picture_cache_ = | 269 client_picture_cache_ = |
| 288 image_serialization_processor_->CreateClientPictureCache(); | 270 image_serialization_processor_->CreateClientPictureCache(); |
| 289 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); | 271 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); |
| 290 } | 272 } |
| 291 | 273 |
| 292 // For the remote mode, the RemoteChannelImpl implements the Proxy, which is | 274 // For the remote mode, the RemoteChannelImpl implements the Proxy, which is |
| 293 // owned by the LayerTreeHostInProcess. The RemoteChannelImpl pipes requests | 275 // owned by the LayerTreeHostInProcess. The RemoteChannelImpl pipes requests |
| 294 // which need to handled locally, for instance the Output Surface creation to | 276 // which need to handled locally, for instance the Output Surface creation to |
| 295 // the LayerTreeHostInProcess on the client, while the other requests are sent | 277 // the LayerTreeHostInProcess on the client, while the other requests are sent |
| 296 // to the RemoteChannelMain on the server which directs them to ProxyMain and | 278 // to the RemoteChannelMain on the server which directs them to ProxyMain and |
| 297 // the remote server LayerTreeHostInProcess. | 279 // the remote server LayerTreeHostInProcess. |
| 298 InitializeProxy(base::MakeUnique<RemoteChannelImpl>( | 280 InitializeProxy(base::MakeUnique<RemoteChannelImpl>( |
| 299 this, remote_proto_channel, task_runner_provider_.get()), | 281 this, remote_proto_channel, task_runner_provider_.get())); |
| 300 nullptr); | |
| 301 } | 282 } |
| 302 | 283 |
| 303 void LayerTreeHostInProcess::InitializeForTesting( | 284 void LayerTreeHostInProcess::InitializeForTesting( |
| 304 std::unique_ptr<TaskRunnerProvider> task_runner_provider, | 285 std::unique_ptr<TaskRunnerProvider> task_runner_provider, |
| 305 std::unique_ptr<Proxy> proxy_for_testing, | 286 std::unique_ptr<Proxy> proxy_for_testing) { |
| 306 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 307 task_runner_provider_ = std::move(task_runner_provider); | 287 task_runner_provider_ = std::move(task_runner_provider); |
| 308 | 288 |
| 309 InitializePictureCacheForTesting(); | 289 InitializePictureCacheForTesting(); |
| 310 | 290 |
| 311 InitializeProxy(std::move(proxy_for_testing), | 291 InitializeProxy(std::move(proxy_for_testing)); |
| 312 std::move(external_begin_frame_source)); | |
| 313 } | 292 } |
| 314 | 293 |
| 315 void LayerTreeHostInProcess::InitializePictureCacheForTesting() { | 294 void LayerTreeHostInProcess::InitializePictureCacheForTesting() { |
| 316 if (!image_serialization_processor_) | 295 if (!image_serialization_processor_) |
| 317 return; | 296 return; |
| 318 | 297 |
| 319 // Initialize both engine and client cache to ensure serialization tests | 298 // Initialize both engine and client cache to ensure serialization tests |
| 320 // with a single LayerTreeHostInProcess can work correctly. | 299 // with a single LayerTreeHostInProcess can work correctly. |
| 321 engine_picture_cache_ = | 300 engine_picture_cache_ = |
| 322 image_serialization_processor_->CreateEnginePictureCache(); | 301 image_serialization_processor_->CreateEnginePictureCache(); |
| 323 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); | 302 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); |
| 324 client_picture_cache_ = | 303 client_picture_cache_ = |
| 325 image_serialization_processor_->CreateClientPictureCache(); | 304 image_serialization_processor_->CreateClientPictureCache(); |
| 326 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); | 305 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); |
| 327 } | 306 } |
| 328 | 307 |
| 329 void LayerTreeHostInProcess::SetTaskRunnerProviderForTesting( | 308 void LayerTreeHostInProcess::SetTaskRunnerProviderForTesting( |
| 330 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { | 309 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { |
| 331 DCHECK(!task_runner_provider_); | 310 DCHECK(!task_runner_provider_); |
| 332 task_runner_provider_ = std::move(task_runner_provider); | 311 task_runner_provider_ = std::move(task_runner_provider); |
| 333 } | 312 } |
| 334 | 313 |
| 335 void LayerTreeHostInProcess::SetUIResourceManagerForTesting( | 314 void LayerTreeHostInProcess::SetUIResourceManagerForTesting( |
| 336 std::unique_ptr<UIResourceManager> ui_resource_manager) { | 315 std::unique_ptr<UIResourceManager> ui_resource_manager) { |
| 337 ui_resource_manager_ = std::move(ui_resource_manager); | 316 ui_resource_manager_ = std::move(ui_resource_manager); |
| 338 } | 317 } |
| 339 | 318 |
| 340 void LayerTreeHostInProcess::InitializeProxy( | 319 void LayerTreeHostInProcess::InitializeProxy(std::unique_ptr<Proxy> proxy) { |
| 341 std::unique_ptr<Proxy> proxy, | |
| 342 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 343 TRACE_EVENT0("cc", "LayerTreeHostInProcess::InitializeForReal"); | 320 TRACE_EVENT0("cc", "LayerTreeHostInProcess::InitializeForReal"); |
| 344 DCHECK(task_runner_provider_); | 321 DCHECK(task_runner_provider_); |
| 345 | 322 |
| 346 proxy_ = std::move(proxy); | 323 proxy_ = std::move(proxy); |
| 347 proxy_->Start(std::move(external_begin_frame_source)); | 324 proxy_->Start(); |
| 348 | 325 |
| 349 layer_tree_->animation_host()->SetSupportsScrollAnimations( | 326 layer_tree_->animation_host()->SetSupportsScrollAnimations( |
| 350 proxy_->SupportsImplScrolling()); | 327 proxy_->SupportsImplScrolling()); |
| 351 } | 328 } |
| 352 | 329 |
| 353 LayerTreeHostInProcess::~LayerTreeHostInProcess() { | 330 LayerTreeHostInProcess::~LayerTreeHostInProcess() { |
| 354 TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess"); | 331 TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess"); |
| 355 | 332 |
| 356 // Clear any references into the LayerTreeHostInProcess. | 333 // Clear any references into the LayerTreeHostInProcess. |
| 357 layer_tree_.reset(); | 334 layer_tree_.reset(); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 | 1027 |
| 1051 debug_state_.FromProtobuf(proto.debug_state()); | 1028 debug_state_.FromProtobuf(proto.debug_state()); |
| 1052 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); | 1029 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); |
| 1053 content_is_suitable_for_gpu_rasterization_ = | 1030 content_is_suitable_for_gpu_rasterization_ = |
| 1054 proto.content_is_suitable_for_gpu_rasterization(); | 1031 proto.content_is_suitable_for_gpu_rasterization(); |
| 1055 id_ = proto.id(); | 1032 id_ = proto.id(); |
| 1056 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | 1033 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
| 1057 } | 1034 } |
| 1058 | 1035 |
| 1059 } // namespace cc | 1036 } // namespace cc |
| OLD | NEW |