| 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" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
| 14 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "content/child/child_process.h" | 16 #include "content/child/child_process.h" |
| 17 #include "content/child/thread_safe_sender.h" | 17 #include "content/child/thread_safe_sender.h" |
| 18 #include "content/common/establish_channel_params.h" | 18 #include "content/common/establish_channel_params.h" |
| 19 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" | |
| 20 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | |
| 21 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | |
| 22 #include "content/common/gpu/media/media_service.h" | |
| 23 #include "content/common/gpu_host_messages.h" | 19 #include "content/common/gpu_host_messages.h" |
| 24 #include "content/gpu/gpu_process_control_impl.h" | 20 #include "content/gpu/gpu_process_control_impl.h" |
| 25 #include "content/gpu/gpu_watchdog_thread.h" | 21 #include "content/gpu/gpu_watchdog_thread.h" |
| 26 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
| 27 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/gpu/content_gpu_client.h" | 24 #include "content/public/gpu/content_gpu_client.h" |
| 29 #include "gpu/command_buffer/service/gpu_switches.h" | 25 #include "gpu/command_buffer/service/gpu_switches.h" |
| 30 #include "gpu/command_buffer/service/sync_point_manager.h" | 26 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 31 #include "gpu/config/gpu_info_collector.h" | 27 #include "gpu/config/gpu_info_collector.h" |
| 32 #include "gpu/config/gpu_switches.h" | 28 #include "gpu/config/gpu_switches.h" |
| 33 #include "gpu/config/gpu_util.h" | 29 #include "gpu/config/gpu_util.h" |
| 34 #include "gpu/ipc/common/memory_stats.h" | 30 #include "gpu/ipc/common/memory_stats.h" |
| 35 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 31 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
| 36 #include "ipc/ipc_channel_handle.h" | 32 #include "ipc/ipc_channel_handle.h" |
| 37 #include "ipc/ipc_sync_message_filter.h" | 33 #include "ipc/ipc_sync_message_filter.h" |
| 34 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" |
| 35 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" |
| 36 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" |
| 37 #include "media/gpu/ipc/service/media_service.h" |
| 38 #include "ui/gl/gl_implementation.h" | 38 #include "ui/gl/gl_implementation.h" |
| 39 #include "ui/gl/gl_switches.h" | 39 #include "ui/gl/gl_switches.h" |
| 40 #include "ui/gl/gpu_switching_manager.h" | 40 #include "ui/gl/gpu_switching_manager.h" |
| 41 #include "url/gurl.h" | 41 #include "url/gurl.h" |
| 42 | 42 |
| 43 #if defined(USE_OZONE) | 43 #if defined(USE_OZONE) |
| 44 #include "ui/ozone/public/gpu_platform_support.h" | 44 #include "ui/ozone/public/gpu_platform_support.h" |
| 45 #include "ui/ozone/public/ozone_platform.h" | 45 #include "ui/ozone/public/ozone_platform.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
| 49 #include "content/common/gpu/media/avda_surface_tracker.h" | 49 #include "media/gpu/avda_surface_tracker.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 namespace content { | 52 namespace content { |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 base::LazyInstance<base::ThreadLocalPointer<GpuChildThread>> g_lazy_tls = | 55 base::LazyInstance<base::ThreadLocalPointer<GpuChildThread>> g_lazy_tls = |
| 56 LAZY_INSTANCE_INITIALIZER; | 56 LAZY_INSTANCE_INITIALIZER; |
| 57 | 57 |
| 58 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 58 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
| 59 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; | 59 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 void GpuChildThread::StoreShaderToDisk(int32_t client_id, | 360 void GpuChildThread::StoreShaderToDisk(int32_t client_id, |
| 361 const std::string& key, | 361 const std::string& key, |
| 362 const std::string& shader) { | 362 const std::string& shader) { |
| 363 Send(new GpuHostMsg_CacheShader(client_id, key, shader)); | 363 Send(new GpuHostMsg_CacheShader(client_id, key, shader)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) { | 366 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) { |
| 367 gpu_preferences_ = gpu_preferences; | 367 gpu_preferences_ = gpu_preferences; |
| 368 | 368 |
| 369 gpu_info_.video_decode_accelerator_capabilities = | 369 gpu_info_.video_decode_accelerator_capabilities = |
| 370 content::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); | 370 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); |
| 371 gpu_info_.video_encode_accelerator_supported_profiles = | 371 gpu_info_.video_encode_accelerator_supported_profiles = |
| 372 content::GpuVideoEncodeAccelerator::GetSupportedProfiles( | 372 media::GpuVideoEncodeAccelerator::GetSupportedProfiles( |
| 373 gpu_preferences_); | 373 gpu_preferences_); |
| 374 gpu_info_.jpeg_decode_accelerator_supported = | 374 gpu_info_.jpeg_decode_accelerator_supported = |
| 375 content::GpuJpegDecodeAccelerator::IsSupported(); | 375 media::GpuJpegDecodeAccelerator::IsSupported(); |
| 376 | 376 |
| 377 // Record initialization only after collecting the GPU info because that can | 377 // Record initialization only after collecting the GPU info because that can |
| 378 // take a significant amount of time. | 378 // take a significant amount of time. |
| 379 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 379 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
| 380 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); | 380 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); |
| 381 while (!deferred_messages_.empty()) { | 381 while (!deferred_messages_.empty()) { |
| 382 Send(deferred_messages_.front()); | 382 Send(deferred_messages_.front()); |
| 383 deferred_messages_.pop(); | 383 deferred_messages_.pop(); |
| 384 } | 384 } |
| 385 | 385 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 408 // Defer creation of the render thread. This is to prevent it from handling | 408 // Defer creation of the render thread. This is to prevent it from handling |
| 409 // IPC messages before the sandbox has been enabled and all other necessary | 409 // IPC messages before the sandbox has been enabled and all other necessary |
| 410 // initialization has succeeded. | 410 // initialization has succeeded. |
| 411 gpu_channel_manager_.reset( | 411 gpu_channel_manager_.reset( |
| 412 new gpu::GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(), | 412 new gpu::GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(), |
| 413 base::ThreadTaskRunnerHandle::Get().get(), | 413 base::ThreadTaskRunnerHandle::Get().get(), |
| 414 ChildProcess::current()->io_task_runner(), | 414 ChildProcess::current()->io_task_runner(), |
| 415 ChildProcess::current()->GetShutDownEvent(), | 415 ChildProcess::current()->GetShutDownEvent(), |
| 416 sync_point_manager, gpu_memory_buffer_factory_)); | 416 sync_point_manager, gpu_memory_buffer_factory_)); |
| 417 | 417 |
| 418 media_service_.reset(new MediaService(gpu_channel_manager_.get())); | 418 media_service_.reset(new media::MediaService(gpu_channel_manager_.get())); |
| 419 | 419 |
| 420 #if defined(USE_OZONE) | 420 #if defined(USE_OZONE) |
| 421 ui::OzonePlatform::GetInstance() | 421 ui::OzonePlatform::GetInstance() |
| 422 ->GetGpuPlatformSupport() | 422 ->GetGpuPlatformSupport() |
| 423 ->OnChannelEstablished(this); | 423 ->OnChannelEstablished(this); |
| 424 #endif | 424 #endif |
| 425 } | 425 } |
| 426 | 426 |
| 427 void GpuChildThread::OnFinalize() { | 427 void GpuChildThread::OnFinalize() { |
| 428 // Quit the GPU process | 428 // Quit the GPU process |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); | 566 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); |
| 567 } | 567 } |
| 568 | 568 |
| 569 #if defined(OS_ANDROID) | 569 #if defined(OS_ANDROID) |
| 570 void GpuChildThread::OnWakeUpGpu() { | 570 void GpuChildThread::OnWakeUpGpu() { |
| 571 if (gpu_channel_manager_) | 571 if (gpu_channel_manager_) |
| 572 gpu_channel_manager_->WakeUpGpu(); | 572 gpu_channel_manager_->WakeUpGpu(); |
| 573 } | 573 } |
| 574 | 574 |
| 575 void GpuChildThread::OnDestroyingVideoSurface(int surface_id) { | 575 void GpuChildThread::OnDestroyingVideoSurface(int surface_id) { |
| 576 AVDASurfaceTracker::GetInstance()->NotifyDestroyingSurface(surface_id); | 576 media::AVDASurfaceTracker::GetInstance()->NotifyDestroyingSurface(surface_id); |
| 577 Send(new GpuHostMsg_DestroyingVideoSurfaceAck(surface_id)); | 577 Send(new GpuHostMsg_DestroyingVideoSurfaceAck(surface_id)); |
| 578 } | 578 } |
| 579 #endif | 579 #endif |
| 580 | 580 |
| 581 void GpuChildThread::OnLoseAllContexts() { | 581 void GpuChildThread::OnLoseAllContexts() { |
| 582 if (gpu_channel_manager_) { | 582 if (gpu_channel_manager_) { |
| 583 gpu_channel_manager_->DestroyAllChannels(); | 583 gpu_channel_manager_->DestroyAllChannels(); |
| 584 media_service_->DestroyAllChannels(); | 584 media_service_->DestroyAllChannels(); |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 | 587 |
| 588 void GpuChildThread::BindProcessControlRequest( | 588 void GpuChildThread::BindProcessControlRequest( |
| 589 mojo::InterfaceRequest<mojom::ProcessControl> request) { | 589 mojo::InterfaceRequest<mojom::ProcessControl> request) { |
| 590 DVLOG(1) << "GPU: Binding ProcessControl request"; | 590 DVLOG(1) << "GPU: Binding ProcessControl request"; |
| 591 DCHECK(process_control_); | 591 DCHECK(process_control_); |
| 592 process_control_bindings_.AddBinding(process_control_.get(), | 592 process_control_bindings_.AddBinding(process_control_.get(), |
| 593 std::move(request)); | 593 std::move(request)); |
| 594 } | 594 } |
| 595 | 595 |
| 596 } // namespace content | 596 } // namespace content |
| OLD | NEW |