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 "cc/test/test_gpu_memory_buffer_manager.h" | 5 #include "cc/test/test_gpu_memory_buffer_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
9 #include "ui/gfx/buffer_format_util.h" | 9 #include "ui/gfx/buffer_format_util.h" |
10 #include "ui/gfx/gpu_memory_buffer.h" | 10 #include "ui/gfx/gpu_memory_buffer.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 case gfx::BufferFormat::RGBA_4444: | 23 case gfx::BufferFormat::RGBA_4444: |
24 case gfx::BufferFormat::RGBA_8888: | 24 case gfx::BufferFormat::RGBA_8888: |
25 case gfx::BufferFormat::RGBX_8888: | 25 case gfx::BufferFormat::RGBX_8888: |
26 case gfx::BufferFormat::BGRA_8888: | 26 case gfx::BufferFormat::BGRA_8888: |
27 return 1; | 27 return 1; |
28 case gfx::BufferFormat::YUV_420: { | 28 case gfx::BufferFormat::YUV_420: { |
29 static size_t factor[] = {1, 2, 2}; | 29 static size_t factor[] = {1, 2, 2}; |
30 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); | 30 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); |
31 return factor[plane]; | 31 return factor[plane]; |
32 } | 32 } |
| 33 case gfx::BufferFormat::YUV_420_BIPLANAR: { |
| 34 static size_t factor[] = {1, 2}; |
| 35 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); |
| 36 return factor[plane]; |
| 37 } |
33 } | 38 } |
34 NOTREACHED(); | 39 NOTREACHED(); |
35 return 0; | 40 return 0; |
36 } | 41 } |
37 | 42 |
38 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) { | 43 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) { |
39 switch (format) { | 44 switch (format) { |
40 case gfx::BufferFormat::ATCIA: | 45 case gfx::BufferFormat::ATCIA: |
41 case gfx::BufferFormat::DXT5: | 46 case gfx::BufferFormat::DXT5: |
42 DCHECK_EQ(plane, 0); | 47 DCHECK_EQ(plane, 0); |
43 return width; | 48 return width; |
44 case gfx::BufferFormat::ATC: | 49 case gfx::BufferFormat::ATC: |
45 case gfx::BufferFormat::DXT1: | 50 case gfx::BufferFormat::DXT1: |
46 case gfx::BufferFormat::ETC1: | 51 case gfx::BufferFormat::ETC1: |
47 DCHECK_EQ(plane, 0); | 52 DCHECK_EQ(plane, 0); |
48 DCHECK_EQ(width % 2, 0u); | 53 DCHECK_EQ(width % 2, 0u); |
49 return width / 2; | 54 return width / 2; |
50 case gfx::BufferFormat::R_8: | 55 case gfx::BufferFormat::R_8: |
51 return (width + 3) & ~0x3; | 56 return (width + 3) & ~0x3; |
52 case gfx::BufferFormat::RGBA_4444: | 57 case gfx::BufferFormat::RGBA_4444: |
53 DCHECK_EQ(plane, 0); | 58 DCHECK_EQ(plane, 0); |
54 return width * 2; | 59 return width * 2; |
55 case gfx::BufferFormat::RGBA_8888: | 60 case gfx::BufferFormat::RGBA_8888: |
56 case gfx::BufferFormat::RGBX_8888: | 61 case gfx::BufferFormat::RGBX_8888: |
57 case gfx::BufferFormat::BGRA_8888: | 62 case gfx::BufferFormat::BGRA_8888: |
58 DCHECK_EQ(plane, 0); | 63 DCHECK_EQ(plane, 0); |
59 return width * 4; | 64 return width * 4; |
60 case gfx::BufferFormat::YUV_420: | 65 case gfx::BufferFormat::YUV_420: |
61 return width / SubsamplingFactor(format, plane); | 66 return width / SubsamplingFactor(format, plane); |
| 67 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 68 return width; |
62 } | 69 } |
63 NOTREACHED(); | 70 NOTREACHED(); |
64 return 0; | 71 return 0; |
65 } | 72 } |
66 | 73 |
67 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) { | 74 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) { |
68 size_t size_in_bytes = 0; | 75 size_t size_in_bytes = 0; |
69 int num_planes = static_cast<int>(gfx::NumberOfPlanesForBufferFormat(format)); | 76 int num_planes = static_cast<int>(gfx::NumberOfPlanesForBufferFormat(format)); |
70 for (int i = 0; i < num_planes; ++i) { | 77 for (int i = 0; i < num_planes; ++i) { |
71 size_in_bytes += StrideInBytes(size.width(), format, i) * | 78 size_in_bytes += StrideInBytes(size.width(), format, i) * |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ClientBuffer buffer) { | 166 ClientBuffer buffer) { |
160 return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer); | 167 return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer); |
161 } | 168 } |
162 | 169 |
163 void TestGpuMemoryBufferManager::SetDestructionSyncPoint( | 170 void TestGpuMemoryBufferManager::SetDestructionSyncPoint( |
164 gfx::GpuMemoryBuffer* buffer, | 171 gfx::GpuMemoryBuffer* buffer, |
165 uint32 sync_point) { | 172 uint32 sync_point) { |
166 } | 173 } |
167 | 174 |
168 } // namespace cc | 175 } // namespace cc |
OLD | NEW |