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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 success = base::HexStringToInt( | 161 success = base::HexStringToInt( |
162 command_line.GetSwitchValueASCII(switches::kGpuDeviceID), | 162 command_line.GetSwitchValueASCII(switches::kGpuDeviceID), |
163 reinterpret_cast<int*>(&(gpu_info.gpu.device_id))); | 163 reinterpret_cast<int*>(&(gpu_info.gpu.device_id))); |
164 DCHECK(success); | 164 DCHECK(success); |
165 gpu_info.driver_vendor = | 165 gpu_info.driver_vendor = |
166 command_line.GetSwitchValueASCII(switches::kGpuDriverVendor); | 166 command_line.GetSwitchValueASCII(switches::kGpuDriverVendor); |
167 gpu_info.driver_version = | 167 gpu_info.driver_version = |
168 command_line.GetSwitchValueASCII(switches::kGpuDriverVersion); | 168 command_line.GetSwitchValueASCII(switches::kGpuDriverVersion); |
169 GetContentClient()->SetGpuInfo(gpu_info); | 169 GetContentClient()->SetGpuInfo(gpu_info); |
170 | 170 |
171 #if defined(OS_WIN) | |
172 // Asynchronously initialize DXVA while GL is being initialized because | |
173 // they both take tens of ms. | |
174 base::WaitableEvent dxva_initialized(true, false); | |
175 DXVAVideoDecodeAccelerator::PreSandboxInitialization( | |
176 base::Bind(&base::WaitableEvent::Signal, | |
177 base::Unretained(&dxva_initialized))); | |
178 #endif | |
179 | |
171 // We need to track that information for the WarmUpSandbox function. | 180 // We need to track that information for the WarmUpSandbox function. |
172 bool initialized_gl_context = false; | 181 bool initialized_gl_context = false; |
173 // Load and initialize the GL implementation and locate the GL entry points. | 182 // Load and initialize the GL implementation and locate the GL entry points. |
174 if (gfx::GLSurface::InitializeOneOff()) { | 183 if (gfx::GLSurface::InitializeOneOff()) { |
175 if (!command_line.HasSwitch(switches::kSkipGpuFullInfoCollection)) { | 184 if (!command_line.HasSwitch(switches::kSkipGpuFullInfoCollection)) { |
176 if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info)) | 185 if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info)) |
177 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; | 186 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |
178 GetContentClient()->SetGpuInfo(gpu_info); | 187 GetContentClient()->SetGpuInfo(gpu_info); |
179 | 188 |
180 // We know that CollectGraphicsInfo will initialize a GLContext. | 189 // We know that CollectGraphicsInfo will initialize a GLContext. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 watchdog_thread->Stop(); | 245 watchdog_thread->Stop(); |
237 gpu_info.sandboxed = InitializeSandbox(); | 246 gpu_info.sandboxed = InitializeSandbox(); |
238 if (watchdog_thread.get()) | 247 if (watchdog_thread.get()) |
239 watchdog_thread->Start(); | 248 watchdog_thread->Start(); |
240 } | 249 } |
241 } | 250 } |
242 #endif | 251 #endif |
243 | 252 |
244 #if defined(OS_WIN) | 253 #if defined(OS_WIN) |
245 { | 254 { |
255 // DXVA initialization must have completed before the token is lowered. | |
256 TRACE_EVENT0("gpu", "Wait for DXVA initialization"); | |
257 dxva_initialized.Wait(); | |
258 } | |
259 | |
260 { | |
246 TRACE_EVENT0("gpu", "Lower token"); | 261 TRACE_EVENT0("gpu", "Lower token"); |
247 // For windows, if the target_services interface is not zero, the process | 262 // For windows, if the target_services interface is not zero, the process |
248 // is sandboxed and we must call LowerToken() before rendering untrusted | 263 // is sandboxed and we must call LowerToken() before rendering untrusted |
249 // content. | 264 // content. |
250 sandbox::TargetServices* target_services = | 265 sandbox::TargetServices* target_services = |
251 parameters.sandbox_info->target_services; | 266 parameters.sandbox_info->target_services; |
252 if (target_services) { | 267 if (target_services) { |
253 target_services->LowerToken(); | 268 target_services->LowerToken(); |
254 gpu_info.sandboxed = true; | 269 gpu_info.sandboxed = true; |
255 } | 270 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. | 350 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. |
336 gpu_info.driver_vendor == "NVIDIA") || | 351 gpu_info.driver_vendor == "NVIDIA") || |
337 gpu_info.optimus; | 352 gpu_info.optimus; |
338 if (uses_nvidia_driver && should_initialize_gl_context) { | 353 if (uses_nvidia_driver && should_initialize_gl_context) { |
339 // We need this on Nvidia to pre-open /dev/nvidiactl and /dev/nvidia0. | 354 // We need this on Nvidia to pre-open /dev/nvidiactl and /dev/nvidia0. |
340 CreateDummyGlContext(); | 355 CreateDummyGlContext(); |
341 } | 356 } |
342 #endif | 357 #endif |
343 | 358 |
344 #if defined(OS_WIN) | 359 #if defined(OS_WIN) |
345 { | 360 // Preload these DLL because the sandbox prevents them from loading. |
346 TRACE_EVENT0("gpu", "Initialize COM"); | 361 LoadLibrary(L"setupapi.dll"); |
347 base::win::ScopedCOMInitializer com_initializer; | |
apatrick_chromium
2012/11/29 21:54:58
This was clearly nonsense. COM would be uninitiali
| |
348 } | |
349 | |
350 { | |
351 TRACE_EVENT0("gpu", "Preload setupapi.dll"); | |
352 // Preload this DLL because the sandbox prevents it from loading. | |
353 LoadLibrary(L"setupapi.dll"); | |
354 } | |
355 | |
356 { | |
357 TRACE_EVENT0("gpu", "Initialize DXVA"); | |
358 // Initialize H/W video decoding stuff which fails in the sandbox. | |
359 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | |
360 } | |
361 #endif | 362 #endif |
362 } | 363 } |
363 | 364 |
364 } // namespace. | 365 } // namespace. |
365 | 366 |
366 } // namespace content | 367 } // namespace content |
OLD | NEW |