| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "gpu/ipc/host/gpu_memory_buffer_support.h" | 5 #include "gpu/ipc/host/gpu_memory_buffer_support.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
| 11 #include "gpu/ipc/host/gpu_switches.h" | 11 #include "gpu/ipc/host/gpu_switches.h" |
| 12 #include "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
| 13 #include "ui/gl/gl_implementation.h" |
| 13 #include "ui/gl/gl_switches.h" | 14 #include "ui/gl/gl_switches.h" |
| 14 | 15 |
| 15 namespace gpu { | 16 namespace gpu { |
| 16 | 17 |
| 17 bool AreNativeGpuMemoryBuffersEnabled() { | 18 bool AreNativeGpuMemoryBuffersEnabled() { |
| 18 // Disable native buffers when using Mesa. | 19 // Disable native buffers when using software GL. |
| 19 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 20 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 20 switches::kUseGL) == gl::kGLImplementationOSMesaName) { | 21 switches::kUseGL) == |
| 22 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation())) { |
| 21 return false; | 23 return false; |
| 22 } | 24 } |
| 23 | 25 |
| 24 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
| 25 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 27 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 26 switches::kDisableNativeGpuMemoryBuffers); | 28 switches::kDisableNativeGpuMemoryBuffers); |
| 27 #else | 29 #else |
| 28 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 30 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 29 switches::kEnableNativeGpuMemoryBuffers); | 31 switches::kEnableNativeGpuMemoryBuffers); |
| 30 #endif | 32 #endif |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | 52 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
| 51 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; | 53 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; |
| 52 for (auto format : kNativeFormats) { | 54 for (auto format : kNativeFormats) { |
| 53 for (auto usage : kNativeUsages) { | 55 for (auto usage : kNativeUsages) { |
| 54 if (IsNativeGpuMemoryBufferConfigurationSupported(format, usage)) | 56 if (IsNativeGpuMemoryBufferConfigurationSupported(format, usage)) |
| 55 configurations.insert(std::make_pair(format, usage)); | 57 configurations.insert(std::make_pair(format, usage)); |
| 56 } | 58 } |
| 57 } | 59 } |
| 58 } | 60 } |
| 59 | 61 |
| 60 // Disable native buffers only when using Mesa. | 62 // Disable native buffers only when using software GL. |
| 61 bool force_native_gpu_read_write_formats = | 63 bool force_native_gpu_read_write_formats = |
| 62 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 64 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 63 switches::kUseGL) != gl::kGLImplementationOSMesaName; | 65 switches::kUseGL) != |
| 66 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation()); |
| 64 if (force_native_gpu_read_write_formats) { | 67 if (force_native_gpu_read_write_formats) { |
| 65 const gfx::BufferFormat kGPUReadWriteFormats[] = { | 68 const gfx::BufferFormat kGPUReadWriteFormats[] = { |
| 66 gfx::BufferFormat::BGR_565, gfx::BufferFormat::RGBA_8888, | 69 gfx::BufferFormat::BGR_565, gfx::BufferFormat::RGBA_8888, |
| 67 gfx::BufferFormat::RGBX_8888, gfx::BufferFormat::BGRA_8888, | 70 gfx::BufferFormat::RGBX_8888, gfx::BufferFormat::BGRA_8888, |
| 68 gfx::BufferFormat::BGRX_8888, gfx::BufferFormat::UYVY_422, | 71 gfx::BufferFormat::BGRX_8888, gfx::BufferFormat::UYVY_422, |
| 69 gfx::BufferFormat::YVU_420, gfx::BufferFormat::YUV_420_BIPLANAR}; | 72 gfx::BufferFormat::YVU_420, gfx::BufferFormat::YUV_420_BIPLANAR}; |
| 70 const gfx::BufferUsage kGPUReadWriteUsages[] = {gfx::BufferUsage::GPU_READ, | 73 const gfx::BufferUsage kGPUReadWriteUsages[] = {gfx::BufferUsage::GPU_READ, |
| 71 gfx::BufferUsage::SCANOUT}; | 74 gfx::BufferUsage::SCANOUT}; |
| 72 for (auto format : kGPUReadWriteFormats) { | 75 for (auto format : kGPUReadWriteFormats) { |
| 73 for (auto usage : kGPUReadWriteUsages) { | 76 for (auto usage : kGPUReadWriteUsages) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 104 break; | 107 break; |
| 105 } | 108 } |
| 106 NOTREACHED(); | 109 NOTREACHED(); |
| 107 return GL_TEXTURE_2D; | 110 return GL_TEXTURE_2D; |
| 108 #else // defined(USE_OZONE) || defined(OS_MACOSX) | 111 #else // defined(USE_OZONE) || defined(OS_MACOSX) |
| 109 return GL_TEXTURE_2D; | 112 return GL_TEXTURE_2D; |
| 110 #endif | 113 #endif |
| 111 } | 114 } |
| 112 | 115 |
| 113 } // namespace gpu | 116 } // namespace gpu |
| OLD | NEW |