| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 switches::kDisableLogging, | 99 switches::kDisableLogging, |
| 98 switches::kDisableSeccompFilterSandbox, | 100 switches::kDisableSeccompFilterSandbox, |
| 99 #if defined(ENABLE_WEBRTC) | 101 #if defined(ENABLE_WEBRTC) |
| 100 switches::kDisableWebRtcHWEncoding, | 102 switches::kDisableWebRtcHWEncoding, |
| 101 #endif | 103 #endif |
| 102 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
| 103 switches::kEnableAcceleratedVpxDecode, | 105 switches::kEnableAcceleratedVpxDecode, |
| 104 #endif | 106 #endif |
| 105 switches::kEnableHeapProfiling, | 107 switches::kEnableHeapProfiling, |
| 106 switches::kEnableLogging, | 108 switches::kEnableLogging, |
| 107 switches::kEnableShareGroupAsyncTextureUpload, | |
| 108 #if defined(OS_ANDROID) | 109 #if defined(OS_ANDROID) |
| 109 switches::kEnableUnifiedMediaPipeline, | 110 switches::kEnableUnifiedMediaPipeline, |
| 110 #endif | 111 #endif |
| 111 #if defined(OS_CHROMEOS) | 112 #if defined(OS_CHROMEOS) |
| 112 switches::kDisableVaapiAcceleratedVideoEncode, | 113 switches::kDisableVaapiAcceleratedVideoEncode, |
| 113 #endif | 114 #endif |
| 114 switches::kGpuStartupDialog, | 115 switches::kGpuStartupDialog, |
| 115 switches::kGpuSandboxAllowSysVShm, | 116 switches::kGpuSandboxAllowSysVShm, |
| 116 switches::kGpuSandboxFailuresFatal, | 117 switches::kGpuSandboxFailuresFatal, |
| 117 switches::kGpuSandboxStartEarly, | 118 switches::kGpuSandboxStartEarly, |
| 118 switches::kLoggingLevel, | 119 switches::kLoggingLevel, |
| 119 switches::kEnableLowEndDeviceMode, | 120 switches::kEnableLowEndDeviceMode, |
| 120 switches::kDisableLowEndDeviceMode, | 121 switches::kDisableLowEndDeviceMode, |
| 121 switches::kEnableMemoryBenchmarking, | 122 switches::kEnableMemoryBenchmarking, |
| 122 switches::kNoSandbox, | 123 switches::kNoSandbox, |
| 123 switches::kProfilerTiming, | 124 switches::kProfilerTiming, |
| 124 switches::kTestGLLib, | 125 switches::kTestGLLib, |
| 125 switches::kTraceConfigFile, | 126 switches::kTraceConfigFile, |
| 126 switches::kTraceStartup, | 127 switches::kTraceStartup, |
| 127 switches::kTraceToConsole, | 128 switches::kTraceToConsole, |
| 128 switches::kV, | 129 switches::kV, |
| 129 switches::kVModule, | 130 switches::kVModule, |
| 130 #if defined(OS_MACOSX) | 131 #if defined(OS_MACOSX) |
| 131 switches::kDisableRemoteCoreAnimation, | 132 switches::kDisableRemoteCoreAnimation, |
| 132 switches::kDisableMacOverlays, | 133 switches::kDisableMacOverlays, |
| 133 switches::kEnableSandboxLogging, | 134 switches::kEnableSandboxLogging, |
| 134 switches::kShowMacOverlayBorders, | 135 switches::kShowMacOverlayBorders, |
| 135 #endif | 136 #endif |
| 136 #if defined(USE_AURA) | |
| 137 switches::kUIPrioritizeInGpuProcess, | |
| 138 #endif | |
| 139 #if defined(USE_OZONE) | 137 #if defined(USE_OZONE) |
| 140 switches::kOzonePlatform, | 138 switches::kOzonePlatform, |
| 141 #endif | 139 #endif |
| 142 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 140 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 143 switches::kWindowDepth, | 141 switches::kWindowDepth, |
| 144 switches::kX11Display, | 142 switches::kX11Display, |
| 145 #endif | 143 #endif |
| 146 }; | 144 }; |
| 147 | 145 |
| 148 enum GPUProcessLifetimeEvent { | 146 enum GPUProcessLifetimeEvent { |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 return false; | 536 return false; |
| 539 | 537 |
| 540 if (!SetupMojo()) | 538 if (!SetupMojo()) |
| 541 return false; | 539 return false; |
| 542 | 540 |
| 543 if (in_process_) { | 541 if (in_process_) { |
| 544 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 542 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 545 DCHECK(g_gpu_main_thread_factory); | 543 DCHECK(g_gpu_main_thread_factory); |
| 546 in_process_gpu_thread_.reset( | 544 in_process_gpu_thread_.reset( |
| 547 g_gpu_main_thread_factory(InProcessChildThreadParams( | 545 g_gpu_main_thread_factory(InProcessChildThreadParams( |
| 548 channel_id, base::MessageLoop::current()->task_runner()))); | 546 channel_id, base::MessageLoop::current()->task_runner()), |
| 547 GetGpuPreferences())); |
| 549 base::Thread::Options options; | 548 base::Thread::Options options; |
| 550 #if defined(OS_WIN) | 549 #if defined(OS_WIN) |
| 551 // WGL needs to create its own window and pump messages on it. | 550 // WGL needs to create its own window and pump messages on it. |
| 552 options.message_loop_type = base::MessageLoop::TYPE_UI; | 551 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 553 #endif | 552 #endif |
| 554 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 553 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 555 options.priority = base::ThreadPriority::DISPLAY; | 554 options.priority = base::ThreadPriority::DISPLAY; |
| 556 #endif | 555 #endif |
| 557 in_process_gpu_thread_->StartWithOptions(options); | 556 in_process_gpu_thread_->StartWithOptions(options); |
| 558 | 557 |
| 559 OnProcessLaunched(); // Fake a callback that the process is ready. | 558 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 560 } else if (!LaunchGpuProcess(channel_id)) { | 559 } else if (!LaunchGpuProcess(channel_id)) { |
| 561 return false; | 560 return false; |
| 562 } | 561 } |
| 563 | 562 |
| 564 if (!Send(new GpuMsg_Initialize())) | 563 if (!Send(new GpuMsg_Initialize(GetGpuPreferences()))) |
| 565 return false; | 564 return false; |
| 566 | 565 |
| 567 return true; | 566 return true; |
| 568 } | 567 } |
| 569 | 568 |
| 570 bool GpuProcessHost::SetupMojo() { | 569 bool GpuProcessHost::SetupMojo() { |
| 571 DCHECK(!mojo_application_host_); | 570 DCHECK(!mojo_application_host_); |
| 572 mojo_application_host_.reset(new MojoApplicationHost); | 571 mojo_application_host_.reset(new MojoApplicationHost); |
| 573 return mojo_application_host_->Init(); | 572 return mojo_application_host_->Init(); |
| 574 } | 573 } |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 969 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 971 | 970 |
| 972 #if defined(OS_WIN) | 971 #if defined(OS_WIN) |
| 973 if (GetContentClient()->browser()->ShouldUseWindowsPrefetchArgument()) | 972 if (GetContentClient()->browser()->ShouldUseWindowsPrefetchArgument()) |
| 974 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); | 973 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); |
| 975 #endif // defined(OS_WIN) | 974 #endif // defined(OS_WIN) |
| 976 | 975 |
| 977 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) | 976 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) |
| 978 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); | 977 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); |
| 979 | 978 |
| 979 // TODO(penghuang): Replace all GPU related switches with GpuPreferences. |
| 980 // https://crbug.com/590825 |
| 980 // If you want a browser command-line switch passed to the GPU process | 981 // If you want a browser command-line switch passed to the GPU process |
| 981 // you need to add it to |kSwitchNames| at the beginning of this file. | 982 // you need to add it to |kSwitchNames| at the beginning of this file. |
| 982 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, | 983 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 983 arraysize(kSwitchNames)); | 984 arraysize(kSwitchNames)); |
| 984 cmd_line->CopySwitchesFrom( | 985 cmd_line->CopySwitchesFrom( |
| 985 browser_command_line, switches::kGpuSwitches, switches::kNumGpuSwitches); | |
| 986 cmd_line->CopySwitchesFrom( | |
| 987 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, | 986 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, |
| 988 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); | 987 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); |
| 989 | 988 |
| 990 GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 989 GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
| 991 cmd_line, process_->GetData().id); | 990 cmd_line, process_->GetData().id); |
| 992 | 991 |
| 993 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line); | 992 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line); |
| 994 | 993 |
| 995 if (cmd_line->HasSwitch(switches::kUseGL)) { | 994 if (cmd_line->HasSwitch(switches::kUseGL)) { |
| 996 swiftshader_rendering_ = | 995 swiftshader_rendering_ = |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1150 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1152 ClientIdToShaderCacheMap::iterator iter = | 1151 ClientIdToShaderCacheMap::iterator iter = |
| 1153 client_id_to_shader_cache_.find(client_id); | 1152 client_id_to_shader_cache_.find(client_id); |
| 1154 // If the cache doesn't exist then this is an off the record profile. | 1153 // If the cache doesn't exist then this is an off the record profile. |
| 1155 if (iter == client_id_to_shader_cache_.end()) | 1154 if (iter == client_id_to_shader_cache_.end()) |
| 1156 return; | 1155 return; |
| 1157 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1156 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1158 } | 1157 } |
| 1159 | 1158 |
| 1160 } // namespace content | 1159 } // namespace content |
| OLD | NEW |