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 <dwmapi.h> | 8 #include <dwmapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif | 10 #endif |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 #if !defined(OS_MACOSX) | 415 #if !defined(OS_MACOSX) |
416 bool CollectGraphicsInfo(gpu::GPUInfo& gpu_info) { | 416 bool CollectGraphicsInfo(gpu::GPUInfo& gpu_info) { |
417 bool res = true; | 417 bool res = true; |
418 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info); | 418 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info); |
419 switch (result) { | 419 switch (result) { |
420 case gpu::kCollectInfoFatalFailure: | 420 case gpu::kCollectInfoFatalFailure: |
421 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal)."; | 421 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal)."; |
422 res = false; | 422 res = false; |
423 break; | 423 break; |
424 case gpu::kCollectInfoNonFatalFailure: | 424 case gpu::kCollectInfoNonFatalFailure: |
425 VLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal)."; | 425 DVLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal)."; |
426 break; | 426 break; |
427 case gpu::kCollectInfoNone: | 427 case gpu::kCollectInfoNone: |
428 NOTREACHED(); | 428 NOTREACHED(); |
429 break; | 429 break; |
430 case gpu::kCollectInfoSuccess: | 430 case gpu::kCollectInfoSuccess: |
431 break; | 431 break; |
432 } | 432 } |
433 GetContentClient()->SetGpuInfo(gpu_info); | 433 GetContentClient()->SetGpuInfo(gpu_info); |
434 return res; | 434 return res; |
435 } | 435 } |
436 #endif | 436 #endif |
437 | 437 |
438 #if defined(OS_LINUX) | 438 #if defined(OS_LINUX) |
439 #if !defined(OS_CHROMEOS) | 439 #if !defined(OS_CHROMEOS) |
440 bool CanAccessNvidiaDeviceFile() { | 440 bool CanAccessNvidiaDeviceFile() { |
441 bool res = true; | 441 bool res = true; |
442 base::ThreadRestrictions::AssertIOAllowed(); | 442 base::ThreadRestrictions::AssertIOAllowed(); |
443 if (access("/dev/nvidiactl", R_OK) != 0) { | 443 if (access("/dev/nvidiactl", R_OK) != 0) { |
444 VLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; | 444 DVLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; |
445 res = false; | 445 res = false; |
446 } | 446 } |
447 return res; | 447 return res; |
448 } | 448 } |
449 #endif | 449 #endif |
450 | 450 |
451 void CreateDummyGlContext() { | 451 void CreateDummyGlContext() { |
452 scoped_refptr<gfx::GLSurface> surface( | 452 scoped_refptr<gfx::GLSurface> surface( |
453 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size())); | 453 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size())); |
454 if (!surface.get()) { | 454 if (!surface.get()) { |
455 VLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed"; | 455 DVLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed"; |
456 return; | 456 return; |
457 } | 457 } |
458 | 458 |
459 // On Linux, this is needed to make sure /dev/nvidiactl has | 459 // On Linux, this is needed to make sure /dev/nvidiactl has |
460 // been opened and its descriptor cached. | 460 // been opened and its descriptor cached. |
461 scoped_refptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext( | 461 scoped_refptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext( |
462 NULL, surface.get(), gfx::PreferDiscreteGpu)); | 462 NULL, surface.get(), gfx::PreferDiscreteGpu)); |
463 if (!context.get()) { | 463 if (!context.get()) { |
464 VLOG(1) << "gfx::GLContext::CreateGLContext failed"; | 464 DVLOG(1) << "gfx::GLContext::CreateGLContext failed"; |
465 return; | 465 return; |
466 } | 466 } |
467 | 467 |
468 // Similarly, this is needed for /dev/nvidia0. | 468 // Similarly, this is needed for /dev/nvidia0. |
469 if (context->MakeCurrent(surface.get())) { | 469 if (context->MakeCurrent(surface.get())) { |
470 context->ReleaseCurrent(surface.get()); | 470 context->ReleaseCurrent(surface.get()); |
471 } else { | 471 } else { |
472 VLOG(1) << "gfx::GLContext::MakeCurrent failed"; | 472 DVLOG(1) << "gfx::GLContext::MakeCurrent failed"; |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 void WarmUpSandboxNvidia(const gpu::GPUInfo& gpu_info, | 476 void WarmUpSandboxNvidia(const gpu::GPUInfo& gpu_info, |
477 bool should_initialize_gl_context) { | 477 bool should_initialize_gl_context) { |
478 // We special case Optimus since the vendor_id we see may not be Nvidia. | 478 // We special case Optimus since the vendor_id we see may not be Nvidia. |
479 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. | 479 bool uses_nvidia_driver = (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA. |
480 gpu_info.driver_vendor == "NVIDIA") || | 480 gpu_info.driver_vendor == "NVIDIA") || |
481 gpu_info.optimus; | 481 gpu_info.optimus; |
482 if (uses_nvidia_driver && should_initialize_gl_context) { | 482 if (uses_nvidia_driver && should_initialize_gl_context) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 return true; | 536 return true; |
537 } | 537 } |
538 | 538 |
539 return false; | 539 return false; |
540 } | 540 } |
541 #endif // defined(OS_WIN) | 541 #endif // defined(OS_WIN) |
542 | 542 |
543 } // namespace. | 543 } // namespace. |
544 | 544 |
545 } // namespace content | 545 } // namespace content |
OLD | NEW |