| 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/gpu_memory_buffer.h" | 9 #include "ui/gfx/gpu_memory_buffer.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 case gfx::BufferFormat::RGBA_4444: | 22 case gfx::BufferFormat::RGBA_4444: |
| 23 case gfx::BufferFormat::RGBA_8888: | 23 case gfx::BufferFormat::RGBA_8888: |
| 24 case gfx::BufferFormat::RGBX_8888: | 24 case gfx::BufferFormat::RGBX_8888: |
| 25 case gfx::BufferFormat::BGRA_8888: | 25 case gfx::BufferFormat::BGRA_8888: |
| 26 return 1; | 26 return 1; |
| 27 case gfx::BufferFormat::YUV_420: { | 27 case gfx::BufferFormat::YUV_420: { |
| 28 static size_t factor[] = {1, 2, 2}; | 28 static size_t factor[] = {1, 2, 2}; |
| 29 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); | 29 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); |
| 30 return factor[plane]; | 30 return factor[plane]; |
| 31 } | 31 } |
| 32 case gfx::BufferFormat::YUV_420_BIPLANAR: { |
| 33 static size_t factor[] = {1, 2}; |
| 34 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); |
| 35 return factor[plane]; |
| 36 } |
| 32 } | 37 } |
| 33 NOTREACHED(); | 38 NOTREACHED(); |
| 34 return 0; | 39 return 0; |
| 35 } | 40 } |
| 36 | 41 |
| 37 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) { | 42 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) { |
| 38 switch (format) { | 43 switch (format) { |
| 39 case gfx::BufferFormat::ATCIA: | 44 case gfx::BufferFormat::ATCIA: |
| 40 case gfx::BufferFormat::DXT5: | 45 case gfx::BufferFormat::DXT5: |
| 41 DCHECK_EQ(plane, 0); | 46 DCHECK_EQ(plane, 0); |
| 42 return width; | 47 return width; |
| 43 case gfx::BufferFormat::ATC: | 48 case gfx::BufferFormat::ATC: |
| 44 case gfx::BufferFormat::DXT1: | 49 case gfx::BufferFormat::DXT1: |
| 45 case gfx::BufferFormat::ETC1: | 50 case gfx::BufferFormat::ETC1: |
| 46 DCHECK_EQ(plane, 0); | 51 DCHECK_EQ(plane, 0); |
| 47 DCHECK_EQ(width % 2, 0u); | 52 DCHECK_EQ(width % 2, 0u); |
| 48 return width / 2; | 53 return width / 2; |
| 49 case gfx::BufferFormat::R_8: | 54 case gfx::BufferFormat::R_8: |
| 50 return (width + 3) & ~0x3; | 55 return (width + 3) & ~0x3; |
| 51 case gfx::BufferFormat::RGBA_4444: | 56 case gfx::BufferFormat::RGBA_4444: |
| 52 DCHECK_EQ(plane, 0); | 57 DCHECK_EQ(plane, 0); |
| 53 return width * 2; | 58 return width * 2; |
| 54 case gfx::BufferFormat::RGBA_8888: | 59 case gfx::BufferFormat::RGBA_8888: |
| 55 case gfx::BufferFormat::RGBX_8888: | 60 case gfx::BufferFormat::RGBX_8888: |
| 56 case gfx::BufferFormat::BGRA_8888: | 61 case gfx::BufferFormat::BGRA_8888: |
| 57 DCHECK_EQ(plane, 0); | 62 DCHECK_EQ(plane, 0); |
| 58 return width * 4; | 63 return width * 4; |
| 59 case gfx::BufferFormat::YUV_420: | 64 case gfx::BufferFormat::YUV_420: |
| 60 return width / SubsamplingFactor(format, plane); | 65 return width / SubsamplingFactor(format, plane); |
| 66 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 67 return width; |
| 61 } | 68 } |
| 62 NOTREACHED(); | 69 NOTREACHED(); |
| 63 return 0; | 70 return 0; |
| 64 } | 71 } |
| 65 | 72 |
| 66 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) { | 73 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) { |
| 67 size_t size_in_bytes = 0; | 74 size_t size_in_bytes = 0; |
| 68 int num_planes = | 75 int num_planes = |
| 69 static_cast<int>(gfx::GpuMemoryBuffer::NumberOfPlanes(format)); | 76 static_cast<int>(gfx::GpuMemoryBuffer::NumberOfPlanes(format)); |
| 70 for (int i = 0; i < num_planes; ++i) { | 77 for (int i = 0; i < num_planes; ++i) { |
| (...skipping 88 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 |