| 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 543 |
| 544 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); | 544 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); |
| 545 | 545 |
| 546 std::string channel_id = process_->GetHost()->CreateChannel(); | 546 std::string channel_id = process_->GetHost()->CreateChannel(); |
| 547 if (channel_id.empty()) | 547 if (channel_id.empty()) |
| 548 return false; | 548 return false; |
| 549 | 549 |
| 550 if (!SetupMojo()) | 550 if (!SetupMojo()) |
| 551 return false; | 551 return false; |
| 552 | 552 |
| 553 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); |
| 553 if (in_process_) { | 554 if (in_process_) { |
| 554 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 555 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 555 DCHECK(g_gpu_main_thread_factory); | 556 DCHECK(g_gpu_main_thread_factory); |
| 556 in_process_gpu_thread_.reset( | 557 in_process_gpu_thread_.reset( |
| 557 g_gpu_main_thread_factory(InProcessChildThreadParams( | 558 g_gpu_main_thread_factory(InProcessChildThreadParams( |
| 558 channel_id, base::MessageLoop::current()->task_runner()), | 559 channel_id, base::MessageLoop::current()->task_runner()), |
| 559 GetGpuPreferencesFromCommandLine())); | 560 gpu_preferences)); |
| 560 base::Thread::Options options; | 561 base::Thread::Options options; |
| 561 #if defined(OS_WIN) | 562 #if defined(OS_WIN) |
| 562 // WGL needs to create its own window and pump messages on it. | 563 // WGL needs to create its own window and pump messages on it. |
| 563 options.message_loop_type = base::MessageLoop::TYPE_UI; | 564 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 564 #endif | 565 #endif |
| 565 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 566 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 566 options.priority = base::ThreadPriority::DISPLAY; | 567 options.priority = base::ThreadPriority::DISPLAY; |
| 567 #endif | 568 #endif |
| 568 in_process_gpu_thread_->StartWithOptions(options); | 569 in_process_gpu_thread_->StartWithOptions(options); |
| 569 | 570 |
| 570 OnProcessLaunched(); // Fake a callback that the process is ready. | 571 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 571 } else if (!LaunchGpuProcess(channel_id)) { | 572 } else if (!LaunchGpuProcess(channel_id, &gpu_preferences)) { |
| 572 return false; | 573 return false; |
| 573 } | 574 } |
| 574 | 575 |
| 575 if (!Send(new GpuMsg_Initialize(GetGpuPreferencesFromCommandLine()))) | 576 if (!Send(new GpuMsg_Initialize(gpu_preferences))) |
| 576 return false; | 577 return false; |
| 577 | 578 |
| 578 return true; | 579 return true; |
| 579 } | 580 } |
| 580 | 581 |
| 581 bool GpuProcessHost::SetupMojo() { | 582 bool GpuProcessHost::SetupMojo() { |
| 582 DCHECK(!mojo_application_host_); | 583 DCHECK(!mojo_application_host_); |
| 583 mojo_application_host_.reset(new MojoApplicationHost); | 584 mojo_application_host_.reset(new MojoApplicationHost); |
| 584 return mojo_application_host_->Init(); | 585 return mojo_application_host_->Init(); |
| 585 } | 586 } |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 if (g_gpu_process_hosts[kind_] == this) | 943 if (g_gpu_process_hosts[kind_] == this) |
| 943 g_gpu_process_hosts[kind_] = NULL; | 944 g_gpu_process_hosts[kind_] = NULL; |
| 944 | 945 |
| 945 process_->ForceShutdown(); | 946 process_->ForceShutdown(); |
| 946 } | 947 } |
| 947 | 948 |
| 948 void GpuProcessHost::StopGpuProcess() { | 949 void GpuProcessHost::StopGpuProcess() { |
| 949 Send(new GpuMsg_Finalize()); | 950 Send(new GpuMsg_Finalize()); |
| 950 } | 951 } |
| 951 | 952 |
| 952 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { | 953 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id, |
| 954 gpu::GpuPreferences* gpu_preferences) { |
| 953 if (!(gpu_enabled_ && | 955 if (!(gpu_enabled_ && |
| 954 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) && | 956 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) && |
| 955 !hardware_gpu_enabled_) { | 957 !hardware_gpu_enabled_) { |
| 956 SendOutstandingReplies(); | 958 SendOutstandingReplies(); |
| 957 return false; | 959 return false; |
| 958 } | 960 } |
| 959 | 961 |
| 960 const base::CommandLine& browser_command_line = | 962 const base::CommandLine& browser_command_line = |
| 961 *base::CommandLine::ForCurrentProcess(); | 963 *base::CommandLine::ForCurrentProcess(); |
| 962 | 964 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 // you need to add it to |kSwitchNames| at the beginning of this file. | 1002 // you need to add it to |kSwitchNames| at the beginning of this file. |
| 1001 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, | 1003 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 1002 arraysize(kSwitchNames)); | 1004 arraysize(kSwitchNames)); |
| 1003 cmd_line->CopySwitchesFrom( | 1005 cmd_line->CopySwitchesFrom( |
| 1004 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, | 1006 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, |
| 1005 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); | 1007 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); |
| 1006 | 1008 |
| 1007 GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 1009 GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
| 1008 cmd_line, process_->GetData().id); | 1010 cmd_line, process_->GetData().id); |
| 1009 | 1011 |
| 1010 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line); | 1012 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line, |
| 1011 | 1013 gpu_preferences); |
| 1012 if (cmd_line->HasSwitch(switches::kUseGL)) { | 1014 if (cmd_line->HasSwitch(switches::kUseGL)) { |
| 1013 swiftshader_rendering_ = | 1015 swiftshader_rendering_ = |
| 1014 (cmd_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); | 1016 (cmd_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); |
| 1015 } | 1017 } |
| 1016 | 1018 |
| 1017 UMA_HISTOGRAM_BOOLEAN("GPU.GPU.GPUProcessSoftwareRendering", | 1019 UMA_HISTOGRAM_BOOLEAN("GPU.GPU.GPUProcessSoftwareRendering", |
| 1018 swiftshader_rendering_); | 1020 swiftshader_rendering_); |
| 1019 | 1021 |
| 1020 // If specified, prepend a launcher program to the command line. | 1022 // If specified, prepend a launcher program to the command line. |
| 1021 if (!gpu_launcher.empty()) | 1023 if (!gpu_launcher.empty()) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1170 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1169 ClientIdToShaderCacheMap::iterator iter = | 1171 ClientIdToShaderCacheMap::iterator iter = |
| 1170 client_id_to_shader_cache_.find(client_id); | 1172 client_id_to_shader_cache_.find(client_id); |
| 1171 // If the cache doesn't exist then this is an off the record profile. | 1173 // If the cache doesn't exist then this is an off the record profile. |
| 1172 if (iter == client_id_to_shader_cache_.end()) | 1174 if (iter == client_id_to_shader_cache_.end()) |
| 1173 return; | 1175 return; |
| 1174 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1176 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1175 } | 1177 } |
| 1176 | 1178 |
| 1177 } // namespace content | 1179 } // namespace content |
| OLD | NEW |