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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 #endif | 289 #endif |
290 if (command_line.HasSwitch(switches::kInProcessGPU)) { | 290 if (command_line.HasSwitch(switches::kInProcessGPU)) { |
291 // With in-process GPU, gl::init::InitializeGLOneOff() is called from | 291 // With in-process GPU, gl::init::InitializeGLOneOff() is called from |
292 // GpuChildThread before getting here. | 292 // GpuChildThread before getting here. |
293 gl_already_initialized = true; | 293 gl_already_initialized = true; |
294 } | 294 } |
295 | 295 |
296 // Load and initialize the GL implementation and locate the GL entry points. | 296 // Load and initialize the GL implementation and locate the GL entry points. |
297 bool gl_initialized = | 297 bool gl_initialized = |
298 gl_already_initialized | 298 gl_already_initialized |
299 ? gfx::GetGLImplementation() != gfx::kGLImplementationNone | 299 ? gl::GetGLImplementation() != gl::kGLImplementationNone |
300 : gl::init::InitializeGLOneOff(); | 300 : gl::init::InitializeGLOneOff(); |
301 if (gl_initialized) { | 301 if (gl_initialized) { |
302 // We need to collect GL strings (VENDOR, RENDERER) for blacklisting | 302 // We need to collect GL strings (VENDOR, RENDERER) for blacklisting |
303 // purposes. However, on Mac we don't actually use them. As documented in | 303 // purposes. However, on Mac we don't actually use them. As documented in |
304 // crbug.com/222934, due to some driver issues, glGetString could take | 304 // crbug.com/222934, due to some driver issues, glGetString could take |
305 // multiple seconds to finish, which in turn cause the GPU process to | 305 // multiple seconds to finish, which in turn cause the GPU process to |
306 // crash. | 306 // crash. |
307 // By skipping the following code on Mac, we don't really lose anything, | 307 // By skipping the following code on Mac, we don't really lose anything, |
308 // because the basic GPU information is passed down from browser process | 308 // because the basic GPU information is passed down from browser process |
309 // and we already registered them through SetGpuInfo() above. | 309 // and we already registered them through SetGpuInfo() above. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 if (enable_watchdog && delayed_watchdog_enable) { | 353 if (enable_watchdog && delayed_watchdog_enable) { |
354 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); | 354 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); |
355 base::Thread::Options options; | 355 base::Thread::Options options; |
356 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 356 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
357 watchdog_thread->StartWithOptions(options); | 357 watchdog_thread->StartWithOptions(options); |
358 } | 358 } |
359 | 359 |
360 // OSMesa is expected to run very slowly, so disable the watchdog in that | 360 // OSMesa is expected to run very slowly, so disable the watchdog in that |
361 // case. | 361 // case. |
362 if (enable_watchdog && | 362 if (enable_watchdog && |
363 gfx::GetGLImplementation() == gfx::kGLImplementationOSMesaGL) { | 363 gl::GetGLImplementation() == gl::kGLImplementationOSMesaGL) { |
364 watchdog_thread->Stop(); | 364 watchdog_thread->Stop(); |
365 watchdog_thread = NULL; | 365 watchdog_thread = NULL; |
366 } | 366 } |
367 | 367 |
368 #if defined(OS_LINUX) | 368 #if defined(OS_LINUX) |
369 should_initialize_gl_context = !initialized_gl_context && | 369 should_initialize_gl_context = !initialized_gl_context && |
370 !dead_on_arrival; | 370 !dead_on_arrival; |
371 | 371 |
372 if (!initialized_sandbox) { | 372 if (!initialized_sandbox) { |
373 gpu_info.sandboxed = StartSandboxLinux(gpu_info, watchdog_thread.get(), | 373 gpu_info.sandboxed = StartSandboxLinux(gpu_info, watchdog_thread.get(), |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 base::ThreadRestrictions::AssertIOAllowed(); | 523 base::ThreadRestrictions::AssertIOAllowed(); |
524 if (access("/dev/nvidiactl", R_OK) != 0) { | 524 if (access("/dev/nvidiactl", R_OK) != 0) { |
525 DVLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; | 525 DVLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; |
526 res = false; | 526 res = false; |
527 } | 527 } |
528 return res; | 528 return res; |
529 } | 529 } |
530 #endif | 530 #endif |
531 | 531 |
532 void CreateDummyGlContext() { | 532 void CreateDummyGlContext() { |
533 scoped_refptr<gfx::GLSurface> surface( | 533 scoped_refptr<gl::GLSurface> surface( |
534 gl::init::CreateOffscreenGLSurface(gfx::Size())); | 534 gl::init::CreateOffscreenGLSurface(gfx::Size())); |
535 if (!surface.get()) { | 535 if (!surface.get()) { |
536 DVLOG(1) << "gl::init::CreateOffscreenGLSurface failed"; | 536 DVLOG(1) << "gl::init::CreateOffscreenGLSurface failed"; |
537 return; | 537 return; |
538 } | 538 } |
539 | 539 |
540 // On Linux, this is needed to make sure /dev/nvidiactl has | 540 // On Linux, this is needed to make sure /dev/nvidiactl has |
541 // been opened and its descriptor cached. | 541 // been opened and its descriptor cached. |
542 scoped_refptr<gfx::GLContext> context( | 542 scoped_refptr<gl::GLContext> context( |
543 gl::init::CreateGLContext(NULL, surface.get(), gfx::PreferDiscreteGpu)); | 543 gl::init::CreateGLContext(NULL, surface.get(), gl::PreferDiscreteGpu)); |
544 if (!context.get()) { | 544 if (!context.get()) { |
545 DVLOG(1) << "gl::init::CreateGLContext failed"; | 545 DVLOG(1) << "gl::init::CreateGLContext failed"; |
546 return; | 546 return; |
547 } | 547 } |
548 | 548 |
549 // Similarly, this is needed for /dev/nvidia0. | 549 // Similarly, this is needed for /dev/nvidia0. |
550 if (context->MakeCurrent(surface.get())) { | 550 if (context->MakeCurrent(surface.get())) { |
551 context->ReleaseCurrent(surface.get()); | 551 context->ReleaseCurrent(surface.get()); |
552 } else { | 552 } else { |
553 DVLOG(1) << "gfx::GLContext::MakeCurrent failed"; | 553 DVLOG(1) << "gl::GLContext::MakeCurrent failed"; |
554 } | 554 } |
555 } | 555 } |
556 | 556 |
557 void WarmUpSandboxNvidia(const gpu::GPUInfo& gpu_info, | 557 void WarmUpSandboxNvidia(const gpu::GPUInfo& gpu_info, |
558 bool should_initialize_gl_context) { | 558 bool should_initialize_gl_context) { |
559 // We special case Optimus since the vendor_id we see may not be Nvidia. | 559 // We special case Optimus since the vendor_id we see may not be Nvidia. |
560 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. | 560 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. |
561 gpu_info.driver_vendor == "NVIDIA") || | 561 gpu_info.driver_vendor == "NVIDIA") || |
562 gpu_info.optimus; | 562 gpu_info.optimus; |
563 if (uses_nvidia_driver && should_initialize_gl_context) { | 563 if (uses_nvidia_driver && should_initialize_gl_context) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 return true; | 617 return true; |
618 } | 618 } |
619 | 619 |
620 return false; | 620 return false; |
621 } | 621 } |
622 #endif // defined(OS_WIN) | 622 #endif // defined(OS_WIN) |
623 | 623 |
624 } // namespace. | 624 } // namespace. |
625 | 625 |
626 } // namespace content | 626 } // namespace content |
OLD | NEW |