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 "gpu/ipc/service/gpu_init.h" | 5 #include "gpu/ipc/service/gpu_init.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "gpu/command_buffer/service/gpu_switches.h" | 13 #include "gpu/command_buffer/service/gpu_switches.h" |
14 #include "gpu/config/gpu_driver_bug_list.h" | 14 #include "gpu/config/gpu_driver_bug_list.h" |
15 #include "gpu/config/gpu_info_collector.h" | 15 #include "gpu/config/gpu_info_collector.h" |
16 #include "gpu/config/gpu_switches.h" | 16 #include "gpu/config/gpu_switches.h" |
17 #include "gpu/config/gpu_util.h" | 17 #include "gpu/config/gpu_util.h" |
18 #include "gpu/ipc/service/gpu_watchdog_thread.h" | 18 #include "gpu/ipc/service/gpu_watchdog_thread.h" |
19 #include "gpu/ipc/service/switches.h" | 19 #include "gpu/ipc/service/switches.h" |
20 #include "ui/gl/gl_implementation.h" | 20 #include "ui/gl/gl_implementation.h" |
21 #include "ui/gl/gl_switches.h" | 21 #include "ui/gl/gl_switches.h" |
22 #include "ui/gl/init/gl_factory.h" | 22 #include "ui/gl/init/gl_factory.h" |
23 | 23 |
| 24 #if defined(USE_OZONE) |
| 25 #include "ui/ozone/public/ozone_platform.h" |
| 26 #endif |
| 27 |
24 namespace gpu { | 28 namespace gpu { |
25 | 29 |
26 namespace { | 30 namespace { |
27 | 31 |
28 void GetGpuInfoFromCommandLine(gpu::GPUInfo& gpu_info, | 32 void GetGpuInfoFromCommandLine(gpu::GPUInfo& gpu_info, |
29 const base::CommandLine& command_line) { | 33 const base::CommandLine& command_line) { |
30 if (!command_line.HasSwitch(switches::kGpuVendorID) || | 34 if (!command_line.HasSwitch(switches::kGpuVendorID) || |
31 !command_line.HasSwitch(switches::kGpuDeviceID) || | 35 !command_line.HasSwitch(switches::kGpuDeviceID) || |
32 !command_line.HasSwitch(switches::kGpuDriverVersion)) | 36 !command_line.HasSwitch(switches::kGpuDriverVersion)) |
33 return; | 37 return; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return res; | 111 return res; |
108 } | 112 } |
109 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 113 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
110 | 114 |
111 } // namespace | 115 } // namespace |
112 | 116 |
113 GpuInit::GpuInit() {} | 117 GpuInit::GpuInit() {} |
114 | 118 |
115 GpuInit::~GpuInit() {} | 119 GpuInit::~GpuInit() {} |
116 | 120 |
117 bool GpuInit::InitializeAndStartSandbox(const base::CommandLine& command_line) { | 121 bool GpuInit::InitializeAndStartSandbox(const base::CommandLine& command_line, |
| 122 shell::Connector* connector) { |
118 if (command_line.HasSwitch(switches::kSupportsDualGpus)) { | 123 if (command_line.HasSwitch(switches::kSupportsDualGpus)) { |
119 std::set<int> workarounds; | 124 std::set<int> workarounds; |
120 gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine(&workarounds, | 125 gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine(&workarounds, |
121 command_line); | 126 command_line); |
122 gpu::InitializeDualGpusIfSupported(workarounds); | 127 gpu::InitializeDualGpusIfSupported(workarounds); |
123 } | 128 } |
124 | 129 |
125 // In addition to disabling the watchdog if the command line switch is | 130 // In addition to disabling the watchdog if the command line switch is |
126 // present, disable the watchdog on valgrind because the code is expected | 131 // present, disable the watchdog on valgrind because the code is expected |
127 // to run slowly in that case. | 132 // to run slowly in that case. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 167 |
163 #if defined(OS_LINUX) | 168 #if defined(OS_LINUX) |
164 // On Chrome OS ARM Mali, GPU driver userspace creates threads when | 169 // On Chrome OS ARM Mali, GPU driver userspace creates threads when |
165 // initializing a GL context, so start the sandbox early. | 170 // initializing a GL context, so start the sandbox early. |
166 if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) | 171 if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) |
167 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); | 172 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); |
168 #endif // defined(OS_LINUX) | 173 #endif // defined(OS_LINUX) |
169 | 174 |
170 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); | 175 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); |
171 | 176 |
| 177 #if defined(USE_OZONE) |
| 178 ui::OzonePlatform::InitParams ozoneInitParams; |
| 179 ozoneInitParams.connector = connector; |
| 180 ui::OzonePlatform::InitializeForGPU(ozoneInitParams); |
| 181 #endif |
| 182 |
172 // Load and initialize the GL implementation and locate the GL entry points if | 183 // Load and initialize the GL implementation and locate the GL entry points if |
173 // needed. This initialization may have already happened if running in the | 184 // needed. This initialization may have already happened if running in the |
174 // browser process, for example. | 185 // browser process, for example. |
175 bool gl_initialized = gl::GetGLImplementation() != gl::kGLImplementationNone; | 186 bool gl_initialized = gl::GetGLImplementation() != gl::kGLImplementationNone; |
176 if (!gl_initialized) | 187 if (!gl_initialized) |
177 gl_initialized = gl::init::InitializeGLOneOff(); | 188 gl_initialized = gl::init::InitializeGLOneOff(); |
178 | 189 |
179 if (!gl_initialized) { | 190 if (!gl_initialized) { |
180 VLOG(1) << "gl::init::InitializeGLOneOff failed"; | 191 VLOG(1) << "gl::init::InitializeGLOneOff failed"; |
181 return false; | 192 return false; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } else if (enable_watchdog && delayed_watchdog_enable) { | 236 } else if (enable_watchdog && delayed_watchdog_enable) { |
226 watchdog_thread_ = gpu::GpuWatchdogThread::Create(); | 237 watchdog_thread_ = gpu::GpuWatchdogThread::Create(); |
227 } | 238 } |
228 | 239 |
229 if (!gpu_info_.sandboxed) | 240 if (!gpu_info_.sandboxed) |
230 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); | 241 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); |
231 return true; | 242 return true; |
232 } | 243 } |
233 | 244 |
234 } // namespace gpu | 245 } // namespace gpu |
OLD | NEW |