| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/gpu/gpu_service.h" | 5 #include "services/ui/gpu/gpu_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 // Signal this event before destroying the child process. That way all | 65 // Signal this event before destroying the child process. That way all |
| 66 // background threads can cleanup. | 66 // background threads can cleanup. |
| 67 // For example, in the renderer the RenderThread instances will be able to | 67 // For example, in the renderer the RenderThread instances will be able to |
| 68 // notice shutdown before the render process begins waiting for them to exit. | 68 // notice shutdown before the render process begins waiting for them to exit. |
| 69 shutdown_event_.Signal(); | 69 shutdown_event_.Signal(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void GpuService::InitializeWithHost(mojom::GpuHostPtr gpu_host, | 72 void GpuService::InitializeWithHost(mojom::GpuHostPtr gpu_host, |
| 73 const gpu::GpuPreferences& preferences, | 73 const gpu::GpuPreferences& preferences, |
| 74 gpu::GpuProcessActivityFlags activity_flags, |
| 74 gpu::SyncPointManager* sync_point_manager, | 75 gpu::SyncPointManager* sync_point_manager, |
| 75 base::WaitableEvent* shutdown_event) { | 76 base::WaitableEvent* shutdown_event) { |
| 76 DCHECK(CalledOnValidThread()); | 77 DCHECK(CalledOnValidThread()); |
| 77 DCHECK(!gpu_host_); | 78 DCHECK(!gpu_host_); |
| 78 gpu_host_ = std::move(gpu_host); | 79 gpu_host_ = std::move(gpu_host); |
| 79 gpu_preferences_ = preferences; | 80 gpu_preferences_ = preferences; |
| 80 gpu_info_.video_decode_accelerator_capabilities = | 81 gpu_info_.video_decode_accelerator_capabilities = |
| 81 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); | 82 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); |
| 82 gpu_info_.video_encode_accelerator_supported_profiles = | 83 gpu_info_.video_encode_accelerator_supported_profiles = |
| 83 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_); | 84 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_); |
| 84 gpu_info_.jpeg_decode_accelerator_supported = | 85 gpu_info_.jpeg_decode_accelerator_supported = |
| 85 media::GpuJpegDecodeAcceleratorFactoryProvider:: | 86 media::GpuJpegDecodeAcceleratorFactoryProvider:: |
| 86 IsAcceleratedJpegDecodeSupported(); | 87 IsAcceleratedJpegDecodeSupported(); |
| 87 gpu_host_->DidInitialize(gpu_info_); | 88 gpu_host_->DidInitialize(gpu_info_); |
| 88 | 89 |
| 89 sync_point_manager_ = sync_point_manager; | 90 sync_point_manager_ = sync_point_manager; |
| 90 if (!sync_point_manager_) { | 91 if (!sync_point_manager_) { |
| 91 owned_sync_point_manager_ = base::MakeUnique<gpu::SyncPointManager>(); | 92 owned_sync_point_manager_ = base::MakeUnique<gpu::SyncPointManager>(); |
| 92 sync_point_manager_ = owned_sync_point_manager_.get(); | 93 sync_point_manager_ = owned_sync_point_manager_.get(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 // Defer creation of the render thread. This is to prevent it from handling | 96 // Defer creation of the render thread. This is to prevent it from handling |
| 96 // IPC messages before the sandbox has been enabled and all other necessary | 97 // IPC messages before the sandbox has been enabled and all other necessary |
| 97 // initialization has succeeded. | 98 // initialization has succeeded. |
| 98 gpu_channel_manager_.reset(new gpu::GpuChannelManager( | 99 gpu_channel_manager_.reset(new gpu::GpuChannelManager( |
| 99 gpu_preferences_, this, watchdog_thread_.get(), | 100 gpu_preferences_, this, watchdog_thread_.get(), |
| 100 base::ThreadTaskRunnerHandle::Get().get(), io_runner_.get(), | 101 base::ThreadTaskRunnerHandle::Get().get(), io_runner_.get(), |
| 101 shutdown_event ? shutdown_event : &shutdown_event_, sync_point_manager_, | 102 shutdown_event ? shutdown_event : &shutdown_event_, sync_point_manager_, |
| 102 gpu_memory_buffer_factory_, gpu_feature_info_)); | 103 gpu_memory_buffer_factory_, gpu_feature_info_, |
| 104 std::move(activity_flags))); |
| 103 | 105 |
| 104 media_gpu_channel_manager_.reset( | 106 media_gpu_channel_manager_.reset( |
| 105 new media::MediaGpuChannelManager(gpu_channel_manager_.get())); | 107 new media::MediaGpuChannelManager(gpu_channel_manager_.get())); |
| 106 } | 108 } |
| 107 | 109 |
| 108 void GpuService::Bind(mojom::GpuServiceRequest request) { | 110 void GpuService::Bind(mojom::GpuServiceRequest request) { |
| 109 bindings_.AddBinding(this, std::move(request)); | 111 bindings_.AddBinding(this, std::move(request)); |
| 110 } | 112 } |
| 111 | 113 |
| 112 void GpuService::CreateGpuMemoryBuffer( | 114 void GpuService::CreateGpuMemoryBuffer( |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 261 |
| 260 void GpuService::ThrowJavaException() { | 262 void GpuService::ThrowJavaException() { |
| 261 #if defined(OS_ANDROID) | 263 #if defined(OS_ANDROID) |
| 262 base::android::ThrowUncaughtException(); | 264 base::android::ThrowUncaughtException(); |
| 263 #else | 265 #else |
| 264 NOTREACHED() << "Java exception not supported on this platform."; | 266 NOTREACHED() << "Java exception not supported on this platform."; |
| 265 #endif | 267 #endif |
| 266 } | 268 } |
| 267 | 269 |
| 268 } // namespace ui | 270 } // namespace ui |
| OLD | NEW |