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 "content/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "content/browser/gpu/gpu_surface_tracker.h" | 29 #include "content/browser/gpu/gpu_surface_tracker.h" |
30 #include "content/browser/gpu/shader_disk_cache.h" | 30 #include "content/browser/gpu/shader_disk_cache.h" |
31 #include "content/browser/mojo/mojo_application_host.h" | 31 #include "content/browser/mojo/mojo_application_host.h" |
32 #include "content/browser/renderer_host/render_widget_host_impl.h" | 32 #include "content/browser/renderer_host/render_widget_host_impl.h" |
33 #include "content/common/child_process_host_impl.h" | 33 #include "content/common/child_process_host_impl.h" |
34 #include "content/common/gpu/gpu_host_messages.h" | 34 #include "content/common/gpu/gpu_host_messages.h" |
35 #include "content/common/in_process_child_thread_params.h" | 35 #include "content/common/in_process_child_thread_params.h" |
36 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/content_browser_client.h" | 38 #include "content/public/browser/content_browser_client.h" |
| 39 #include "content/public/browser/gpu_utils.h" |
39 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
40 #include "content/public/browser/render_widget_host_view.h" | 41 #include "content/public/browser/render_widget_host_view.h" |
41 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 42 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
42 #include "content/public/common/content_client.h" | 43 #include "content/public/common/content_client.h" |
43 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" |
44 #include "content/public/common/result_codes.h" | 45 #include "content/public/common/result_codes.h" |
45 #include "content/public/common/sandbox_type.h" | 46 #include "content/public/common/sandbox_type.h" |
46 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 47 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 48 #include "gpu/command_buffer/service/gpu_preferences.h" |
47 #include "gpu/command_buffer/service/gpu_switches.h" | 49 #include "gpu/command_buffer/service/gpu_switches.h" |
48 #include "ipc/ipc_channel_handle.h" | 50 #include "ipc/ipc_channel_handle.h" |
49 #include "ipc/ipc_switches.h" | 51 #include "ipc/ipc_switches.h" |
50 #include "ipc/message_filter.h" | 52 #include "ipc/message_filter.h" |
51 #include "media/base/media_switches.h" | 53 #include "media/base/media_switches.h" |
52 #include "ui/base/ui_base_switches.h" | 54 #include "ui/base/ui_base_switches.h" |
53 #include "ui/events/latency_info.h" | 55 #include "ui/events/latency_info.h" |
54 #include "ui/gl/gl_switches.h" | 56 #include "ui/gl/gl_switches.h" |
55 | 57 |
56 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 switches::kDisableLogging, | 100 switches::kDisableLogging, |
99 switches::kDisableSeccompFilterSandbox, | 101 switches::kDisableSeccompFilterSandbox, |
100 #if defined(ENABLE_WEBRTC) | 102 #if defined(ENABLE_WEBRTC) |
101 switches::kDisableWebRtcHWEncoding, | 103 switches::kDisableWebRtcHWEncoding, |
102 #endif | 104 #endif |
103 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
104 switches::kEnableAcceleratedVpxDecode, | 106 switches::kEnableAcceleratedVpxDecode, |
105 #endif | 107 #endif |
106 switches::kEnableHeapProfiling, | 108 switches::kEnableHeapProfiling, |
107 switches::kEnableLogging, | 109 switches::kEnableLogging, |
108 switches::kEnableShareGroupAsyncTextureUpload, | |
109 #if defined(OS_ANDROID) | 110 #if defined(OS_ANDROID) |
110 switches::kEnableUnifiedMediaPipeline, | 111 switches::kEnableUnifiedMediaPipeline, |
111 #endif | 112 #endif |
112 #if defined(OS_CHROMEOS) | 113 #if defined(OS_CHROMEOS) |
113 switches::kDisableVaapiAcceleratedVideoEncode, | 114 switches::kDisableVaapiAcceleratedVideoEncode, |
114 #endif | 115 #endif |
| 116 switches::kGpuDriverBugWorkarounds, |
115 switches::kGpuStartupDialog, | 117 switches::kGpuStartupDialog, |
116 switches::kGpuSandboxAllowSysVShm, | 118 switches::kGpuSandboxAllowSysVShm, |
117 switches::kGpuSandboxFailuresFatal, | 119 switches::kGpuSandboxFailuresFatal, |
118 switches::kGpuSandboxStartEarly, | 120 switches::kGpuSandboxStartEarly, |
119 switches::kLoggingLevel, | 121 switches::kLoggingLevel, |
120 switches::kEnableLowEndDeviceMode, | 122 switches::kEnableLowEndDeviceMode, |
121 switches::kDisableLowEndDeviceMode, | 123 switches::kDisableLowEndDeviceMode, |
122 switches::kEnableMemoryBenchmarking, | 124 switches::kEnableMemoryBenchmarking, |
123 switches::kNoSandbox, | 125 switches::kNoSandbox, |
124 switches::kProfilerTiming, | 126 switches::kProfilerTiming, |
125 switches::kTestGLLib, | 127 switches::kTestGLLib, |
126 switches::kTraceConfigFile, | 128 switches::kTraceConfigFile, |
127 switches::kTraceStartup, | 129 switches::kTraceStartup, |
128 switches::kTraceToConsole, | 130 switches::kTraceToConsole, |
129 switches::kV, | 131 switches::kV, |
130 switches::kVModule, | 132 switches::kVModule, |
131 #if defined(OS_MACOSX) | 133 #if defined(OS_MACOSX) |
132 switches::kDisableRemoteCoreAnimation, | 134 switches::kDisableRemoteCoreAnimation, |
133 switches::kDisableMacOverlays, | 135 switches::kDisableMacOverlays, |
134 switches::kEnableSandboxLogging, | 136 switches::kEnableSandboxLogging, |
135 switches::kShowMacOverlayBorders, | 137 switches::kShowMacOverlayBorders, |
136 #endif | 138 #endif |
137 #if defined(USE_AURA) | |
138 switches::kUIPrioritizeInGpuProcess, | |
139 #endif | |
140 #if defined(USE_OZONE) | 139 #if defined(USE_OZONE) |
141 switches::kOzonePlatform, | 140 switches::kOzonePlatform, |
142 #endif | 141 #endif |
143 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 142 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
144 switches::kWindowDepth, | 143 switches::kWindowDepth, |
145 switches::kX11Display, | 144 switches::kX11Display, |
146 #endif | 145 #endif |
147 }; | 146 }; |
148 | 147 |
149 enum GPUProcessLifetimeEvent { | 148 enum GPUProcessLifetimeEvent { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 return false; | 538 return false; |
540 | 539 |
541 if (!SetupMojo()) | 540 if (!SetupMojo()) |
542 return false; | 541 return false; |
543 | 542 |
544 if (in_process_) { | 543 if (in_process_) { |
545 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 544 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
546 DCHECK(g_gpu_main_thread_factory); | 545 DCHECK(g_gpu_main_thread_factory); |
547 in_process_gpu_thread_.reset( | 546 in_process_gpu_thread_.reset( |
548 g_gpu_main_thread_factory(InProcessChildThreadParams( | 547 g_gpu_main_thread_factory(InProcessChildThreadParams( |
549 channel_id, base::MessageLoop::current()->task_runner()))); | 548 channel_id, base::MessageLoop::current()->task_runner()), |
| 549 GetGpuPreferencesFromCommandLine())); |
550 base::Thread::Options options; | 550 base::Thread::Options options; |
551 #if defined(OS_WIN) | 551 #if defined(OS_WIN) |
552 // WGL needs to create its own window and pump messages on it. | 552 // WGL needs to create its own window and pump messages on it. |
553 options.message_loop_type = base::MessageLoop::TYPE_UI; | 553 options.message_loop_type = base::MessageLoop::TYPE_UI; |
554 #endif | 554 #endif |
555 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 555 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
556 options.priority = base::ThreadPriority::DISPLAY; | 556 options.priority = base::ThreadPriority::DISPLAY; |
557 #endif | 557 #endif |
558 in_process_gpu_thread_->StartWithOptions(options); | 558 in_process_gpu_thread_->StartWithOptions(options); |
559 | 559 |
560 OnProcessLaunched(); // Fake a callback that the process is ready. | 560 OnProcessLaunched(); // Fake a callback that the process is ready. |
561 } else if (!LaunchGpuProcess(channel_id)) { | 561 } else if (!LaunchGpuProcess(channel_id)) { |
562 return false; | 562 return false; |
563 } | 563 } |
564 | 564 |
565 if (!Send(new GpuMsg_Initialize())) | 565 if (!Send(new GpuMsg_Initialize(GetGpuPreferencesFromCommandLine()))) |
566 return false; | 566 return false; |
567 | 567 |
568 return true; | 568 return true; |
569 } | 569 } |
570 | 570 |
571 bool GpuProcessHost::SetupMojo() { | 571 bool GpuProcessHost::SetupMojo() { |
572 DCHECK(!mojo_application_host_); | 572 DCHECK(!mojo_application_host_); |
573 mojo_application_host_.reset(new MojoApplicationHost); | 573 mojo_application_host_.reset(new MojoApplicationHost); |
574 return mojo_application_host_->Init(); | 574 return mojo_application_host_->Init(); |
575 } | 575 } |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 975 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
976 | 976 |
977 #if defined(OS_WIN) | 977 #if defined(OS_WIN) |
978 if (GetContentClient()->browser()->ShouldUseWindowsPrefetchArgument()) | 978 if (GetContentClient()->browser()->ShouldUseWindowsPrefetchArgument()) |
979 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); | 979 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); |
980 #endif // defined(OS_WIN) | 980 #endif // defined(OS_WIN) |
981 | 981 |
982 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) | 982 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) |
983 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); | 983 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); |
984 | 984 |
| 985 // TODO(penghuang): Replace all GPU related switches with GpuPreferences. |
| 986 // https://crbug.com/590825 |
985 // If you want a browser command-line switch passed to the GPU process | 987 // If you want a browser command-line switch passed to the GPU process |
986 // you need to add it to |kSwitchNames| at the beginning of this file. | 988 // you need to add it to |kSwitchNames| at the beginning of this file. |
987 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, | 989 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
988 arraysize(kSwitchNames)); | 990 arraysize(kSwitchNames)); |
989 cmd_line->CopySwitchesFrom( | 991 cmd_line->CopySwitchesFrom( |
990 browser_command_line, switches::kGpuSwitches, switches::kNumGpuSwitches); | |
991 cmd_line->CopySwitchesFrom( | |
992 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, | 992 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, |
993 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); | 993 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); |
994 | 994 |
995 GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 995 GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
996 cmd_line, process_->GetData().id); | 996 cmd_line, process_->GetData().id); |
997 | 997 |
998 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line); | 998 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line); |
999 | 999 |
1000 if (cmd_line->HasSwitch(switches::kUseGL)) { | 1000 if (cmd_line->HasSwitch(switches::kUseGL)) { |
1001 swiftshader_rendering_ = | 1001 swiftshader_rendering_ = |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1156 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1157 ClientIdToShaderCacheMap::iterator iter = | 1157 ClientIdToShaderCacheMap::iterator iter = |
1158 client_id_to_shader_cache_.find(client_id); | 1158 client_id_to_shader_cache_.find(client_id); |
1159 // If the cache doesn't exist then this is an off the record profile. | 1159 // If the cache doesn't exist then this is an off the record profile. |
1160 if (iter == client_id_to_shader_cache_.end()) | 1160 if (iter == client_id_to_shader_cache_.end()) |
1161 return; | 1161 return; |
1162 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1162 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1163 } | 1163 } |
1164 | 1164 |
1165 } // namespace content | 1165 } // namespace content |
OLD | NEW |