| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 remote_proto_channel_receiver_(nullptr), | 234 remote_proto_channel_receiver_(nullptr), |
| 235 weak_factory_(this) {} | 235 weak_factory_(this) {} |
| 236 | 236 |
| 237 void RenderWidgetCompositor::Initialize(float device_scale_factor) { | 237 void RenderWidgetCompositor::Initialize(float device_scale_factor) { |
| 238 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 238 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 239 cc::LayerTreeSettings settings = | 239 cc::LayerTreeSettings settings = |
| 240 GenerateLayerTreeSettings(*cmd, compositor_deps_, device_scale_factor); | 240 GenerateLayerTreeSettings(*cmd, compositor_deps_, device_scale_factor); |
| 241 | 241 |
| 242 animation_host_ = cc::AnimationHost::CreateMainInstance(); | 242 animation_host_ = cc::AnimationHost::CreateMainInstance(); |
| 243 | 243 |
| 244 if (cmd->HasSwitch(switches::kUseRemoteCompositing) && | 244 if (cmd->HasSwitch(switches::kUseRemoteCompositing)) { |
| 245 cmd->HasSwitch(switches::kUseLayerTreeHostRemote)) { | |
| 246 DCHECK(!threaded_); | 245 DCHECK(!threaded_); |
| 247 | 246 |
| 248 cc::LayerTreeHostRemote::InitParams params; | 247 cc::LayerTreeHostRemote::InitParams params; |
| 249 params.client = this; | 248 params.client = this; |
| 250 params.main_task_runner = | 249 params.main_task_runner = |
| 251 compositor_deps_->GetCompositorMainThreadTaskRunner(); | 250 compositor_deps_->GetCompositorMainThreadTaskRunner(); |
| 252 params.mutator_host = animation_host_.get(); | 251 params.mutator_host = animation_host_.get(); |
| 253 params.remote_compositor_bridge = | 252 params.remote_compositor_bridge = |
| 254 GetContentClient()->renderer()->CreateRemoteCompositorBridge( | 253 GetContentClient()->renderer()->CreateRemoteCompositorBridge( |
| 255 this, params.main_task_runner); | 254 this, params.main_task_runner); |
| 256 params.engine_picture_cache = | 255 params.engine_picture_cache = |
| 257 compositor_deps_->GetImageSerializationProcessor() | 256 compositor_deps_->GetImageSerializationProcessor() |
| 258 ->CreateEnginePictureCache(); | 257 ->CreateEnginePictureCache(); |
| 259 params.settings = &settings; | 258 params.settings = &settings; |
| 260 layer_tree_host_ = base::MakeUnique<cc::LayerTreeHostRemote>(¶ms); | 259 layer_tree_host_ = base::MakeUnique<cc::LayerTreeHostRemote>(¶ms); |
| 261 return; | 260 } else { |
| 261 cc::LayerTreeHostInProcess::InitParams params; |
| 262 params.client = this; |
| 263 params.settings = &settings; |
| 264 params.task_graph_runner = compositor_deps_->GetTaskGraphRunner(); |
| 265 params.main_task_runner = |
| 266 compositor_deps_->GetCompositorMainThreadTaskRunner(); |
| 267 params.mutator_host = animation_host_.get(); |
| 268 if (!threaded_) { |
| 269 // Single-threaded layout tests. |
| 270 layer_tree_host_ = |
| 271 cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); |
| 272 } else { |
| 273 layer_tree_host_ = cc::LayerTreeHostInProcess::CreateThreaded( |
| 274 compositor_deps_->GetCompositorImplThreadTaskRunner(), ¶ms); |
| 275 } |
| 262 } | 276 } |
| 263 | 277 |
| 264 cc::LayerTreeHostInProcess::InitParams params; | |
| 265 params.client = this; | |
| 266 params.settings = &settings; | |
| 267 params.task_graph_runner = compositor_deps_->GetTaskGraphRunner(); | |
| 268 params.main_task_runner = | |
| 269 compositor_deps_->GetCompositorMainThreadTaskRunner(); | |
| 270 params.mutator_host = animation_host_.get(); | |
| 271 | |
| 272 if (cmd->HasSwitch(switches::kUseRemoteCompositing)) { | |
| 273 DCHECK(!threaded_); | |
| 274 params.image_serialization_processor = | |
| 275 compositor_deps_->GetImageSerializationProcessor(); | |
| 276 layer_tree_host_ = | |
| 277 cc::LayerTreeHostInProcess::CreateRemoteServer(this, ¶ms); | |
| 278 } else if (!threaded_) { | |
| 279 // Single-threaded layout tests. | |
| 280 layer_tree_host_ = | |
| 281 cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); | |
| 282 } else { | |
| 283 layer_tree_host_ = cc::LayerTreeHostInProcess::CreateThreaded( | |
| 284 compositor_deps_->GetCompositorImplThreadTaskRunner(), ¶ms); | |
| 285 } | |
| 286 DCHECK(layer_tree_host_); | 278 DCHECK(layer_tree_host_); |
| 287 } | 279 } |
| 288 | 280 |
| 289 RenderWidgetCompositor::~RenderWidgetCompositor() = default; | 281 RenderWidgetCompositor::~RenderWidgetCompositor() = default; |
| 290 | 282 |
| 291 // static | 283 // static |
| 292 cc::LayerTreeSettings RenderWidgetCompositor::GenerateLayerTreeSettings( | 284 cc::LayerTreeSettings RenderWidgetCompositor::GenerateLayerTreeSettings( |
| 293 const base::CommandLine& cmd, | 285 const base::CommandLine& cmd, |
| 294 CompositorDependencies* compositor_deps, | 286 CompositorDependencies* compositor_deps, |
| 295 float device_scale_factor) { | 287 float device_scale_factor) { |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 float device_scale) { | 1141 float device_scale) { |
| 1150 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); | 1142 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
| 1151 } | 1143 } |
| 1152 | 1144 |
| 1153 void RenderWidgetCompositor::SetDeviceColorSpace( | 1145 void RenderWidgetCompositor::SetDeviceColorSpace( |
| 1154 const gfx::ColorSpace& color_space) { | 1146 const gfx::ColorSpace& color_space) { |
| 1155 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); | 1147 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); |
| 1156 } | 1148 } |
| 1157 | 1149 |
| 1158 } // namespace content | 1150 } // namespace content |
| OLD | NEW |