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/command_buffer/common/gpu_memory_buffer_support.h" | 5 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2extchromium.h> | 8 #include <GLES2/gl2extchromium.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "gpu/command_buffer/common/capabilities.h" | 11 #include "gpu/command_buffer/common/capabilities.h" |
12 | 12 |
13 namespace gpu { | 13 namespace gpu { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 gfx::BufferFormat BufferFormatForInternalFormat(unsigned internalformat) { | 17 gfx::BufferFormat BufferFormatForInternalFormat(unsigned internalformat) { |
18 switch (internalformat) { | 18 switch (internalformat) { |
19 case GL_RED_EXT: | 19 case GL_RED_EXT: |
20 return gfx::BufferFormat::R_8; | 20 return gfx::BufferFormat::R_8; |
| 21 case GL_R16_EXT: |
| 22 return gfx::BufferFormat::R_16; |
21 case GL_RG_EXT: | 23 case GL_RG_EXT: |
22 return gfx::BufferFormat::RG_88; | 24 return gfx::BufferFormat::RG_88; |
23 case GL_RGB: | 25 case GL_RGB: |
24 return gfx::BufferFormat::BGRX_8888; | 26 return gfx::BufferFormat::BGRX_8888; |
25 case GL_RGBA: | 27 case GL_RGBA: |
26 return gfx::BufferFormat::RGBA_8888; | 28 return gfx::BufferFormat::RGBA_8888; |
27 case GL_BGRA_EXT: | 29 case GL_BGRA_EXT: |
28 return gfx::BufferFormat::BGRA_8888; | 30 return gfx::BufferFormat::BGRA_8888; |
29 case GL_ATC_RGB_AMD: | 31 case GL_ATC_RGB_AMD: |
30 return gfx::BufferFormat::ATC; | 32 return gfx::BufferFormat::ATC; |
(...skipping 24 matching lines...) Expand all Loading... |
55 gfx::BufferFormat format) { | 57 gfx::BufferFormat format) { |
56 switch (format) { | 58 switch (format) { |
57 case gfx::BufferFormat::ATC: | 59 case gfx::BufferFormat::ATC: |
58 case gfx::BufferFormat::ATCIA: | 60 case gfx::BufferFormat::ATCIA: |
59 case gfx::BufferFormat::BGRA_8888: | 61 case gfx::BufferFormat::BGRA_8888: |
60 case gfx::BufferFormat::BGRX_8888: | 62 case gfx::BufferFormat::BGRX_8888: |
61 case gfx::BufferFormat::DXT1: | 63 case gfx::BufferFormat::DXT1: |
62 case gfx::BufferFormat::DXT5: | 64 case gfx::BufferFormat::DXT5: |
63 case gfx::BufferFormat::ETC1: | 65 case gfx::BufferFormat::ETC1: |
64 case gfx::BufferFormat::R_8: | 66 case gfx::BufferFormat::R_8: |
| 67 case gfx::BufferFormat::R_16: |
65 case gfx::BufferFormat::RG_88: | 68 case gfx::BufferFormat::RG_88: |
66 case gfx::BufferFormat::RGBA_8888: | 69 case gfx::BufferFormat::RGBA_8888: |
67 case gfx::BufferFormat::YVU_420: | 70 case gfx::BufferFormat::YVU_420: |
68 case gfx::BufferFormat::YUV_420_BIPLANAR: | 71 case gfx::BufferFormat::YUV_420_BIPLANAR: |
69 case gfx::BufferFormat::UYVY_422: | 72 case gfx::BufferFormat::UYVY_422: |
70 return format == BufferFormatForInternalFormat(internalformat); | 73 return format == BufferFormatForInternalFormat(internalformat); |
71 case gfx::BufferFormat::BGR_565: | 74 case gfx::BufferFormat::BGR_565: |
72 case gfx::BufferFormat::RGBX_8888: | 75 case gfx::BufferFormat::RGBX_8888: |
73 return internalformat == GL_RGB; | 76 return internalformat == GL_RGB; |
74 case gfx::BufferFormat::RGBA_4444: | 77 case gfx::BufferFormat::RGBA_4444: |
(...skipping 14 matching lines...) Expand all Loading... |
89 return capabilities.texture_format_atc; | 92 return capabilities.texture_format_atc; |
90 case gfx::BufferFormat::BGRA_8888: | 93 case gfx::BufferFormat::BGRA_8888: |
91 case gfx::BufferFormat::BGRX_8888: | 94 case gfx::BufferFormat::BGRX_8888: |
92 return capabilities.texture_format_bgra8888; | 95 return capabilities.texture_format_bgra8888; |
93 case gfx::BufferFormat::DXT1: | 96 case gfx::BufferFormat::DXT1: |
94 return capabilities.texture_format_dxt1; | 97 return capabilities.texture_format_dxt1; |
95 case gfx::BufferFormat::DXT5: | 98 case gfx::BufferFormat::DXT5: |
96 return capabilities.texture_format_dxt5; | 99 return capabilities.texture_format_dxt5; |
97 case gfx::BufferFormat::ETC1: | 100 case gfx::BufferFormat::ETC1: |
98 return capabilities.texture_format_etc1; | 101 return capabilities.texture_format_etc1; |
| 102 case gfx::BufferFormat::R_16: |
| 103 return capabilities.texture_norm16; |
99 case gfx::BufferFormat::R_8: | 104 case gfx::BufferFormat::R_8: |
100 case gfx::BufferFormat::RG_88: | 105 case gfx::BufferFormat::RG_88: |
101 return capabilities.texture_rg; | 106 return capabilities.texture_rg; |
102 case gfx::BufferFormat::UYVY_422: | 107 case gfx::BufferFormat::UYVY_422: |
103 return capabilities.image_ycbcr_422; | 108 return capabilities.image_ycbcr_422; |
104 case gfx::BufferFormat::BGR_565: | 109 case gfx::BufferFormat::BGR_565: |
105 case gfx::BufferFormat::RGBA_4444: | 110 case gfx::BufferFormat::RGBA_4444: |
106 case gfx::BufferFormat::RGBA_8888: | 111 case gfx::BufferFormat::RGBA_8888: |
107 case gfx::BufferFormat::RGBX_8888: | 112 case gfx::BufferFormat::RGBX_8888: |
108 case gfx::BufferFormat::YVU_420: | 113 case gfx::BufferFormat::YVU_420: |
(...skipping 19 matching lines...) Expand all Loading... |
128 switch (format) { | 133 switch (format) { |
129 case gfx::BufferFormat::ATC: | 134 case gfx::BufferFormat::ATC: |
130 case gfx::BufferFormat::ATCIA: | 135 case gfx::BufferFormat::ATCIA: |
131 case gfx::BufferFormat::DXT1: | 136 case gfx::BufferFormat::DXT1: |
132 case gfx::BufferFormat::DXT5: | 137 case gfx::BufferFormat::DXT5: |
133 case gfx::BufferFormat::ETC1: | 138 case gfx::BufferFormat::ETC1: |
134 // Compressed images must have a width and height that's evenly divisible | 139 // Compressed images must have a width and height that's evenly divisible |
135 // by the block size. | 140 // by the block size. |
136 return size.width() % 4 == 0 && size.height() % 4 == 0; | 141 return size.width() % 4 == 0 && size.height() % 4 == 0; |
137 case gfx::BufferFormat::R_8: | 142 case gfx::BufferFormat::R_8: |
| 143 case gfx::BufferFormat::R_16: |
138 case gfx::BufferFormat::RG_88: | 144 case gfx::BufferFormat::RG_88: |
139 case gfx::BufferFormat::BGR_565: | 145 case gfx::BufferFormat::BGR_565: |
140 case gfx::BufferFormat::RGBA_4444: | 146 case gfx::BufferFormat::RGBA_4444: |
141 case gfx::BufferFormat::RGBA_8888: | 147 case gfx::BufferFormat::RGBA_8888: |
142 case gfx::BufferFormat::RGBX_8888: | 148 case gfx::BufferFormat::RGBX_8888: |
143 case gfx::BufferFormat::BGRA_8888: | 149 case gfx::BufferFormat::BGRA_8888: |
144 case gfx::BufferFormat::BGRX_8888: | 150 case gfx::BufferFormat::BGRX_8888: |
145 case gfx::BufferFormat::RGBA_F16: | 151 case gfx::BufferFormat::RGBA_F16: |
146 return true; | 152 return true; |
147 case gfx::BufferFormat::YVU_420: | 153 case gfx::BufferFormat::YVU_420: |
148 case gfx::BufferFormat::YUV_420_BIPLANAR: | 154 case gfx::BufferFormat::YUV_420_BIPLANAR: |
149 // U and V planes are subsampled by a factor of 2. | 155 // U and V planes are subsampled by a factor of 2. |
150 return size.width() % 2 == 0 && size.height() % 2 == 0; | 156 return size.width() % 2 == 0 && size.height() % 2 == 0; |
151 case gfx::BufferFormat::UYVY_422: | 157 case gfx::BufferFormat::UYVY_422: |
152 return size.width() % 2 == 0; | 158 return size.width() % 2 == 0; |
153 } | 159 } |
154 | 160 |
155 NOTREACHED(); | 161 NOTREACHED(); |
156 return false; | 162 return false; |
157 } | 163 } |
158 | 164 |
159 } // namespace gpu | 165 } // namespace gpu |
OLD | NEW |