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" | 17 #include "base/win/scoped_com_initializer.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "content/common/gpu/gpu_config.h" | 19 #include "content/common/gpu/gpu_config.h" |
20 #include "content/gpu/gpu_child_thread.h" | 20 #include "content/gpu/gpu_child_thread.h" |
21 #include "content/gpu/gpu_info_collector.h" | 21 #include "content/gpu/gpu_info_collector.h" |
22 #include "content/gpu/gpu_process.h" | 22 #include "content/gpu/gpu_process.h" |
23 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/common/gpu_switching_option.h" |
25 #include "content/public/common/main_function_params.h" | 26 #include "content/public/common/main_function_params.h" |
26 #include "crypto/hmac.h" | 27 #include "crypto/hmac.h" |
27 #include "ui/gl/gl_surface.h" | 28 #include "ui/gl/gl_surface.h" |
28 #include "ui/gl/gl_switches.h" | 29 #include "ui/gl/gl_switches.h" |
| 30 #include "ui/gl/gpu_switching_manager.h" |
29 | 31 |
30 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
31 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 33 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
32 #include "sandbox/win/src/sandbox.h" | 34 #include "sandbox/win/src/sandbox.h" |
33 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 35 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
34 #include "content/common/gpu/media/omx_video_decode_accelerator.h" | 36 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
35 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 37 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
36 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 38 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
37 #endif | 39 #endif |
38 | 40 |
(...skipping 27 matching lines...) Expand all Loading... |
66 // able to load a DLL. | 68 // able to load a DLL. |
67 SetErrorMode( | 69 SetErrorMode( |
68 SEM_FAILCRITICALERRORS | | 70 SEM_FAILCRITICALERRORS | |
69 SEM_NOGPFAULTERRORBOX | | 71 SEM_NOGPFAULTERRORBOX | |
70 SEM_NOOPENFILEERRORBOX); | 72 SEM_NOOPENFILEERRORBOX); |
71 #elif defined(USE_X11) | 73 #elif defined(USE_X11) |
72 ui::SetDefaultX11ErrorHandlers(); | 74 ui::SetDefaultX11ErrorHandlers(); |
73 #endif | 75 #endif |
74 } | 76 } |
75 | 77 |
| 78 if (command_line.HasSwitch(switches::kGpuSwitching)) { |
| 79 std::string option = command_line.GetSwitchValueASCII( |
| 80 switches::kGpuSwitching); |
| 81 if (option == switches::kGpuSwitchingOptionNameForceDiscrete) |
| 82 gfx::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); |
| 83 else if (option == switches::kGpuSwitchingOptionNameForceIntegrated) |
| 84 gfx::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); |
| 85 } |
| 86 |
76 // Initialization of the OpenGL bindings may fail, in which case we | 87 // Initialization of the OpenGL bindings may fail, in which case we |
77 // will need to tear down this process. However, we can not do so | 88 // will need to tear down this process. However, we can not do so |
78 // safely until the IPC channel is set up, because the detection of | 89 // safely until the IPC channel is set up, because the detection of |
79 // early return of a child process is implemented using an IPC | 90 // early return of a child process is implemented using an IPC |
80 // channel error. If the IPC channel is not fully set up between the | 91 // channel error. If the IPC channel is not fully set up between the |
81 // browser and GPU process, and the GPU process crashes or exits | 92 // browser and GPU process, and the GPU process crashes or exits |
82 // early, the browser process will never detect it. For this reason | 93 // early, the browser process will never detect it. For this reason |
83 // we defer tearing down the GPU process until receiving the | 94 // we defer tearing down the GPU process until receiving the |
84 // GpuMsg_Initialize message from the browser. | 95 // GpuMsg_Initialize message from the browser. |
85 bool dead_on_arrival = false; | 96 bool dead_on_arrival = false; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 309 } |
299 | 310 |
300 void CollectGraphicsInfo(content::GPUInfo* gpu_info) { | 311 void CollectGraphicsInfo(content::GPUInfo* gpu_info) { |
301 if (!gpu_info_collector::CollectGraphicsInfo(gpu_info)) | 312 if (!gpu_info_collector::CollectGraphicsInfo(gpu_info)) |
302 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; | 313 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |
303 content::GetContentClient()->SetGpuInfo(*gpu_info); | 314 content::GetContentClient()->SetGpuInfo(*gpu_info); |
304 } | 315 } |
305 | 316 |
306 } // namespace. | 317 } // namespace. |
307 | 318 |
OLD | NEW |