Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "gpu/config/gpu_switches.h" | 29 #include "gpu/config/gpu_switches.h" |
| 30 #include "gpu/config/gpu_util.h" | 30 #include "gpu/config/gpu_util.h" |
| 31 #include "gpu/ipc/common/memory_stats.h" | 31 #include "gpu/ipc/common/memory_stats.h" |
| 32 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 32 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
| 33 #include "ipc/ipc_channel_handle.h" | 33 #include "ipc/ipc_channel_handle.h" |
| 34 #include "ipc/ipc_sync_message_filter.h" | 34 #include "ipc/ipc_sync_message_filter.h" |
| 35 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" | 35 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" |
| 36 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" | 36 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" |
| 37 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" | 37 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" |
| 38 #include "media/gpu/ipc/service/media_service.h" | 38 #include "media/gpu/ipc/service/media_service.h" |
| 39 #include "services/shell/public/cpp/interface_registry.h" | |
| 39 #include "ui/gl/gl_implementation.h" | 40 #include "ui/gl/gl_implementation.h" |
| 40 #include "ui/gl/gl_switches.h" | 41 #include "ui/gl/gl_switches.h" |
| 41 #include "ui/gl/gpu_switching_manager.h" | 42 #include "ui/gl/gpu_switching_manager.h" |
| 42 #include "ui/gl/init/gl_factory.h" | 43 #include "ui/gl/init/gl_factory.h" |
| 43 #include "url/gurl.h" | 44 #include "url/gurl.h" |
| 44 | 45 |
| 45 #if defined(USE_OZONE) | 46 #if defined(USE_OZONE) |
| 46 #include "ui/ozone/public/gpu_platform_support.h" | 47 #include "ui/ozone/public/gpu_platform_support.h" |
| 47 #include "ui/ozone/public/ozone_platform.h" | 48 #include "ui/ozone/public/ozone_platform.h" |
| 48 #endif | 49 #endif |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 #if defined(OS_ANDROID) | 215 #if defined(OS_ANDROID) |
| 215 // When running in in-process mode, this has been set in the browser at | 216 // When running in in-process mode, this has been set in the browser at |
| 216 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). | 217 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). |
| 217 if (!in_browser_process_) | 218 if (!in_browser_process_) |
| 218 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); | 219 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); |
| 219 #endif | 220 #endif |
| 220 | 221 |
| 221 // Only set once per process instance. | 222 // Only set once per process instance. |
| 222 process_control_.reset(new GpuProcessControlImpl()); | 223 process_control_.reset(new GpuProcessControlImpl()); |
| 223 | 224 |
| 225 // Use of base::Unretained(this) is safe here because |service_registry()| | |
|
Ben Goodger (Google)
2016/07/03 03:29:27
This seems worse than before - given that you don'
Ken Rockot(use gerrit already)
2016/07/04 18:22:58
Right, so it's not really worse in practice since
| |
| 226 // will be destroyed before GpuChildThread is destructed. | |
| 227 GetInterfaceRegistry()->AddInterface(base::Bind( | |
| 228 &GpuChildThread::BindProcessControlRequest, base::Unretained(this))); | |
| 229 | |
| 230 if (GetContentClient()->gpu()) { // NULL in tests. | |
| 231 GetContentClient()->gpu()->ExposeInterfacesToBrowser( | |
| 232 GetInterfaceRegistry()); | |
| 233 } | |
| 234 | |
| 235 // We don't want to process any incoming interface requests until | |
| 236 // OnInitialize() is invoked. | |
| 237 GetInterfaceRegistry()->PauseBinding(); | |
| 238 | |
| 224 if (GetContentClient()->gpu()) // NULL in tests. | 239 if (GetContentClient()->gpu()) // NULL in tests. |
| 225 GetContentClient()->gpu()->Initialize(this); | 240 GetContentClient()->gpu()->Initialize(this); |
| 226 } | 241 } |
| 227 | 242 |
| 228 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, | 243 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 229 const std::string& group_name) { | 244 const std::string& group_name) { |
| 230 Send(new GpuHostMsg_FieldTrialActivated(trial_name)); | 245 Send(new GpuHostMsg_FieldTrialActivated(trial_name)); |
| 231 } | 246 } |
| 232 | 247 |
| 233 bool GpuChildThread::Send(IPC::Message* msg) { | 248 bool GpuChildThread::Send(IPC::Message* msg) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 OnDestroyingVideoSurface); | 298 OnDestroyingVideoSurface); |
| 284 #endif | 299 #endif |
| 285 IPC_MESSAGE_UNHANDLED(handled = false) | 300 IPC_MESSAGE_UNHANDLED(handled = false) |
| 286 IPC_END_MESSAGE_MAP() | 301 IPC_END_MESSAGE_MAP() |
| 287 if (handled) | 302 if (handled) |
| 288 return true; | 303 return true; |
| 289 | 304 |
| 290 return false; | 305 return false; |
| 291 } | 306 } |
| 292 | 307 |
| 293 bool GpuChildThread::AcceptConnection(shell::Connection* connection) { | |
| 294 // Use of base::Unretained(this) is safe here because |service_registry()| | |
| 295 // will be destroyed before GpuChildThread is destructed. | |
| 296 connection->GetInterfaceRegistry()->AddInterface(base::Bind( | |
| 297 &GpuChildThread::BindProcessControlRequest, base::Unretained(this))); | |
| 298 | |
| 299 if (GetContentClient()->gpu()) { // NULL in tests. | |
| 300 GetContentClient()->gpu()->ExposeInterfacesToBrowser( | |
| 301 connection->GetInterfaceRegistry()); | |
| 302 } | |
| 303 | |
| 304 // We don't want to process any incoming interface requests until | |
| 305 // OnInitialize(). | |
| 306 if (!gpu_channel_manager_) { | |
| 307 connection->GetInterfaceRegistry()->PauseBinding(); | |
| 308 resume_interface_bindings_callback_ = base::Bind( | |
| 309 &shell::InterfaceRegistry::ResumeBinding, | |
| 310 connection->GetInterfaceRegistry()->GetWeakPtr()); | |
| 311 } | |
| 312 | |
| 313 return true; | |
| 314 } | |
| 315 | |
| 316 shell::InterfaceRegistry* GpuChildThread::GetInterfaceRegistryForConnection() { | |
| 317 return nullptr; | |
| 318 } | |
| 319 | |
| 320 shell::InterfaceProvider* GpuChildThread::GetInterfaceProviderForConnection() { | |
| 321 return nullptr; | |
| 322 } | |
| 323 | |
| 324 void GpuChildThread::SetActiveURL(const GURL& url) { | 308 void GpuChildThread::SetActiveURL(const GURL& url) { |
| 325 GetContentClient()->SetActiveURL(url); | 309 GetContentClient()->SetActiveURL(url); |
| 326 } | 310 } |
| 327 | 311 |
| 328 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { | 312 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { |
| 329 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); | 313 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); |
| 330 } | 314 } |
| 331 | 315 |
| 332 void GpuChildThread::DidDestroyChannel(int client_id) { | 316 void GpuChildThread::DidDestroyChannel(int client_id) { |
| 333 media_service_->RemoveChannel(client_id); | 317 media_service_->RemoveChannel(client_id); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 357 } | 341 } |
| 358 #endif | 342 #endif |
| 359 | 343 |
| 360 void GpuChildThread::StoreShaderToDisk(int32_t client_id, | 344 void GpuChildThread::StoreShaderToDisk(int32_t client_id, |
| 361 const std::string& key, | 345 const std::string& key, |
| 362 const std::string& shader) { | 346 const std::string& shader) { |
| 363 Send(new GpuHostMsg_CacheShader(client_id, key, shader)); | 347 Send(new GpuHostMsg_CacheShader(client_id, key, shader)); |
| 364 } | 348 } |
| 365 | 349 |
| 366 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) { | 350 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) { |
| 367 if (!resume_interface_bindings_callback_.is_null()) | 351 GetInterfaceRegistry()->ResumeBinding(); |
| 368 base::ResetAndReturn(&resume_interface_bindings_callback_).Run(); | |
| 369 | 352 |
| 370 gpu_preferences_ = gpu_preferences; | 353 gpu_preferences_ = gpu_preferences; |
| 371 | 354 |
| 372 gpu_info_.video_decode_accelerator_capabilities = | 355 gpu_info_.video_decode_accelerator_capabilities = |
| 373 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); | 356 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); |
| 374 gpu_info_.video_encode_accelerator_supported_profiles = | 357 gpu_info_.video_encode_accelerator_supported_profiles = |
| 375 media::GpuVideoEncodeAccelerator::GetSupportedProfiles( | 358 media::GpuVideoEncodeAccelerator::GetSupportedProfiles( |
| 376 gpu_preferences_); | 359 gpu_preferences_); |
| 377 gpu_info_.jpeg_decode_accelerator_supported = | 360 gpu_info_.jpeg_decode_accelerator_supported = |
| 378 media::GpuJpegDecodeAccelerator::IsSupported(); | 361 media::GpuJpegDecodeAccelerator::IsSupported(); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 | 568 |
| 586 void GpuChildThread::BindProcessControlRequest( | 569 void GpuChildThread::BindProcessControlRequest( |
| 587 mojo::InterfaceRequest<mojom::ProcessControl> request) { | 570 mojo::InterfaceRequest<mojom::ProcessControl> request) { |
| 588 DVLOG(1) << "GPU: Binding ProcessControl request"; | 571 DVLOG(1) << "GPU: Binding ProcessControl request"; |
| 589 DCHECK(process_control_); | 572 DCHECK(process_control_); |
| 590 process_control_bindings_.AddBinding(process_control_.get(), | 573 process_control_bindings_.AddBinding(process_control_.get(), |
| 591 std::move(request)); | 574 std::move(request)); |
| 592 } | 575 } |
| 593 | 576 |
| 594 } // namespace content | 577 } // namespace content |
| OLD | NEW |