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 <dwmapi.h> |
8 #include <windows.h> | 9 #include <windows.h> |
9 #endif | 10 #endif |
10 | 11 |
11 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
(...skipping 10 matching lines...) Expand all Loading... |
28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
29 #include "content/public/common/main_function_params.h" | 30 #include "content/public/common/main_function_params.h" |
30 #include "crypto/hmac.h" | 31 #include "crypto/hmac.h" |
31 #include "gpu/config/gpu_info_collector.h" | 32 #include "gpu/config/gpu_info_collector.h" |
32 #include "ui/gl/gl_implementation.h" | 33 #include "ui/gl/gl_implementation.h" |
33 #include "ui/gl/gl_surface.h" | 34 #include "ui/gl/gl_surface.h" |
34 #include "ui/gl/gl_switches.h" | 35 #include "ui/gl/gl_switches.h" |
35 #include "ui/gl/gpu_switching_manager.h" | 36 #include "ui/gl/gpu_switching_manager.h" |
36 | 37 |
37 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 39 #include "base/win/windows_version.h" |
38 #include "base/win/scoped_com_initializer.h" | 40 #include "base/win/scoped_com_initializer.h" |
39 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 41 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
40 #include "sandbox/win/src/sandbox.h" | 42 #include "sandbox/win/src/sandbox.h" |
41 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 43 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
42 #include "content/common/gpu/media/exynos_video_decode_accelerator.h" | 44 #include "content/common/gpu/media/exynos_video_decode_accelerator.h" |
43 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 45 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
44 #include "content/common/gpu/media/vaapi_wrapper.h" | 46 #include "content/common/gpu/media/vaapi_wrapper.h" |
45 #endif | 47 #endif |
46 | 48 |
47 #if defined(USE_X11) | 49 #if defined(USE_X11) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 LOG(ERROR) << "WarmUpSandbox() failed with loading setupapi.dll"; | 370 LOG(ERROR) << "WarmUpSandbox() failed with loading setupapi.dll"; |
369 return false; | 371 return false; |
370 } | 372 } |
371 } | 373 } |
372 | 374 |
373 if (!command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | 375 if (!command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode)) { |
374 TRACE_EVENT0("gpu", "Initialize DXVA"); | 376 TRACE_EVENT0("gpu", "Initialize DXVA"); |
375 // Initialize H/W video decoding stuff which fails in the sandbox. | 377 // Initialize H/W video decoding stuff which fails in the sandbox. |
376 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | 378 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
377 } | 379 } |
| 380 |
| 381 { |
| 382 TRACE_EVENT0("gpu", "Warm up DWM"); |
| 383 |
| 384 // DWM was introduced with Windows Vista. DwmFlush seems to be sufficient |
| 385 // to warm it up before lowering the token. DWM is required to present to |
| 386 // a window with Vista and later and this allows us to do so with the |
| 387 // GPU process sandbox enabled. |
| 388 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 389 HMODULE module = LoadLibrary(L"dwmapi.dll"); |
| 390 if (module) { |
| 391 typedef HRESULT (WINAPI *DwmFlushFunc)(); |
| 392 DwmFlushFunc dwm_flush = reinterpret_cast<DwmFlushFunc>( |
| 393 GetProcAddress(module, "DwmFlush")); |
| 394 if (dwm_flush) |
| 395 dwm_flush(); |
| 396 } |
| 397 } |
| 398 } |
378 #endif | 399 #endif |
379 return true; | 400 return true; |
380 } | 401 } |
381 | 402 |
382 #if defined(OS_LINUX) | 403 #if defined(OS_LINUX) |
383 void WarmUpSandboxNvidia(const gpu::GPUInfo& gpu_info, | 404 void WarmUpSandboxNvidia(const gpu::GPUInfo& gpu_info, |
384 bool should_initialize_gl_context) { | 405 bool should_initialize_gl_context) { |
385 // We special case Optimus since the vendor_id we see may not be Nvidia. | 406 // We special case Optimus since the vendor_id we see may not be Nvidia. |
386 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. | 407 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. |
387 gpu_info.driver_vendor == "NVIDIA") || | 408 gpu_info.driver_vendor == "NVIDIA") || |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 return true; | 447 return true; |
427 } | 448 } |
428 | 449 |
429 return false; | 450 return false; |
430 } | 451 } |
431 #endif // defined(OS_WIN) | 452 #endif // defined(OS_WIN) |
432 | 453 |
433 } // namespace. | 454 } // namespace. |
434 | 455 |
435 } // namespace content | 456 } // namespace content |
OLD | NEW |