| 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #if defined(USE_X11) | 41 #if defined(USE_X11) |
| 42 #include "ui/base/x/x11_util.h" | 42 #include "ui/base/x/x11_util.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 #if defined(OS_LINUX) | 45 #if defined(OS_LINUX) |
| 46 #include "content/public/common/sandbox_init.h" | 46 #include "content/public/common/sandbox_init.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 void WarmUpSandbox(const content::GPUInfo&, bool); | 50 void WarmUpSandbox(const content::GPUInfo&, bool); |
| 51 #if defined(OS_LINUX) |
| 51 void CollectGraphicsInfo(content::GPUInfo*); | 52 void CollectGraphicsInfo(content::GPUInfo*); |
| 53 #endif |
| 52 } | 54 } |
| 53 | 55 |
| 54 // Main function for starting the Gpu process. | 56 // Main function for starting the Gpu process. |
| 55 int GpuMain(const content::MainFunctionParams& parameters) { | 57 int GpuMain(const content::MainFunctionParams& parameters) { |
| 56 TRACE_EVENT0("gpu", "GpuMain"); | 58 TRACE_EVENT0("gpu", "GpuMain"); |
| 57 | 59 |
| 58 base::Time start_time = base::Time::Now(); | 60 base::Time start_time = base::Time::Now(); |
| 59 | 61 |
| 60 const CommandLine& command_line = parameters.command_line; | 62 const CommandLine& command_line = parameters.command_line; |
| 61 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { | 63 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 main_message_loop.Run(); | 221 main_message_loop.Run(); |
| 220 } | 222 } |
| 221 | 223 |
| 222 child_thread->StopWatchdog(); | 224 child_thread->StopWatchdog(); |
| 223 | 225 |
| 224 return 0; | 226 return 0; |
| 225 } | 227 } |
| 226 | 228 |
| 227 namespace { | 229 namespace { |
| 228 | 230 |
| 231 #if defined(OS_LINUX) |
| 229 void CreateDummyGlContext() { | 232 void CreateDummyGlContext() { |
| 230 scoped_refptr<gfx::GLSurface> surface( | 233 scoped_refptr<gfx::GLSurface> surface( |
| 231 gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1))); | 234 gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1))); |
| 232 if (!surface.get()) { | 235 if (!surface.get()) { |
| 233 VLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed"; | 236 VLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed"; |
| 234 return; | 237 return; |
| 235 } | 238 } |
| 236 | 239 |
| 237 // On Linux, this is needed to make sure /dev/nvidiactl has | 240 // On Linux, this is needed to make sure /dev/nvidiactl has |
| 238 // been opened and its descriptor cached. | 241 // been opened and its descriptor cached. |
| 239 scoped_refptr<gfx::GLContext> context( | 242 scoped_refptr<gfx::GLContext> context( |
| 240 gfx::GLContext::CreateGLContext(NULL, | 243 gfx::GLContext::CreateGLContext(NULL, |
| 241 surface, | 244 surface, |
| 242 gfx::PreferDiscreteGpu)); | 245 gfx::PreferDiscreteGpu)); |
| 243 if (!context.get()) { | 246 if (!context.get()) { |
| 244 VLOG(1) << "gfx::GLContext::CreateGLContext failed"; | 247 VLOG(1) << "gfx::GLContext::CreateGLContext failed"; |
| 245 return; | 248 return; |
| 246 } | 249 } |
| 247 | 250 |
| 248 // Similarly, this is needed for /dev/nvidia0. | 251 // Similarly, this is needed for /dev/nvidia0. |
| 249 if (context->MakeCurrent(surface)) { | 252 if (context->MakeCurrent(surface)) { |
| 250 context->ReleaseCurrent(surface.get()); | 253 context->ReleaseCurrent(surface.get()); |
| 251 } else { | 254 } else { |
| 252 VLOG(1) << "gfx::GLContext::MakeCurrent failed"; | 255 VLOG(1) << "gfx::GLContext::MakeCurrent failed"; |
| 253 } | 256 } |
| 254 } | 257 } |
| 258 #endif |
| 255 | 259 |
| 256 void WarmUpSandbox(const content::GPUInfo& gpu_info, | 260 void WarmUpSandbox(const content::GPUInfo& gpu_info, |
| 257 bool should_initialize_gl_context) { | 261 bool should_initialize_gl_context) { |
| 258 { | 262 { |
| 259 TRACE_EVENT0("gpu", "Warm up rand"); | 263 TRACE_EVENT0("gpu", "Warm up rand"); |
| 260 // Warm up the random subsystem, which needs to be done pre-sandbox on all | 264 // Warm up the random subsystem, which needs to be done pre-sandbox on all |
| 261 // platforms. | 265 // platforms. |
| 262 (void) base::RandUint64(); | 266 (void) base::RandUint64(); |
| 263 } | 267 } |
| 264 { | 268 { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 305 } |
| 302 | 306 |
| 303 { | 307 { |
| 304 TRACE_EVENT0("gpu", "Initialize DXVA"); | 308 TRACE_EVENT0("gpu", "Initialize DXVA"); |
| 305 // Initialize H/W video decoding stuff which fails in the sandbox. | 309 // Initialize H/W video decoding stuff which fails in the sandbox. |
| 306 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | 310 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
| 307 } | 311 } |
| 308 #endif | 312 #endif |
| 309 } | 313 } |
| 310 | 314 |
| 315 #if defined(OS_LINUX) |
| 311 void CollectGraphicsInfo(content::GPUInfo* gpu_info) { | 316 void CollectGraphicsInfo(content::GPUInfo* gpu_info) { |
| 312 if (!gpu_info_collector::CollectGraphicsInfo(gpu_info)) | 317 if (!gpu_info_collector::CollectGraphicsInfo(gpu_info)) |
| 313 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; | 318 VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |
| 314 content::GetContentClient()->SetGpuInfo(*gpu_info); | 319 content::GetContentClient()->SetGpuInfo(*gpu_info); |
| 315 } | 320 } |
| 321 #endif |
| 316 | 322 |
| 317 } // namespace. | 323 } // namespace. |
| 318 | 324 |
| OLD | NEW |