| 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" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return builder.Build(); | 109 return builder.Build(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace | 112 } // namespace |
| 113 | 113 |
| 114 GpuChildThread::GpuChildThread( | 114 GpuChildThread::GpuChildThread( |
| 115 GpuWatchdogThread* watchdog_thread, | 115 GpuWatchdogThread* watchdog_thread, |
| 116 bool dead_on_arrival, | 116 bool dead_on_arrival, |
| 117 const gpu::GPUInfo& gpu_info, | 117 const gpu::GPUInfo& gpu_info, |
| 118 const DeferredMessages& deferred_messages, | 118 const DeferredMessages& deferred_messages, |
| 119 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 119 GpuMemoryBufferFactory* gpu_memory_buffer_factory, |
| 120 gpu::SyncPointManager* sync_point_manager) |
| 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_(sync_point_manager), |
| 122 gpu_info_(gpu_info), | 124 gpu_info_(gpu_info), |
| 123 deferred_messages_(deferred_messages), | 125 deferred_messages_(deferred_messages), |
| 124 in_browser_process_(false), | 126 in_browser_process_(false), |
| 125 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { | 127 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { |
| 126 watchdog_thread_ = watchdog_thread; | 128 watchdog_thread_ = watchdog_thread; |
| 127 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
| 128 target_services_ = NULL; | 130 target_services_ = NULL; |
| 129 #endif | 131 #endif |
| 130 g_thread_safe_sender.Get() = thread_safe_sender(); | 132 g_thread_safe_sender.Get() = thread_safe_sender(); |
| 131 } | 133 } |
| 132 | 134 |
| 133 GpuChildThread::GpuChildThread( | 135 GpuChildThread::GpuChildThread( |
| 134 const InProcessChildThreadParams& params, | 136 const InProcessChildThreadParams& params, |
| 135 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 137 GpuMemoryBufferFactory* gpu_memory_buffer_factory, |
| 138 gpu::SyncPointManager* sync_point_manager) |
| 136 : ChildThreadImpl(ChildThreadImpl::Options::Builder() | 139 : ChildThreadImpl(ChildThreadImpl::Options::Builder() |
| 137 .InBrowserProcess(params) | 140 .InBrowserProcess(params) |
| 138 .AddStartupFilter(new GpuMemoryBufferMessageFilter( | 141 .AddStartupFilter(new GpuMemoryBufferMessageFilter( |
| 139 gpu_memory_buffer_factory)) | 142 gpu_memory_buffer_factory)) |
| 140 .Build()), | 143 .Build()), |
| 141 dead_on_arrival_(false), | 144 dead_on_arrival_(false), |
| 145 sync_point_manager_(sync_point_manager), |
| 142 in_browser_process_(true), | 146 in_browser_process_(true), |
| 143 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { | 147 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { |
| 144 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
| 145 target_services_ = NULL; | 149 target_services_ = NULL; |
| 146 #endif | 150 #endif |
| 147 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 151 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 148 switches::kSingleProcess) || | 152 switches::kSingleProcess) || |
| 149 base::CommandLine::ForCurrentProcess()->HasSwitch( | 153 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 150 switches::kInProcessGPU)); | 154 switches::kInProcessGPU)); |
| 151 | 155 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (!in_browser_process_) | 242 if (!in_browser_process_) |
| 239 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 243 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
| 240 | 244 |
| 241 // Defer creation of the render thread. This is to prevent it from handling | 245 // 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 | 246 // IPC messages before the sandbox has been enabled and all other necessary |
| 243 // initialization has succeeded. | 247 // initialization has succeeded. |
| 244 gpu_channel_manager_.reset(new GpuChannelManager( | 248 gpu_channel_manager_.reset(new GpuChannelManager( |
| 245 GetRouter(), watchdog_thread_.get(), | 249 GetRouter(), watchdog_thread_.get(), |
| 246 ChildProcess::current()->io_task_runner(), | 250 ChildProcess::current()->io_task_runner(), |
| 247 ChildProcess::current()->GetShutDownEvent(), channel(), | 251 ChildProcess::current()->GetShutDownEvent(), channel(), |
| 248 GetAttachmentBroker(), gpu_memory_buffer_factory_)); | 252 GetAttachmentBroker(), sync_point_manager_, |
| 253 gpu_memory_buffer_factory_)); |
| 249 | 254 |
| 250 #if defined(USE_OZONE) | 255 #if defined(USE_OZONE) |
| 251 ui::OzonePlatform::GetInstance() | 256 ui::OzonePlatform::GetInstance() |
| 252 ->GetGpuPlatformSupport() | 257 ->GetGpuPlatformSupport() |
| 253 ->OnChannelEstablished(this); | 258 ->OnChannelEstablished(this); |
| 254 #endif | 259 #endif |
| 255 } | 260 } |
| 256 | 261 |
| 257 void GpuChildThread::StopWatchdog() { | 262 void GpuChildThread::StopWatchdog() { |
| 258 if (watchdog_thread_.get()) { | 263 if (watchdog_thread_.get()) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 352 } |
| 348 | 353 |
| 349 void GpuChildThread::OnGpuSwitched() { | 354 void GpuChildThread::OnGpuSwitched() { |
| 350 DVLOG(1) << "GPU: GPU has switched"; | 355 DVLOG(1) << "GPU: GPU has switched"; |
| 351 // Notify observers in the GPU process. | 356 // Notify observers in the GPU process. |
| 352 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 357 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
| 353 } | 358 } |
| 354 | 359 |
| 355 } // namespace content | 360 } // namespace content |
| 356 | 361 |
| OLD | NEW |