| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "content/child/child_process.h" | 11 #include "content/child/child_process.h" |
| 12 #include "content/child/thread_safe_sender.h" | 12 #include "content/child/thread_safe_sender.h" |
| 13 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 13 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 14 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
| 15 #include "content/gpu/gpu_watchdog_thread.h" | 15 #include "content/gpu/gpu_watchdog_thread.h" |
| 16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 18 #include "gpu/config/gpu_info_collector.h" | 19 #include "gpu/config/gpu_info_collector.h" |
| 19 #include "ipc/ipc_channel_handle.h" | 20 #include "ipc/ipc_channel_handle.h" |
| 20 #include "ipc/ipc_sync_message_filter.h" | 21 #include "ipc/ipc_sync_message_filter.h" |
| 21 #include "ui/gl/gl_implementation.h" | 22 #include "ui/gl/gl_implementation.h" |
| 22 #include "ui/gl/gpu_switching_manager.h" | 23 #include "ui/gl/gpu_switching_manager.h" |
| 23 | 24 |
| 24 #if defined(USE_OZONE) | 25 #if defined(USE_OZONE) |
| 25 #include "ui/ozone/public/gpu_platform_support.h" | 26 #include "ui/ozone/public/gpu_platform_support.h" |
| 26 #include "ui/ozone/public/ozone_platform.h" | 27 #include "ui/ozone/public/ozone_platform.h" |
| 27 #endif | 28 #endif |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } // namespace | 113 } // namespace |
| 113 | 114 |
| 114 GpuChildThread::GpuChildThread( | 115 GpuChildThread::GpuChildThread( |
| 115 GpuWatchdogThread* watchdog_thread, | 116 GpuWatchdogThread* watchdog_thread, |
| 116 bool dead_on_arrival, | 117 bool dead_on_arrival, |
| 117 const gpu::GPUInfo& gpu_info, | 118 const gpu::GPUInfo& gpu_info, |
| 118 const DeferredMessages& deferred_messages, | 119 const DeferredMessages& deferred_messages, |
| 119 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 120 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| 120 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), | 121 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), |
| 121 dead_on_arrival_(dead_on_arrival), | 122 dead_on_arrival_(dead_on_arrival), |
| 123 sync_point_manager_(new gpu::SyncPointManager(false)), |
| 124 sync_point_manager_ptr_(sync_point_manager_.get()), |
| 122 gpu_info_(gpu_info), | 125 gpu_info_(gpu_info), |
| 123 deferred_messages_(deferred_messages), | 126 deferred_messages_(deferred_messages), |
| 124 in_browser_process_(false), | 127 in_browser_process_(false), |
| 125 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { | 128 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { |
| 126 watchdog_thread_ = watchdog_thread; | 129 watchdog_thread_ = watchdog_thread; |
| 127 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 128 target_services_ = NULL; | 131 target_services_ = NULL; |
| 129 #endif | 132 #endif |
| 130 g_thread_safe_sender.Get() = thread_safe_sender(); | 133 g_thread_safe_sender.Get() = thread_safe_sender(); |
| 131 } | 134 } |
| 132 | 135 |
| 133 GpuChildThread::GpuChildThread( | 136 GpuChildThread::GpuChildThread( |
| 134 const InProcessChildThreadParams& params, | 137 const InProcessChildThreadParams& params, |
| 135 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 138 GpuMemoryBufferFactory* gpu_memory_buffer_factory, |
| 139 gpu::SyncPointManager* sync_point_manager_override) |
| 136 : ChildThreadImpl(ChildThreadImpl::Options::Builder() | 140 : ChildThreadImpl(ChildThreadImpl::Options::Builder() |
| 137 .InBrowserProcess(params) | 141 .InBrowserProcess(params) |
| 138 .AddStartupFilter(new GpuMemoryBufferMessageFilter( | 142 .AddStartupFilter(new GpuMemoryBufferMessageFilter( |
| 139 gpu_memory_buffer_factory)) | 143 gpu_memory_buffer_factory)) |
| 140 .Build()), | 144 .Build()), |
| 141 dead_on_arrival_(false), | 145 dead_on_arrival_(false), |
| 146 sync_point_manager_(sync_point_manager_override |
| 147 ? nullptr |
| 148 : new gpu::SyncPointManager(false)), |
| 149 sync_point_manager_ptr_(sync_point_manager_override |
| 150 ? sync_point_manager_override |
| 151 : sync_point_manager_.get()), |
| 142 in_browser_process_(true), | 152 in_browser_process_(true), |
| 143 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { | 153 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { |
| 144 #if defined(OS_WIN) | 154 #if defined(OS_WIN) |
| 145 target_services_ = NULL; | 155 target_services_ = NULL; |
| 146 #endif | 156 #endif |
| 147 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 157 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 148 switches::kSingleProcess) || | 158 switches::kSingleProcess) || |
| 149 base::CommandLine::ForCurrentProcess()->HasSwitch( | 159 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 150 switches::kInProcessGPU)); | 160 switches::kInProcessGPU)); |
| 151 | 161 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (!in_browser_process_) | 248 if (!in_browser_process_) |
| 239 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 249 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
| 240 | 250 |
| 241 // Defer creation of the render thread. This is to prevent it from handling | 251 // Defer creation of the render thread. This is to prevent it from handling |
| 242 // IPC messages before the sandbox has been enabled and all other necessary | 252 // IPC messages before the sandbox has been enabled and all other necessary |
| 243 // initialization has succeeded. | 253 // initialization has succeeded. |
| 244 gpu_channel_manager_.reset(new GpuChannelManager( | 254 gpu_channel_manager_.reset(new GpuChannelManager( |
| 245 GetRouter(), watchdog_thread_.get(), | 255 GetRouter(), watchdog_thread_.get(), |
| 246 ChildProcess::current()->io_task_runner(), | 256 ChildProcess::current()->io_task_runner(), |
| 247 ChildProcess::current()->GetShutDownEvent(), channel(), | 257 ChildProcess::current()->GetShutDownEvent(), channel(), |
| 248 GetAttachmentBroker(), gpu_memory_buffer_factory_)); | 258 GetAttachmentBroker(), sync_point_manager_ptr_, |
| 259 gpu_memory_buffer_factory_)); |
| 249 | 260 |
| 250 #if defined(USE_OZONE) | 261 #if defined(USE_OZONE) |
| 251 ui::OzonePlatform::GetInstance() | 262 ui::OzonePlatform::GetInstance() |
| 252 ->GetGpuPlatformSupport() | 263 ->GetGpuPlatformSupport() |
| 253 ->OnChannelEstablished(this); | 264 ->OnChannelEstablished(this); |
| 254 #endif | 265 #endif |
| 255 } | 266 } |
| 256 | 267 |
| 257 void GpuChildThread::StopWatchdog() { | 268 void GpuChildThread::StopWatchdog() { |
| 258 if (watchdog_thread_.get()) { | 269 if (watchdog_thread_.get()) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 358 } |
| 348 | 359 |
| 349 void GpuChildThread::OnGpuSwitched() { | 360 void GpuChildThread::OnGpuSwitched() { |
| 350 DVLOG(1) << "GPU: GPU has switched"; | 361 DVLOG(1) << "GPU: GPU has switched"; |
| 351 // Notify observers in the GPU process. | 362 // Notify observers in the GPU process. |
| 352 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 363 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
| 353 } | 364 } |
| 354 | 365 |
| 355 } // namespace content | 366 } // namespace content |
| 356 | 367 |
| OLD | NEW |