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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
23 #include "ui/gfx/buffer_format_util.h" | 23 #include "ui/gfx/buffer_format_util.h" |
24 #include "ui/gl/gl_switches.h" | 24 #include "ui/gl/gl_switches.h" |
25 | 25 |
26 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
27 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" | 27 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" |
28 #endif | 28 #endif |
29 | 29 |
30 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
31 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" | 31 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" |
| 32 #include "ui/gl/android/surface_texture.h" |
32 #endif | 33 #endif |
33 | 34 |
34 #if defined(USE_OZONE) | 35 #if defined(USE_OZONE) |
35 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h" | 36 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h" |
36 #endif | 37 #endif |
37 | 38 |
38 namespace content { | 39 namespace content { |
39 namespace { | 40 namespace { |
40 | 41 |
41 void HostCreateGpuMemoryBuffer( | 42 void HostCreateGpuMemoryBuffer( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 bool force_native_gpu_read_write_formats = false; | 118 bool force_native_gpu_read_write_formats = false; |
118 #endif | 119 #endif |
119 | 120 |
120 // Disable native buffers when using Mesa. | 121 // Disable native buffers when using Mesa. |
121 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 122 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
122 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { | 123 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { |
123 enable_native_gpu_memory_buffers = false; | 124 enable_native_gpu_memory_buffers = false; |
124 force_native_gpu_read_write_formats = false; | 125 force_native_gpu_read_write_formats = false; |
125 } | 126 } |
126 | 127 |
| 128 #if defined(OS_ANDROID) |
| 129 // Single buffer SurfaceTexture mode is required for native buffers on |
| 130 // Android. |
| 131 if (!gfx::SurfaceTexture::IsSingleBufferModeSupported()) |
| 132 enable_native_gpu_memory_buffers = false; |
| 133 #endif |
| 134 |
127 if (enable_native_gpu_memory_buffers) { | 135 if (enable_native_gpu_memory_buffers) { |
128 const gfx::BufferFormat kNativeFormats[] = { | 136 const gfx::BufferFormat kNativeFormats[] = { |
129 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444, | 137 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444, |
130 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888, | 138 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888, |
131 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR}; | 139 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR}; |
132 const gfx::BufferUsage kNativeUsages[] = { | 140 const gfx::BufferUsage kNativeUsages[] = { |
133 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT, | 141 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT, |
134 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | 142 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
135 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; | 143 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; |
136 for (auto& format : kNativeFormats) { | 144 for (auto& format : kNativeFormats) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 gfx::BufferFormat format, | 234 gfx::BufferFormat format, |
227 gfx::BufferUsage usage) { | 235 gfx::BufferUsage usage) { |
228 GpuMemoryBufferConfigurationSet native_configurations = | 236 GpuMemoryBufferConfigurationSet native_configurations = |
229 GetNativeGpuMemoryBufferConfigurations(); | 237 GetNativeGpuMemoryBufferConfigurations(); |
230 if (native_configurations.find(std::make_pair(format, usage)) == | 238 if (native_configurations.find(std::make_pair(format, usage)) == |
231 native_configurations.end()) { | 239 native_configurations.end()) { |
232 return GL_TEXTURE_2D; | 240 return GL_TEXTURE_2D; |
233 } | 241 } |
234 | 242 |
235 switch (GpuMemoryBufferFactory::GetNativeType()) { | 243 switch (GpuMemoryBufferFactory::GetNativeType()) { |
236 case gfx::SURFACE_TEXTURE_BUFFER: | |
237 case gfx::OZONE_NATIVE_PIXMAP: | 244 case gfx::OZONE_NATIVE_PIXMAP: |
238 // GPU memory buffers that are shared with the GL using EGLImages | 245 // GPU memory buffers that are bound to GL textures using EGLImages |
239 // require TEXTURE_EXTERNAL_OES. | 246 // require TEXTURE_EXTERNAL_OES. |
240 return GL_TEXTURE_EXTERNAL_OES; | 247 return GL_TEXTURE_EXTERNAL_OES; |
241 case gfx::IO_SURFACE_BUFFER: | 248 case gfx::IO_SURFACE_BUFFER: |
242 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. | 249 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. |
243 return GL_TEXTURE_RECTANGLE_ARB; | 250 return GL_TEXTURE_RECTANGLE_ARB; |
| 251 case gfx::SURFACE_TEXTURE_BUFFER: |
| 252 // GPU memory buffers that require a copy expects GL_TEXTURE_2D as target. |
| 253 return GL_TEXTURE_2D; |
244 case gfx::SHARED_MEMORY_BUFFER: | 254 case gfx::SHARED_MEMORY_BUFFER: |
245 return GL_TEXTURE_2D; | |
246 case gfx::EMPTY_BUFFER: | 255 case gfx::EMPTY_BUFFER: |
247 NOTREACHED(); | 256 NOTREACHED(); |
248 return GL_TEXTURE_2D; | 257 return GL_TEXTURE_2D; |
249 } | 258 } |
250 | 259 |
251 NOTREACHED(); | 260 NOTREACHED(); |
252 return GL_TEXTURE_2D; | 261 return GL_TEXTURE_2D; |
253 } | 262 } |
254 | 263 |
255 scoped_ptr<gfx::GpuMemoryBuffer> | 264 scoped_ptr<gfx::GpuMemoryBuffer> |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 return gpu_client_tracing_id_; | 747 return gpu_client_tracing_id_; |
739 } | 748 } |
740 | 749 |
741 // In normal cases, |client_id| is a child process id, so we can perform | 750 // In normal cases, |client_id| is a child process id, so we can perform |
742 // the standard conversion. | 751 // the standard conversion. |
743 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 752 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
744 client_id); | 753 client_id); |
745 } | 754 } |
746 | 755 |
747 } // namespace content | 756 } // namespace content |
OLD | NEW |