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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 210 } |
210 | 211 |
211 // static | 212 // static |
212 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled() { | 213 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled() { |
213 // Disable native buffers when using Mesa. | 214 // Disable native buffers when using Mesa. |
214 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 215 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
215 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { | 216 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { |
216 return false; | 217 return false; |
217 } | 218 } |
218 | 219 |
| 220 #if defined(OS_ANDROID) |
| 221 // Single buffer SurfaceTexture mode is required for native buffers on |
| 222 // Android. |
| 223 if (!gfx::SurfaceTexture::IsSingleBufferModeSupported()) |
| 224 return false; |
| 225 #endif |
| 226 |
219 #if defined(OS_MACOSX) | 227 #if defined(OS_MACOSX) |
220 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 228 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
221 switches::kDisableNativeGpuMemoryBuffers); | 229 switches::kDisableNativeGpuMemoryBuffers); |
222 #else | 230 #else |
223 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 231 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
224 switches::kEnableNativeGpuMemoryBuffers); | 232 switches::kEnableNativeGpuMemoryBuffers); |
225 #endif | 233 #endif |
226 } | 234 } |
227 | 235 |
228 // static | 236 // static |
229 uint32 BrowserGpuMemoryBufferManager::GetImageTextureTarget( | 237 uint32 BrowserGpuMemoryBufferManager::GetImageTextureTarget( |
230 gfx::BufferFormat format, | 238 gfx::BufferFormat format, |
231 gfx::BufferUsage usage) { | 239 gfx::BufferUsage usage) { |
232 GpuMemoryBufferConfigurationSet native_configurations = | 240 GpuMemoryBufferConfigurationSet native_configurations = |
233 GetNativeGpuMemoryBufferConfigurations(); | 241 GetNativeGpuMemoryBufferConfigurations(); |
234 if (native_configurations.find(std::make_pair(format, usage)) == | 242 if (native_configurations.find(std::make_pair(format, usage)) == |
235 native_configurations.end()) { | 243 native_configurations.end()) { |
236 return GL_TEXTURE_2D; | 244 return GL_TEXTURE_2D; |
237 } | 245 } |
238 | 246 |
239 switch (GpuMemoryBufferFactory::GetNativeType()) { | 247 switch (GpuMemoryBufferFactory::GetNativeType()) { |
240 case gfx::SURFACE_TEXTURE_BUFFER: | |
241 case gfx::OZONE_NATIVE_PIXMAP: | 248 case gfx::OZONE_NATIVE_PIXMAP: |
242 // GPU memory buffers that are shared with the GL using EGLImages | 249 // GPU memory buffers that are bound to GL textures using EGLImages |
243 // require TEXTURE_EXTERNAL_OES. | 250 // require TEXTURE_EXTERNAL_OES. |
244 return GL_TEXTURE_EXTERNAL_OES; | 251 return GL_TEXTURE_EXTERNAL_OES; |
245 case gfx::IO_SURFACE_BUFFER: | 252 case gfx::IO_SURFACE_BUFFER: |
246 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. | 253 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. |
247 return GL_TEXTURE_RECTANGLE_ARB; | 254 return GL_TEXTURE_RECTANGLE_ARB; |
| 255 case gfx::SURFACE_TEXTURE_BUFFER: |
| 256 // GPU memory buffers that require a copy expects GL_TEXTURE_2D as target. |
| 257 return GL_TEXTURE_2D; |
248 case gfx::SHARED_MEMORY_BUFFER: | 258 case gfx::SHARED_MEMORY_BUFFER: |
249 return GL_TEXTURE_2D; | |
250 case gfx::EMPTY_BUFFER: | 259 case gfx::EMPTY_BUFFER: |
251 NOTREACHED(); | 260 NOTREACHED(); |
252 return GL_TEXTURE_2D; | 261 return GL_TEXTURE_2D; |
253 } | 262 } |
254 | 263 |
255 NOTREACHED(); | 264 NOTREACHED(); |
256 return GL_TEXTURE_2D; | 265 return GL_TEXTURE_2D; |
257 } | 266 } |
258 | 267 |
259 scoped_ptr<gfx::GpuMemoryBuffer> | 268 scoped_ptr<gfx::GpuMemoryBuffer> |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 return gpu_client_tracing_id_; | 752 return gpu_client_tracing_id_; |
744 } | 753 } |
745 | 754 |
746 // In normal cases, |client_id| is a child process id, so we can perform | 755 // In normal cases, |client_id| is a child process id, so we can perform |
747 // the standard conversion. | 756 // the standard conversion. |
748 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 757 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
749 client_id); | 758 client_id); |
750 } | 759 } |
751 | 760 |
752 } // namespace content | 761 } // namespace content |
OLD | NEW |