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 |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
17 #include "base/win/scoped_com_initializer.h" | |
18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
19 #include "content/common/gpu/gpu_config.h" | 18 #include "content/common/gpu/gpu_config.h" |
20 #include "content/gpu/gpu_child_thread.h" | 19 #include "content/gpu/gpu_child_thread.h" |
21 #include "content/gpu/gpu_info_collector.h" | 20 #include "content/gpu/gpu_info_collector.h" |
22 #include "content/gpu/gpu_process.h" | 21 #include "content/gpu/gpu_process.h" |
23 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
24 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
25 #include "content/public/common/gpu_switching_option.h" | 24 #include "content/public/common/gpu_switching_option.h" |
26 #include "content/public/common/main_function_params.h" | 25 #include "content/public/common/main_function_params.h" |
27 #include "crypto/hmac.h" | 26 #include "crypto/hmac.h" |
28 #include "ui/gl/gl_surface.h" | 27 #include "ui/gl/gl_surface.h" |
29 #include "ui/gl/gl_switches.h" | 28 #include "ui/gl/gl_switches.h" |
30 #include "ui/gl/gpu_switching_manager.h" | 29 #include "ui/gl/gpu_switching_manager.h" |
31 | 30 |
32 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 #include "base/win/scoped_com_initializer.h" |
33 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 33 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
34 #include "sandbox/win/src/sandbox.h" | 34 #include "sandbox/win/src/sandbox.h" |
35 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 35 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
36 #include "content/common/gpu/media/omx_video_decode_accelerator.h" | 36 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
37 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 37 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
38 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 38 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
39 #endif | 39 #endif |
40 | 40 |
41 #if defined(USE_X11) | 41 #if defined(USE_X11) |
42 #include "ui/base/x/x11_util.h" | 42 #include "ui/base/x/x11_util.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // We special case Optimus since the vendor_id we see may not be Nvidia. | 281 // We special case Optimus since the vendor_id we see may not be Nvidia. |
282 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. | 282 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. |
283 gpu_info.driver_vendor == "NVIDIA") || | 283 gpu_info.driver_vendor == "NVIDIA") || |
284 gpu_info.optimus; | 284 gpu_info.optimus; |
285 if (uses_nvidia_driver && should_initialize_gl_context) { | 285 if (uses_nvidia_driver && should_initialize_gl_context) { |
286 // We need this on Nvidia to pre-open /dev/nvidiactl and /dev/nvidia0. | 286 // We need this on Nvidia to pre-open /dev/nvidiactl and /dev/nvidia0. |
287 CreateDummyGlContext(); | 287 CreateDummyGlContext(); |
288 } | 288 } |
289 #endif | 289 #endif |
290 | 290 |
| 291 #if defined(OS_WIN) |
291 { | 292 { |
292 TRACE_EVENT0("gpu", "Initialize COM"); | 293 TRACE_EVENT0("gpu", "Initialize COM"); |
293 base::win::ScopedCOMInitializer com_initializer; | 294 base::win::ScopedCOMInitializer com_initializer; |
294 } | 295 } |
295 | 296 |
296 #if defined(OS_WIN) | |
297 { | 297 { |
298 TRACE_EVENT0("gpu", "Preload setupapi.dll"); | 298 TRACE_EVENT0("gpu", "Preload setupapi.dll"); |
299 // Preload this DLL because the sandbox prevents it from loading. | 299 // Preload this DLL because the sandbox prevents it from loading. |
300 LoadLibrary(L"setupapi.dll"); | 300 LoadLibrary(L"setupapi.dll"); |
301 } | 301 } |
302 | 302 |
303 { | 303 { |
304 TRACE_EVENT0("gpu", "Initialize DXVA"); | 304 TRACE_EVENT0("gpu", "Initialize DXVA"); |
305 // Initialize H/W video decoding stuff which fails in the sandbox. | 305 // Initialize H/W video decoding stuff which fails in the sandbox. |
306 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | 306 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
307 } | 307 } |
308 #endif | 308 #endif |
309 } | 309 } |
310 | 310 |
311 void CollectGraphicsInfo(content::GPUInfo* gpu_info) { | 311 void CollectGraphicsInfo(content::GPUInfo* gpu_info) { |
312 if (!gpu_info_collector::CollectGraphicsInfo(gpu_info)) | 312 if (!gpu_info_collector::CollectGraphicsInfo(gpu_info)) |
313 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; | 313 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |
314 content::GetContentClient()->SetGpuInfo(*gpu_info); | 314 content::GetContentClient()->SetGpuInfo(*gpu_info); |
315 } | 315 } |
316 | 316 |
317 } // namespace. | 317 } // namespace. |
318 | 318 |
OLD | NEW |