| 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_main.h" | 5 #include "services/ui/gpu/gpu_main.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/power_monitor/power_monitor_device_source.h" | 10 #include "base/power_monitor/power_monitor_device_source.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 void GpuMain::InitOnGpuThread( | 149 void GpuMain::InitOnGpuThread( |
| 150 scoped_refptr<base::SingleThreadTaskRunner> io_runner, | 150 scoped_refptr<base::SingleThreadTaskRunner> io_runner, |
| 151 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner) { | 151 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner) { |
| 152 gpu_init_.reset(new gpu::GpuInit()); | 152 gpu_init_.reset(new gpu::GpuInit()); |
| 153 gpu_init_->set_sandbox_helper(this); | 153 gpu_init_->set_sandbox_helper(this); |
| 154 bool success = gpu_init_->InitializeAndStartSandbox( | 154 bool success = gpu_init_->InitializeAndStartSandbox( |
| 155 *base::CommandLine::ForCurrentProcess()); | 155 *base::CommandLine::ForCurrentProcess()); |
| 156 if (!success) | 156 if (!success) |
| 157 return; | 157 return; |
| 158 | 158 |
| 159 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) { | |
| 160 gpu_memory_buffer_factory_ = | |
| 161 gpu::GpuMemoryBufferFactory::CreateNativeType(); | |
| 162 } | |
| 163 | |
| 164 gpu_service_ = base::MakeUnique<GpuService>( | 159 gpu_service_ = base::MakeUnique<GpuService>( |
| 165 gpu_init_->gpu_info(), gpu_init_->TakeWatchdogThread(), | 160 gpu_init_->gpu_info(), gpu_init_->TakeWatchdogThread(), io_runner, |
| 166 gpu_memory_buffer_factory_.get(), io_runner, | |
| 167 gpu_init_->gpu_feature_info()); | 161 gpu_init_->gpu_feature_info()); |
| 168 } | 162 } |
| 169 | 163 |
| 170 void GpuMain::CreateDisplayCompositorInternal( | 164 void GpuMain::CreateDisplayCompositorInternal( |
| 171 cc::mojom::DisplayCompositorRequest request, | 165 cc::mojom::DisplayCompositorRequest request, |
| 172 cc::mojom::DisplayCompositorClientPtrInfo client_info) { | 166 cc::mojom::DisplayCompositorClientPtrInfo client_info) { |
| 173 DCHECK(!gpu_command_service_); | 167 DCHECK(!gpu_command_service_); |
| 174 gpu_command_service_ = new gpu::GpuInProcessThreadService( | 168 gpu_command_service_ = new gpu::GpuInProcessThreadService( |
| 175 gpu_thread_task_runner_, gpu_service_->sync_point_manager(), | 169 gpu_thread_task_runner_, gpu_service_->sync_point_manager(), |
| 176 gpu_service_->mailbox_manager(), gpu_service_->share_group()); | 170 gpu_service_->mailbox_manager(), gpu_service_->share_group()); |
| 177 | 171 |
| 178 // |gpu_memory_buffer_factory_| is null in tests. | 172 gpu::ImageFactory* image_factory = gpu_service_->gpu_image_factory(); |
| 179 gpu::ImageFactory* image_factory = | |
| 180 gpu_memory_buffer_factory_ ? gpu_memory_buffer_factory_->AsImageFactory() | |
| 181 : nullptr; | |
| 182 | |
| 183 mojom::GpuServicePtr gpu_service; | 173 mojom::GpuServicePtr gpu_service; |
| 184 mojom::GpuServiceRequest gpu_service_request(&gpu_service); | 174 mojom::GpuServiceRequest gpu_service_request(&gpu_service); |
| 185 | 175 |
| 186 if (gpu_thread_task_runner_->BelongsToCurrentThread()) { | 176 if (gpu_thread_task_runner_->BelongsToCurrentThread()) { |
| 187 // If the DisplayCompositor creation was delayed because GpuService | 177 // If the DisplayCompositor creation was delayed because GpuService |
| 188 // had not been created yet, then this is called, in gpu thread, right after | 178 // had not been created yet, then this is called, in gpu thread, right after |
| 189 // GpuService is created. | 179 // GpuService is created. |
| 190 BindGpuInternalOnGpuThread(std::move(gpu_service_request)); | 180 BindGpuInternalOnGpuThread(std::move(gpu_service_request)); |
| 191 } else { | 181 } else { |
| 192 gpu_thread_task_runner_->PostTask( | 182 gpu_thread_task_runner_->PostTask( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // TODO(sad): https://crbug.com/645602 | 253 // TODO(sad): https://crbug.com/645602 |
| 264 } | 254 } |
| 265 | 255 |
| 266 bool GpuMain::EnsureSandboxInitialized( | 256 bool GpuMain::EnsureSandboxInitialized( |
| 267 gpu::GpuWatchdogThread* watchdog_thread) { | 257 gpu::GpuWatchdogThread* watchdog_thread) { |
| 268 // TODO(sad): https://crbug.com/645602 | 258 // TODO(sad): https://crbug.com/645602 |
| 269 return true; | 259 return true; |
| 270 } | 260 } |
| 271 | 261 |
| 272 } // namespace ui | 262 } // namespace ui |
| OLD | NEW |