Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: ui/gfx/buffer_format_util.cc

Issue 1389133002: content: Use type-parameterized tests for GpuMemoryBuffer implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SurfaceTexture fix Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 static_assert(arraysize(kBufferFormats) ==
sky 2015/10/07 17:35:13 nit: a newline would be nice between 20 and 21.
reveman 2015/10/07 18:12:57 Done.
22 (static_cast<int>(BufferFormat::LAST) + 1),
23 "BufferFormat::LAST must be last value of kBufferFormats");
24
25 } // namespace
26
27 std::vector<BufferFormat> GetBufferFormats() {
28 return std::vector<BufferFormat>(kBufferFormats,
29 kBufferFormats + arraysize(kBufferFormats));
30 }
11 31
12 size_t NumberOfPlanesForBufferFormat(BufferFormat format) { 32 size_t NumberOfPlanesForBufferFormat(BufferFormat format) {
13 switch (format) { 33 switch (format) {
14 case BufferFormat::ATC: 34 case BufferFormat::ATC:
15 case BufferFormat::ATCIA: 35 case BufferFormat::ATCIA:
16 case BufferFormat::DXT1: 36 case BufferFormat::DXT1:
17 case BufferFormat::DXT5: 37 case BufferFormat::DXT5:
18 case BufferFormat::ETC1: 38 case BufferFormat::ETC1:
19 case BufferFormat::R_8: 39 case BufferFormat::R_8:
20 case BufferFormat::RGBA_4444: 40 case BufferFormat::RGBA_4444:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return false; 161 return false;
142 checked_size += checked_plane_size.ValueOrDie(); 162 checked_size += checked_plane_size.ValueOrDie();
143 if (!checked_size.IsValid()) 163 if (!checked_size.IsValid())
144 return false; 164 return false;
145 } 165 }
146 *size_in_bytes = checked_size.ValueOrDie(); 166 *size_in_bytes = checked_size.ValueOrDie();
147 return true; 167 return true;
148 } 168 }
149 169
150 } // namespace gfx 170 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698