| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "base/trace_event/process_memory_dump.h" | 13 #include "base/trace_event/process_memory_dump.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "content/browser/gpu/gpu_process_host.h" | 15 #include "content/browser/gpu/gpu_process_host.h" |
| 16 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 16 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 17 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" | 17 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
| 18 #include "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h" | 18 #include "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "gpu/GLES2/gl2extchromium.h" | 21 #include "gpu/GLES2/gl2extchromium.h" |
| 22 #include "ui/gl/gl_switches.h" |
| 22 | 23 |
| 23 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
| 24 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" | 25 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
| 28 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" | 29 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" |
| 29 #endif | 30 #endif |
| 30 | 31 |
| 31 #if defined(USE_OZONE) | 32 #if defined(USE_OZONE) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); | 81 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); |
| 81 DCHECK(!supported_types.empty()); | 82 DCHECK(!supported_types.empty()); |
| 82 | 83 |
| 83 // The GPU service will always use the preferred type. | 84 // The GPU service will always use the preferred type. |
| 84 return supported_types[0]; | 85 return supported_types[0]; |
| 85 } | 86 } |
| 86 | 87 |
| 87 std::vector<GpuMemoryBufferFactory::Configuration> | 88 std::vector<GpuMemoryBufferFactory::Configuration> |
| 88 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) { | 89 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) { |
| 89 std::vector<GpuMemoryBufferFactory::Configuration> configurations; | 90 std::vector<GpuMemoryBufferFactory::Configuration> configurations; |
| 90 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 91 #if defined(OS_MACOSX) |
| 91 switches::kEnableNativeGpuMemoryBuffers)) { | 92 bool enable_native_gpu_memory_buffers = |
| 93 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 94 switches::kDisableNativeGpuMemoryBuffers); |
| 95 #else |
| 96 bool enable_native_gpu_memory_buffers = |
| 97 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 98 switches::kEnableNativeGpuMemoryBuffers); |
| 99 #endif |
| 100 |
| 101 // Disable native buffers when using Mesa. |
| 102 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 103 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { |
| 104 enable_native_gpu_memory_buffers = false; |
| 105 } |
| 106 |
| 107 if (enable_native_gpu_memory_buffers) { |
| 92 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = { | 108 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = { |
| 93 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP}, | 109 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP}, |
| 94 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 110 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, |
| 95 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::MAP}, | 111 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::MAP}, |
| 96 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 112 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, |
| 97 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP}, | 113 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP}, |
| 98 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 114 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, |
| 99 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP}, | 115 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP}, |
| 100 {gfx::GpuMemoryBuffer::BGRA_8888, | 116 {gfx::GpuMemoryBuffer::BGRA_8888, |
| 101 gfx::GpuMemoryBuffer::PERSISTENT_MAP}}; | 117 gfx::GpuMemoryBuffer::PERSISTENT_MAP}}; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 576 } |
| 561 | 577 |
| 562 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); | 578 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); |
| 563 if (host) | 579 if (host) |
| 564 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); | 580 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); |
| 565 | 581 |
| 566 buffers.erase(buffer_it); | 582 buffers.erase(buffer_it); |
| 567 } | 583 } |
| 568 | 584 |
| 569 } // namespace content | 585 } // namespace content |
| OLD | NEW |