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" | 19 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" |
20 #include "content/common/gpu/media/gpu_video_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" | 21 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
22 #include "content/common/gpu/media/media_service.h" | 22 #include "content/common/gpu/media/media_service.h" |
23 #include "content/common/gpu_host_messages.h" | 23 #include "content/common/gpu_host_messages.h" |
24 #include "content/gpu/gpu_process_control_impl.h" | 24 #include "content/gpu/gpu_process_control_impl.h" |
25 #include "content/gpu/gpu_watchdog_thread.h" | 25 #include "content/gpu/gpu_watchdog_thread.h" |
26 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
28 #include "content/public/gpu/content_gpu_client.h" | 28 #include "content/public/gpu/content_gpu_client.h" |
29 #include "gpu/command_buffer/service/gpu_switches.h" | 29 #include "gpu/command_buffer/service/gpu_switches.h" |
| 30 #include "gpu/command_buffer/service/sync_point_manager.h" |
30 #include "gpu/config/gpu_info_collector.h" | 31 #include "gpu/config/gpu_info_collector.h" |
31 #include "gpu/config/gpu_switches.h" | 32 #include "gpu/config/gpu_switches.h" |
32 #include "gpu/config/gpu_util.h" | 33 #include "gpu/config/gpu_util.h" |
33 #include "gpu/ipc/common/memory_stats.h" | 34 #include "gpu/ipc/common/memory_stats.h" |
34 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 35 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
35 #include "ipc/ipc_channel_handle.h" | 36 #include "ipc/ipc_channel_handle.h" |
36 #include "ipc/ipc_sync_message_filter.h" | 37 #include "ipc/ipc_sync_message_filter.h" |
37 #include "ui/gl/gl_implementation.h" | 38 #include "ui/gl/gl_implementation.h" |
38 #include "ui/gl/gl_switches.h" | 39 #include "ui/gl/gl_switches.h" |
39 #include "ui/gl/gpu_switching_manager.h" | 40 #include "ui/gl/gpu_switching_manager.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // static | 152 // static |
152 GpuChildThread* GpuChildThread::current() { | 153 GpuChildThread* GpuChildThread::current() { |
153 return g_lazy_tls.Pointer()->Get(); | 154 return g_lazy_tls.Pointer()->Get(); |
154 } | 155 } |
155 | 156 |
156 GpuChildThread::GpuChildThread( | 157 GpuChildThread::GpuChildThread( |
157 GpuWatchdogThread* watchdog_thread, | 158 GpuWatchdogThread* watchdog_thread, |
158 bool dead_on_arrival, | 159 bool dead_on_arrival, |
159 const gpu::GPUInfo& gpu_info, | 160 const gpu::GPUInfo& gpu_info, |
160 const DeferredMessages& deferred_messages, | 161 const DeferredMessages& deferred_messages, |
161 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory, | 162 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
162 gpu::SyncPointManager* sync_point_manager) | |
163 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), | 163 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), |
164 dead_on_arrival_(dead_on_arrival), | 164 dead_on_arrival_(dead_on_arrival), |
165 sync_point_manager_(sync_point_manager), | |
166 gpu_info_(gpu_info), | 165 gpu_info_(gpu_info), |
167 deferred_messages_(deferred_messages), | 166 deferred_messages_(deferred_messages), |
168 in_browser_process_(false), | 167 in_browser_process_(false), |
169 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { | 168 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { |
170 watchdog_thread_ = watchdog_thread; | 169 watchdog_thread_ = watchdog_thread; |
171 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
172 target_services_ = NULL; | 171 target_services_ = NULL; |
173 #endif | 172 #endif |
174 g_thread_safe_sender.Get() = thread_safe_sender(); | 173 g_thread_safe_sender.Get() = thread_safe_sender(); |
175 g_lazy_tls.Pointer()->Set(this); | 174 g_lazy_tls.Pointer()->Set(this); |
176 } | 175 } |
177 | 176 |
178 GpuChildThread::GpuChildThread( | 177 GpuChildThread::GpuChildThread( |
179 const gpu::GpuPreferences& gpu_preferences, | 178 const gpu::GpuPreferences& gpu_preferences, |
180 const InProcessChildThreadParams& params, | 179 const InProcessChildThreadParams& params, |
181 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory, | 180 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
182 gpu::SyncPointManager* sync_point_manager) | |
183 : ChildThreadImpl(ChildThreadImpl::Options::Builder() | 181 : ChildThreadImpl(ChildThreadImpl::Options::Builder() |
184 .InBrowserProcess(params) | 182 .InBrowserProcess(params) |
185 .AddStartupFilter(new GpuMemoryBufferMessageFilter( | 183 .AddStartupFilter(new GpuMemoryBufferMessageFilter( |
186 gpu_memory_buffer_factory)) | 184 gpu_memory_buffer_factory)) |
187 .Build()), | 185 .Build()), |
188 gpu_preferences_(gpu_preferences), | 186 gpu_preferences_(gpu_preferences), |
189 dead_on_arrival_(false), | 187 dead_on_arrival_(false), |
190 sync_point_manager_(sync_point_manager), | |
191 in_browser_process_(true), | 188 in_browser_process_(true), |
192 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { | 189 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { |
193 #if defined(OS_WIN) | 190 #if defined(OS_WIN) |
194 target_services_ = NULL; | 191 target_services_ = NULL; |
195 #endif | 192 #endif |
196 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 193 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
197 switches::kSingleProcess) || | 194 switches::kSingleProcess) || |
198 base::CommandLine::ForCurrentProcess()->HasSwitch( | 195 base::CommandLine::ForCurrentProcess()->HasSwitch( |
199 switches::kInProcessGPU)); | 196 switches::kInProcessGPU)); |
200 | 197 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; | 385 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; |
389 base::MessageLoop::current()->QuitWhenIdle(); | 386 base::MessageLoop::current()->QuitWhenIdle(); |
390 return; | 387 return; |
391 } | 388 } |
392 | 389 |
393 // We don't need to pipe log messages if we are running the GPU thread in | 390 // We don't need to pipe log messages if we are running the GPU thread in |
394 // the browser process. | 391 // the browser process. |
395 if (!in_browser_process_) | 392 if (!in_browser_process_) |
396 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 393 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
397 | 394 |
| 395 gpu::SyncPointManager* sync_point_manager = nullptr; |
| 396 // Note SyncPointManager from ContentGpuClient cannot be owned by this. |
| 397 if (GetContentClient()->gpu()) |
| 398 sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager(); |
| 399 if (!sync_point_manager) { |
| 400 if (!owned_sync_point_manager_) { |
| 401 owned_sync_point_manager_.reset(new gpu::SyncPointManager(false)); |
| 402 } |
| 403 sync_point_manager = owned_sync_point_manager_.get(); |
| 404 } |
| 405 |
398 // Defer creation of the render thread. This is to prevent it from handling | 406 // Defer creation of the render thread. This is to prevent it from handling |
399 // IPC messages before the sandbox has been enabled and all other necessary | 407 // IPC messages before the sandbox has been enabled and all other necessary |
400 // initialization has succeeded. | 408 // initialization has succeeded. |
401 gpu_channel_manager_.reset( | 409 gpu_channel_manager_.reset( |
402 new gpu::GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(), | 410 new gpu::GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(), |
403 base::ThreadTaskRunnerHandle::Get().get(), | 411 base::ThreadTaskRunnerHandle::Get().get(), |
404 ChildProcess::current()->io_task_runner(), | 412 ChildProcess::current()->io_task_runner(), |
405 ChildProcess::current()->GetShutDownEvent(), | 413 ChildProcess::current()->GetShutDownEvent(), |
406 sync_point_manager_, gpu_memory_buffer_factory_)); | 414 sync_point_manager, gpu_memory_buffer_factory_)); |
407 | 415 |
408 media_service_.reset(new MediaService(gpu_channel_manager_.get())); | 416 media_service_.reset(new MediaService(gpu_channel_manager_.get())); |
409 | 417 |
410 #if defined(USE_OZONE) | 418 #if defined(USE_OZONE) |
411 ui::OzonePlatform::GetInstance() | 419 ui::OzonePlatform::GetInstance() |
412 ->GetGpuPlatformSupport() | 420 ->GetGpuPlatformSupport() |
413 ->OnChannelEstablished(this); | 421 ->OnChannelEstablished(this); |
414 #endif | 422 #endif |
415 } | 423 } |
416 | 424 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 587 |
580 void GpuChildThread::BindProcessControlRequest( | 588 void GpuChildThread::BindProcessControlRequest( |
581 mojo::InterfaceRequest<mojom::ProcessControl> request) { | 589 mojo::InterfaceRequest<mojom::ProcessControl> request) { |
582 DVLOG(1) << "GPU: Binding ProcessControl request"; | 590 DVLOG(1) << "GPU: Binding ProcessControl request"; |
583 DCHECK(process_control_); | 591 DCHECK(process_control_); |
584 process_control_bindings_.AddBinding(process_control_.get(), | 592 process_control_bindings_.AddBinding(process_control_.get(), |
585 std::move(request)); | 593 std::move(request)); |
586 } | 594 } |
587 | 595 |
588 } // namespace content | 596 } // namespace content |
OLD | NEW |