| 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 24 matching lines...) Expand all Loading... |
| 35 #include "gpu/config/gpu_util.h" | 35 #include "gpu/config/gpu_util.h" |
| 36 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 36 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
| 37 #include "gpu/ipc/service/gpu_config.h" | 37 #include "gpu/ipc/service/gpu_config.h" |
| 38 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 38 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
| 39 #include "ui/events/platform/platform_event_source.h" | 39 #include "ui/events/platform/platform_event_source.h" |
| 40 #include "ui/gl/gl_context.h" | 40 #include "ui/gl/gl_context.h" |
| 41 #include "ui/gl/gl_implementation.h" | 41 #include "ui/gl/gl_implementation.h" |
| 42 #include "ui/gl/gl_surface.h" | 42 #include "ui/gl/gl_surface.h" |
| 43 #include "ui/gl/gl_switches.h" | 43 #include "ui/gl/gl_switches.h" |
| 44 #include "ui/gl/gpu_switching_manager.h" | 44 #include "ui/gl/gpu_switching_manager.h" |
| 45 #include "ui/gl/init/gl_factory.h" |
| 45 | 46 |
| 46 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 47 #include <dwmapi.h> | 48 #include <dwmapi.h> |
| 48 #include <windows.h> | 49 #include <windows.h> |
| 49 #endif | 50 #endif |
| 50 | 51 |
| 51 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
| 52 #include "base/trace_event/memory_dump_manager.h" | 53 #include "base/trace_event/memory_dump_manager.h" |
| 53 #include "components/tracing/graphics_memory_dump_provider_android.h" | 54 #include "components/tracing/graphics_memory_dump_provider_android.h" |
| 54 #endif | 55 #endif |
| 55 | 56 |
| 56 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 58 #include "base/win/scoped_com_initializer.h" |
| 57 #include "base/win/windows_version.h" | 59 #include "base/win/windows_version.h" |
| 58 #include "base/win/scoped_com_initializer.h" | |
| 59 #include "media/gpu/dxva_video_decode_accelerator_win.h" | 60 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
| 60 #include "sandbox/win/src/sandbox.h" | 61 #include "sandbox/win/src/sandbox.h" |
| 61 #endif | 62 #endif |
| 62 | 63 |
| 63 #if defined(USE_X11) | 64 #if defined(USE_X11) |
| 64 #include "ui/base/x/x11_util.h" // nogncheck | 65 #include "ui/base/x/x11_util.h" // nogncheck |
| 65 #include "ui/gfx/x/x11_switches.h" // nogncheck | 66 #include "ui/gfx/x/x11_switches.h" // nogncheck |
| 66 #endif | 67 #endif |
| 67 | 68 |
| 68 #if defined(OS_LINUX) | 69 #if defined(OS_LINUX) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 initialized_sandbox = true; | 269 initialized_sandbox = true; |
| 269 } | 270 } |
| 270 #endif // defined(OS_LINUX) | 271 #endif // defined(OS_LINUX) |
| 271 | 272 |
| 272 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); | 273 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); |
| 273 | 274 |
| 274 // Determine if we need to initialize GL here or it has already been done. | 275 // Determine if we need to initialize GL here or it has already been done. |
| 275 bool gl_already_initialized = false; | 276 bool gl_already_initialized = false; |
| 276 #if defined(OS_MACOSX) | 277 #if defined(OS_MACOSX) |
| 277 if (!command_line.HasSwitch(switches::kNoSandbox)) { | 278 if (!command_line.HasSwitch(switches::kNoSandbox)) { |
| 278 // On Mac, if the sandbox is enabled, then GLSurface::InitializeOneOff() | 279 // On Mac, if the sandbox is enabled, then gl::init::InitializeGLOneOff() |
| 279 // is called from the sandbox warmup code before getting here. | 280 // is called from the sandbox warmup code before getting here. |
| 280 gl_already_initialized = true; | 281 gl_already_initialized = true; |
| 281 } | 282 } |
| 282 #endif | 283 #endif |
| 283 if (command_line.HasSwitch(switches::kInProcessGPU)) { | 284 if (command_line.HasSwitch(switches::kInProcessGPU)) { |
| 284 // With in-process GPU, GLSurface::InitializeOneOff() is called from | 285 // With in-process GPU, gl::init::InitializeGLOneOff() is called from |
| 285 // GpuChildThread before getting here. | 286 // GpuChildThread before getting here. |
| 286 gl_already_initialized = true; | 287 gl_already_initialized = true; |
| 287 } | 288 } |
| 288 | 289 |
| 289 // Load and initialize the GL implementation and locate the GL entry points. | 290 // Load and initialize the GL implementation and locate the GL entry points. |
| 290 bool gl_initialized = | 291 bool gl_initialized = |
| 291 gl_already_initialized | 292 gl_already_initialized |
| 292 ? gfx::GetGLImplementation() != gfx::kGLImplementationNone | 293 ? gfx::GetGLImplementation() != gfx::kGLImplementationNone |
| 293 : gfx::GLSurface::InitializeOneOff(); | 294 : gl::init::InitializeGLOneOff(); |
| 294 if (gl_initialized) { | 295 if (gl_initialized) { |
| 295 // We need to collect GL strings (VENDOR, RENDERER) for blacklisting | 296 // We need to collect GL strings (VENDOR, RENDERER) for blacklisting |
| 296 // purposes. However, on Mac we don't actually use them. As documented in | 297 // purposes. However, on Mac we don't actually use them. As documented in |
| 297 // crbug.com/222934, due to some driver issues, glGetString could take | 298 // crbug.com/222934, due to some driver issues, glGetString could take |
| 298 // multiple seconds to finish, which in turn cause the GPU process to | 299 // multiple seconds to finish, which in turn cause the GPU process to |
| 299 // crash. | 300 // crash. |
| 300 // By skipping the following code on Mac, we don't really lose anything, | 301 // By skipping the following code on Mac, we don't really lose anything, |
| 301 // because the basic GPU information is passed down from browser process | 302 // because the basic GPU information is passed down from browser process |
| 302 // and we already registered them through SetGpuInfo() above. | 303 // and we already registered them through SetGpuInfo() above. |
| 303 base::TimeTicks before_collect_context_graphics_info = | 304 base::TimeTicks before_collect_context_graphics_info = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 327 !CanAccessNvidiaDeviceFile()) | 328 !CanAccessNvidiaDeviceFile()) |
| 328 dead_on_arrival = true; | 329 dead_on_arrival = true; |
| 329 #endif // !defined(OS_CHROMEOS) | 330 #endif // !defined(OS_CHROMEOS) |
| 330 #endif // defined(OS_LINUX) | 331 #endif // defined(OS_LINUX) |
| 331 #endif // !defined(OS_MACOSX) | 332 #endif // !defined(OS_MACOSX) |
| 332 base::TimeDelta collect_context_time = | 333 base::TimeDelta collect_context_time = |
| 333 base::TimeTicks::Now() - before_collect_context_graphics_info; | 334 base::TimeTicks::Now() - before_collect_context_graphics_info; |
| 334 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", | 335 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", |
| 335 collect_context_time); | 336 collect_context_time); |
| 336 } else { // gl_initialized | 337 } else { // gl_initialized |
| 337 VLOG(1) << "gfx::GLSurface::InitializeOneOff failed"; | 338 VLOG(1) << "gl::init::InitializeGLOneOff failed"; |
| 338 dead_on_arrival = true; | 339 dead_on_arrival = true; |
| 339 } | 340 } |
| 340 | 341 |
| 341 base::TimeDelta initialize_one_off_time = | 342 base::TimeDelta initialize_one_off_time = |
| 342 base::TimeTicks::Now() - before_initialize_one_off; | 343 base::TimeTicks::Now() - before_initialize_one_off; |
| 343 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", | 344 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", |
| 344 initialize_one_off_time); | 345 initialize_one_off_time); |
| 345 | 346 |
| 346 if (enable_watchdog && delayed_watchdog_enable) { | 347 if (enable_watchdog && delayed_watchdog_enable) { |
| 347 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); | 348 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (access("/dev/nvidiactl", R_OK) != 0) { | 518 if (access("/dev/nvidiactl", R_OK) != 0) { |
| 518 DVLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; | 519 DVLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; |
| 519 res = false; | 520 res = false; |
| 520 } | 521 } |
| 521 return res; | 522 return res; |
| 522 } | 523 } |
| 523 #endif | 524 #endif |
| 524 | 525 |
| 525 void CreateDummyGlContext() { | 526 void CreateDummyGlContext() { |
| 526 scoped_refptr<gfx::GLSurface> surface( | 527 scoped_refptr<gfx::GLSurface> surface( |
| 527 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size())); | 528 gl::init::CreateOffscreenGLSurface(gfx::Size())); |
| 528 if (!surface.get()) { | 529 if (!surface.get()) { |
| 529 DVLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed"; | 530 DVLOG(1) << "gl::init::CreateOffscreenGLSurface failed"; |
| 530 return; | 531 return; |
| 531 } | 532 } |
| 532 | 533 |
| 533 // On Linux, this is needed to make sure /dev/nvidiactl has | 534 // On Linux, this is needed to make sure /dev/nvidiactl has |
| 534 // been opened and its descriptor cached. | 535 // been opened and its descriptor cached. |
| 535 scoped_refptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext( | 536 scoped_refptr<gfx::GLContext> context( |
| 536 NULL, surface.get(), gfx::PreferDiscreteGpu)); | 537 gl::init::CreateGLContext(NULL, surface.get(), gfx::PreferDiscreteGpu)); |
| 537 if (!context.get()) { | 538 if (!context.get()) { |
| 538 DVLOG(1) << "gfx::GLContext::CreateGLContext failed"; | 539 DVLOG(1) << "gl::init::CreateGLContext failed"; |
| 539 return; | 540 return; |
| 540 } | 541 } |
| 541 | 542 |
| 542 // Similarly, this is needed for /dev/nvidia0. | 543 // Similarly, this is needed for /dev/nvidia0. |
| 543 if (context->MakeCurrent(surface.get())) { | 544 if (context->MakeCurrent(surface.get())) { |
| 544 context->ReleaseCurrent(surface.get()); | 545 context->ReleaseCurrent(surface.get()); |
| 545 } else { | 546 } else { |
| 546 DVLOG(1) << "gfx::GLContext::MakeCurrent failed"; | 547 DVLOG(1) << "gfx::GLContext::MakeCurrent failed"; |
| 547 } | 548 } |
| 548 } | 549 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 return true; | 611 return true; |
| 611 } | 612 } |
| 612 | 613 |
| 613 return false; | 614 return false; |
| 614 } | 615 } |
| 615 #endif // defined(OS_WIN) | 616 #endif // defined(OS_WIN) |
| 616 | 617 |
| 617 } // namespace. | 618 } // namespace. |
| 618 | 619 |
| 619 } // namespace content | 620 } // namespace content |
| OLD | NEW |