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 "ui/gl/gl_image_memory.h" | 5 #include "ui/gl/gl_image_memory.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 case gfx::BufferFormat::RGBA_4444: | 50 case gfx::BufferFormat::RGBA_4444: |
51 case gfx::BufferFormat::RGBX_8888: | 51 case gfx::BufferFormat::RGBX_8888: |
52 case gfx::BufferFormat::RGBA_8888: | 52 case gfx::BufferFormat::RGBA_8888: |
53 case gfx::BufferFormat::BGRX_8888: | 53 case gfx::BufferFormat::BGRX_8888: |
54 case gfx::BufferFormat::BGRA_8888: | 54 case gfx::BufferFormat::BGRA_8888: |
55 case gfx::BufferFormat::RGBA_F16: | 55 case gfx::BufferFormat::RGBA_F16: |
56 return true; | 56 return true; |
57 case gfx::BufferFormat::YVU_420: | 57 case gfx::BufferFormat::YVU_420: |
58 case gfx::BufferFormat::YUV_420_BIPLANAR: | 58 case gfx::BufferFormat::YUV_420_BIPLANAR: |
59 case gfx::BufferFormat::UYVY_422: | 59 case gfx::BufferFormat::UYVY_422: |
| 60 case gfx::BufferFormat::YUYV_422: |
60 return false; | 61 return false; |
61 } | 62 } |
62 | 63 |
63 NOTREACHED(); | 64 NOTREACHED(); |
64 return false; | 65 return false; |
65 } | 66 } |
66 | 67 |
67 bool IsCompressedFormat(gfx::BufferFormat format) { | 68 bool IsCompressedFormat(gfx::BufferFormat format) { |
68 switch (format) { | 69 switch (format) { |
69 case gfx::BufferFormat::ATC: | 70 case gfx::BufferFormat::ATC: |
70 case gfx::BufferFormat::ATCIA: | 71 case gfx::BufferFormat::ATCIA: |
71 case gfx::BufferFormat::DXT1: | 72 case gfx::BufferFormat::DXT1: |
72 case gfx::BufferFormat::DXT5: | 73 case gfx::BufferFormat::DXT5: |
73 case gfx::BufferFormat::ETC1: | 74 case gfx::BufferFormat::ETC1: |
74 return true; | 75 return true; |
75 case gfx::BufferFormat::R_8: | 76 case gfx::BufferFormat::R_8: |
76 case gfx::BufferFormat::RG_88: | 77 case gfx::BufferFormat::RG_88: |
77 case gfx::BufferFormat::BGR_565: | 78 case gfx::BufferFormat::BGR_565: |
78 case gfx::BufferFormat::RGBA_4444: | 79 case gfx::BufferFormat::RGBA_4444: |
79 case gfx::BufferFormat::RGBX_8888: | 80 case gfx::BufferFormat::RGBX_8888: |
80 case gfx::BufferFormat::RGBA_8888: | 81 case gfx::BufferFormat::RGBA_8888: |
81 case gfx::BufferFormat::BGRX_8888: | 82 case gfx::BufferFormat::BGRX_8888: |
82 case gfx::BufferFormat::BGRA_8888: | 83 case gfx::BufferFormat::BGRA_8888: |
83 case gfx::BufferFormat::RGBA_F16: | 84 case gfx::BufferFormat::RGBA_F16: |
84 return false; | 85 return false; |
85 case gfx::BufferFormat::YVU_420: | 86 case gfx::BufferFormat::YVU_420: |
86 case gfx::BufferFormat::YUV_420_BIPLANAR: | 87 case gfx::BufferFormat::YUV_420_BIPLANAR: |
87 case gfx::BufferFormat::UYVY_422: | 88 case gfx::BufferFormat::UYVY_422: |
| 89 case gfx::BufferFormat::YUYV_422: |
88 NOTREACHED(); | 90 NOTREACHED(); |
89 return false; | 91 return false; |
90 } | 92 } |
91 | 93 |
92 NOTREACHED(); | 94 NOTREACHED(); |
93 return false; | 95 return false; |
94 } | 96 } |
95 | 97 |
96 GLenum TextureFormat(gfx::BufferFormat format) { | 98 GLenum TextureFormat(gfx::BufferFormat format) { |
97 switch (format) { | 99 switch (format) { |
(...skipping 17 matching lines...) Expand all Loading... |
115 return GL_RGBA; | 117 return GL_RGBA; |
116 case gfx::BufferFormat::BGRA_8888: | 118 case gfx::BufferFormat::BGRA_8888: |
117 return GL_BGRA_EXT; | 119 return GL_BGRA_EXT; |
118 case gfx::BufferFormat::BGR_565: | 120 case gfx::BufferFormat::BGR_565: |
119 case gfx::BufferFormat::RGBX_8888: | 121 case gfx::BufferFormat::RGBX_8888: |
120 case gfx::BufferFormat::BGRX_8888: | 122 case gfx::BufferFormat::BGRX_8888: |
121 return GL_RGB; | 123 return GL_RGB; |
122 case gfx::BufferFormat::YVU_420: | 124 case gfx::BufferFormat::YVU_420: |
123 case gfx::BufferFormat::YUV_420_BIPLANAR: | 125 case gfx::BufferFormat::YUV_420_BIPLANAR: |
124 case gfx::BufferFormat::UYVY_422: | 126 case gfx::BufferFormat::UYVY_422: |
| 127 case gfx::BufferFormat::YUYV_422: |
125 NOTREACHED(); | 128 NOTREACHED(); |
126 return 0; | 129 return 0; |
127 } | 130 } |
128 | 131 |
129 NOTREACHED(); | 132 NOTREACHED(); |
130 return 0; | 133 return 0; |
131 } | 134 } |
132 | 135 |
133 GLenum DataFormat(gfx::BufferFormat format) { | 136 GLenum DataFormat(gfx::BufferFormat format) { |
134 switch (format) { | 137 switch (format) { |
(...skipping 10 matching lines...) Expand all Loading... |
145 case gfx::BufferFormat::RG_88: | 148 case gfx::BufferFormat::RG_88: |
146 case gfx::BufferFormat::ATC: | 149 case gfx::BufferFormat::ATC: |
147 case gfx::BufferFormat::ATCIA: | 150 case gfx::BufferFormat::ATCIA: |
148 case gfx::BufferFormat::DXT1: | 151 case gfx::BufferFormat::DXT1: |
149 case gfx::BufferFormat::DXT5: | 152 case gfx::BufferFormat::DXT5: |
150 case gfx::BufferFormat::ETC1: | 153 case gfx::BufferFormat::ETC1: |
151 return TextureFormat(format); | 154 return TextureFormat(format); |
152 case gfx::BufferFormat::YVU_420: | 155 case gfx::BufferFormat::YVU_420: |
153 case gfx::BufferFormat::YUV_420_BIPLANAR: | 156 case gfx::BufferFormat::YUV_420_BIPLANAR: |
154 case gfx::BufferFormat::UYVY_422: | 157 case gfx::BufferFormat::UYVY_422: |
| 158 case gfx::BufferFormat::YUYV_422: |
155 NOTREACHED(); | 159 NOTREACHED(); |
156 return 0; | 160 return 0; |
157 } | 161 } |
158 | 162 |
159 NOTREACHED(); | 163 NOTREACHED(); |
160 return 0; | 164 return 0; |
161 } | 165 } |
162 | 166 |
163 GLenum DataType(gfx::BufferFormat format) { | 167 GLenum DataType(gfx::BufferFormat format) { |
164 switch (format) { | 168 switch (format) { |
(...skipping 11 matching lines...) Expand all Loading... |
176 case gfx::BufferFormat::RGBA_F16: | 180 case gfx::BufferFormat::RGBA_F16: |
177 return GL_HALF_FLOAT_OES; | 181 return GL_HALF_FLOAT_OES; |
178 case gfx::BufferFormat::ATC: | 182 case gfx::BufferFormat::ATC: |
179 case gfx::BufferFormat::ATCIA: | 183 case gfx::BufferFormat::ATCIA: |
180 case gfx::BufferFormat::DXT1: | 184 case gfx::BufferFormat::DXT1: |
181 case gfx::BufferFormat::DXT5: | 185 case gfx::BufferFormat::DXT5: |
182 case gfx::BufferFormat::ETC1: | 186 case gfx::BufferFormat::ETC1: |
183 case gfx::BufferFormat::YVU_420: | 187 case gfx::BufferFormat::YVU_420: |
184 case gfx::BufferFormat::YUV_420_BIPLANAR: | 188 case gfx::BufferFormat::YUV_420_BIPLANAR: |
185 case gfx::BufferFormat::UYVY_422: | 189 case gfx::BufferFormat::UYVY_422: |
| 190 case gfx::BufferFormat::YUYV_422: |
186 NOTREACHED(); | 191 NOTREACHED(); |
187 return 0; | 192 return 0; |
188 } | 193 } |
189 | 194 |
190 NOTREACHED(); | 195 NOTREACHED(); |
191 return 0; | 196 return 0; |
192 } | 197 } |
193 | 198 |
194 GLint DataRowLength(size_t stride, gfx::BufferFormat format) { | 199 GLint DataRowLength(size_t stride, gfx::BufferFormat format) { |
195 switch (format) { | 200 switch (format) { |
(...skipping 11 matching lines...) Expand all Loading... |
207 case gfx::BufferFormat::R_8: | 212 case gfx::BufferFormat::R_8: |
208 return base::checked_cast<GLint>(stride); | 213 return base::checked_cast<GLint>(stride); |
209 case gfx::BufferFormat::ATC: | 214 case gfx::BufferFormat::ATC: |
210 case gfx::BufferFormat::ATCIA: | 215 case gfx::BufferFormat::ATCIA: |
211 case gfx::BufferFormat::DXT1: | 216 case gfx::BufferFormat::DXT1: |
212 case gfx::BufferFormat::DXT5: | 217 case gfx::BufferFormat::DXT5: |
213 case gfx::BufferFormat::ETC1: | 218 case gfx::BufferFormat::ETC1: |
214 case gfx::BufferFormat::YVU_420: | 219 case gfx::BufferFormat::YVU_420: |
215 case gfx::BufferFormat::YUV_420_BIPLANAR: | 220 case gfx::BufferFormat::YUV_420_BIPLANAR: |
216 case gfx::BufferFormat::UYVY_422: | 221 case gfx::BufferFormat::UYVY_422: |
| 222 case gfx::BufferFormat::YUYV_422: |
217 NOTREACHED(); | 223 NOTREACHED(); |
218 return 0; | 224 return 0; |
219 } | 225 } |
220 | 226 |
221 NOTREACHED(); | 227 NOTREACHED(); |
222 return 0; | 228 return 0; |
223 } | 229 } |
224 | 230 |
225 template <typename F> | 231 template <typename F> |
226 std::unique_ptr<uint8_t[]> GLES2RGBData(const gfx::Size& size, | 232 std::unique_ptr<uint8_t[]> GLES2RGBData(const gfx::Size& size, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 343 } |
338 case gfx::BufferFormat::ATC: | 344 case gfx::BufferFormat::ATC: |
339 case gfx::BufferFormat::ATCIA: | 345 case gfx::BufferFormat::ATCIA: |
340 case gfx::BufferFormat::DXT1: | 346 case gfx::BufferFormat::DXT1: |
341 case gfx::BufferFormat::DXT5: | 347 case gfx::BufferFormat::DXT5: |
342 case gfx::BufferFormat::ETC1: | 348 case gfx::BufferFormat::ETC1: |
343 return nullptr; // No data conversion needed | 349 return nullptr; // No data conversion needed |
344 case gfx::BufferFormat::YVU_420: | 350 case gfx::BufferFormat::YVU_420: |
345 case gfx::BufferFormat::YUV_420_BIPLANAR: | 351 case gfx::BufferFormat::YUV_420_BIPLANAR: |
346 case gfx::BufferFormat::UYVY_422: | 352 case gfx::BufferFormat::UYVY_422: |
| 353 case gfx::BufferFormat::YUYV_422: |
347 NOTREACHED(); | 354 NOTREACHED(); |
348 return nullptr; | 355 return nullptr; |
349 } | 356 } |
350 | 357 |
351 NOTREACHED(); | 358 NOTREACHED(); |
352 return nullptr; | 359 return nullptr; |
353 } | 360 } |
354 | 361 |
355 } // namespace | 362 } // namespace |
356 | 363 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 return Type::MEMORY; | 517 return Type::MEMORY; |
511 } | 518 } |
512 | 519 |
513 // static | 520 // static |
514 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { | 521 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { |
515 DCHECK(ValidFormat(format)); | 522 DCHECK(ValidFormat(format)); |
516 return TextureFormat(format); | 523 return TextureFormat(format); |
517 } | 524 } |
518 | 525 |
519 } // namespace gl | 526 } // namespace gl |
OLD | NEW |