OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/gfx/buffer_format_util.h" | 5 #include "ui/gfx/buffer_format_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/numerics/safe_math.h" | 8 #include "base/numerics/safe_math.h" |
9 | 9 |
10 namespace gfx { | 10 namespace gfx { |
| 11 namespace { |
| 12 |
| 13 const BufferFormat kBufferFormats[] = { |
| 14 BufferFormat::ATC, BufferFormat::ATCIA, |
| 15 BufferFormat::DXT1, BufferFormat::DXT5, |
| 16 BufferFormat::ETC1, BufferFormat::R_8, |
| 17 BufferFormat::RGBA_4444, BufferFormat::RGBA_8888, |
| 18 BufferFormat::BGRX_8888, BufferFormat::BGRA_8888, |
| 19 BufferFormat::UYVY_422, BufferFormat::YUV_420_BIPLANAR, |
| 20 BufferFormat::YUV_420}; |
| 21 |
| 22 static_assert(arraysize(kBufferFormats) == |
| 23 (static_cast<int>(BufferFormat::LAST) + 1), |
| 24 "BufferFormat::LAST must be last value of kBufferFormats"); |
| 25 |
| 26 } // namespace |
| 27 |
| 28 std::vector<BufferFormat> GetBufferFormats() { |
| 29 return std::vector<BufferFormat>(kBufferFormats, |
| 30 kBufferFormats + arraysize(kBufferFormats)); |
| 31 } |
11 | 32 |
12 size_t NumberOfPlanesForBufferFormat(BufferFormat format) { | 33 size_t NumberOfPlanesForBufferFormat(BufferFormat format) { |
13 switch (format) { | 34 switch (format) { |
14 case BufferFormat::ATC: | 35 case BufferFormat::ATC: |
15 case BufferFormat::ATCIA: | 36 case BufferFormat::ATCIA: |
16 case BufferFormat::DXT1: | 37 case BufferFormat::DXT1: |
17 case BufferFormat::DXT5: | 38 case BufferFormat::DXT5: |
18 case BufferFormat::ETC1: | 39 case BufferFormat::ETC1: |
19 case BufferFormat::R_8: | 40 case BufferFormat::R_8: |
20 case BufferFormat::RGBA_4444: | 41 case BufferFormat::RGBA_4444: |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return false; | 162 return false; |
142 checked_size += checked_plane_size.ValueOrDie(); | 163 checked_size += checked_plane_size.ValueOrDie(); |
143 if (!checked_size.IsValid()) | 164 if (!checked_size.IsValid()) |
144 return false; | 165 return false; |
145 } | 166 } |
146 *size_in_bytes = checked_size.ValueOrDie(); | 167 *size_in_bytes = checked_size.ValueOrDie(); |
147 return true; | 168 return true; |
148 } | 169 } |
149 | 170 |
150 } // namespace gfx | 171 } // namespace gfx |
OLD | NEW |