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/common/gpu/gpu_memory_buffer_factory_surface_texture.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" |
6 | 6 |
7 #include "content/common/android/surface_texture_manager.h" | 7 #include "content/common/android/surface_texture_manager.h" |
8 #include "ui/gl/android/surface_texture.h" | 8 #include "ui/gl/android/surface_texture.h" |
9 #include "ui/gl/gl_image_surface_texture.h" | 9 #include "ui/gl/gl_image_surface_texture.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 namespace { | |
13 | |
14 const GpuMemoryBufferFactory::Configuration kSupportedConfigurations[] = { | |
15 {gfx::BufferFormat::RGBA_8888, gfx::BufferUsage::MAP}}; | |
16 | |
17 } // namespace | |
18 | 12 |
19 GpuMemoryBufferFactorySurfaceTexture::GpuMemoryBufferFactorySurfaceTexture() { | 13 GpuMemoryBufferFactorySurfaceTexture::GpuMemoryBufferFactorySurfaceTexture() { |
20 } | 14 } |
21 | 15 |
22 GpuMemoryBufferFactorySurfaceTexture::~GpuMemoryBufferFactorySurfaceTexture() { | 16 GpuMemoryBufferFactorySurfaceTexture::~GpuMemoryBufferFactorySurfaceTexture() { |
23 } | 17 } |
24 | 18 |
25 // static | 19 // static |
26 bool GpuMemoryBufferFactorySurfaceTexture:: | 20 bool GpuMemoryBufferFactorySurfaceTexture:: |
27 IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, | 21 IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, |
28 gfx::BufferUsage usage) { | 22 gfx::BufferUsage usage) { |
29 for (auto& configuration : kSupportedConfigurations) { | 23 switch (usage) { |
30 if (configuration.format == format && configuration.usage == usage) | 24 case gfx::BufferUsage::SCANOUT: |
31 return true; | 25 case gfx::BufferUsage::PERSISTENT_MAP: |
| 26 return false; |
| 27 case gfx::BufferUsage::MAP: |
| 28 return format == gfx::BufferFormat::RGBA_8888; |
32 } | 29 } |
33 | 30 NOTREACHED(); |
34 return false; | 31 return false; |
35 } | 32 } |
36 | 33 |
37 void GpuMemoryBufferFactorySurfaceTexture:: | |
38 GetSupportedGpuMemoryBufferConfigurations( | |
39 std::vector<Configuration>* configurations) { | |
40 configurations->assign( | |
41 kSupportedConfigurations, | |
42 kSupportedConfigurations + arraysize(kSupportedConfigurations)); | |
43 } | |
44 | |
45 gfx::GpuMemoryBufferHandle | 34 gfx::GpuMemoryBufferHandle |
46 GpuMemoryBufferFactorySurfaceTexture::CreateGpuMemoryBuffer( | 35 GpuMemoryBufferFactorySurfaceTexture::CreateGpuMemoryBuffer( |
47 gfx::GpuMemoryBufferId id, | 36 gfx::GpuMemoryBufferId id, |
48 const gfx::Size& size, | 37 const gfx::Size& size, |
49 gfx::BufferFormat format, | 38 gfx::BufferFormat format, |
50 gfx::BufferUsage usage, | 39 gfx::BufferUsage usage, |
51 int client_id, | 40 int client_id, |
52 gfx::PluginWindowHandle surface_handle) { | 41 gfx::PluginWindowHandle surface_handle) { |
53 // Note: this needs to be 0 as the surface texture implemenation will take | 42 // Note: this needs to be 0 as the surface texture implemenation will take |
54 // ownership of the texture and call glDeleteTextures when the GPU service | 43 // ownership of the texture and call glDeleteTextures when the GPU service |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 103 |
115 scoped_refptr<gfx::GLImageSurfaceTexture> image( | 104 scoped_refptr<gfx::GLImageSurfaceTexture> image( |
116 new gfx::GLImageSurfaceTexture(size)); | 105 new gfx::GLImageSurfaceTexture(size)); |
117 if (!image->Initialize(it->second.get())) | 106 if (!image->Initialize(it->second.get())) |
118 return scoped_refptr<gfx::GLImage>(); | 107 return scoped_refptr<gfx::GLImage>(); |
119 | 108 |
120 return image; | 109 return image; |
121 } | 110 } |
122 | 111 |
123 } // namespace content | 112 } // namespace content |
OLD | NEW |