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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 bool CanAccessNvidiaDeviceFile(); | 112 bool CanAccessNvidiaDeviceFile(); |
113 #endif | 113 #endif |
114 bool StartSandboxLinux(const gpu::GPUInfo&, GpuWatchdogThread*, bool); | 114 bool StartSandboxLinux(const gpu::GPUInfo&, GpuWatchdogThread*, bool); |
115 #elif defined(OS_WIN) | 115 #elif defined(OS_WIN) |
116 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); | 116 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); |
117 #endif | 117 #endif |
118 | 118 |
119 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = | 119 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = |
120 LAZY_INSTANCE_INITIALIZER; | 120 LAZY_INSTANCE_INITIALIZER; |
121 | 121 |
122 bool GpuProcessLogMessageHandler(int severity, | 122 void GpuProcessLogMessageListener(int severity, |
123 const char* file, int line, | 123 const char* file, int line, |
124 size_t message_start, | 124 size_t message_start, |
125 const std::string& str) { | 125 const std::string& str) { |
126 std::string header = str.substr(0, message_start); | 126 std::string header = str.substr(0, message_start); |
127 std::string message = str.substr(message_start); | 127 std::string message = str.substr(message_start); |
128 deferred_messages.Get().push( | 128 deferred_messages.Get().push( |
129 new GpuHostMsg_OnLogMessage(severity, header, message)); | 129 new GpuHostMsg_OnLogMessage(severity, header, message)); |
130 return false; | |
131 } | 130 } |
132 | 131 |
133 } // namespace anonymous | 132 } // namespace anonymous |
134 | 133 |
135 // Main function for starting the Gpu process. | 134 // Main function for starting the Gpu process. |
136 int GpuMain(const MainFunctionParams& parameters) { | 135 int GpuMain(const MainFunctionParams& parameters) { |
137 TRACE_EVENT0("gpu", "GpuMain"); | 136 TRACE_EVENT0("gpu", "GpuMain"); |
138 base::trace_event::TraceLog::GetInstance()->SetProcessName("GPU Process"); | 137 base::trace_event::TraceLog::GetInstance()->SetProcessName("GPU Process"); |
139 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( | 138 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( |
140 kTraceEventGpuProcessSortIndex); | 139 kTraceEventGpuProcessSortIndex); |
(...skipping 17 matching lines...) Expand all Loading... |
158 | 157 |
159 #if !defined(OS_CHROMEOS) | 158 #if !defined(OS_CHROMEOS) |
160 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 159 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
161 switches::kWindowDepth)); | 160 switches::kWindowDepth)); |
162 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 161 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
163 switches::kX11VisualID)); | 162 switches::kX11VisualID)); |
164 #endif | 163 #endif |
165 | 164 |
166 #endif | 165 #endif |
167 | 166 |
168 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 167 logging::AddLogMessageListener(GpuProcessLogMessageListener); |
169 | 168 |
170 if (command_line.HasSwitch(switches::kSupportsDualGpus)) { | 169 if (command_line.HasSwitch(switches::kSupportsDualGpus)) { |
171 std::string types = command_line.GetSwitchValueASCII( | 170 std::string types = command_line.GetSwitchValueASCII( |
172 switches::kGpuDriverBugWorkarounds); | 171 switches::kGpuDriverBugWorkarounds); |
173 std::set<int> workarounds; | 172 std::set<int> workarounds; |
174 gpu::StringToFeatureSet(types, &workarounds); | 173 gpu::StringToFeatureSet(types, &workarounds); |
175 if (workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) | 174 if (workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) |
176 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); | 175 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); |
177 else if (workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) | 176 else if (workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) |
178 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); | 177 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 376 } |
378 #elif defined(OS_WIN) | 377 #elif defined(OS_WIN) |
379 gpu_info.sandboxed = StartSandboxWindows(parameters.sandbox_info); | 378 gpu_info.sandboxed = StartSandboxWindows(parameters.sandbox_info); |
380 #elif defined(OS_MACOSX) | 379 #elif defined(OS_MACOSX) |
381 gpu_info.sandboxed = Sandbox::SandboxIsCurrentlyActive(); | 380 gpu_info.sandboxed = Sandbox::SandboxIsCurrentlyActive(); |
382 #endif | 381 #endif |
383 } else { | 382 } else { |
384 dead_on_arrival = true; | 383 dead_on_arrival = true; |
385 } | 384 } |
386 | 385 |
387 logging::SetLogMessageHandler(NULL); | 386 logging::RemoveLogMessageListener(GpuProcessLogMessageListener); |
388 | 387 |
389 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; | 388 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; |
390 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) | 389 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) |
391 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); | 390 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); |
392 | 391 |
393 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; | 392 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; |
394 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 393 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
395 io_thread_priority = base::ThreadPriority::DISPLAY; | 394 io_thread_priority = base::ThreadPriority::DISPLAY; |
396 #endif | 395 #endif |
397 | 396 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 return true; | 618 return true; |
620 } | 619 } |
621 | 620 |
622 return false; | 621 return false; |
623 } | 622 } |
624 #endif // defined(OS_WIN) | 623 #endif // defined(OS_WIN) |
625 | 624 |
626 } // namespace. | 625 } // namespace. |
627 | 626 |
628 } // namespace content | 627 } // namespace content |
OLD | NEW |