Chromium Code Reviews| Index: content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc |
| diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc b/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc |
| index 3a4789f2e18218f3d042b36e801b0ddd428d2abd..94046f1cf15cbc09d4e95e51149342423fdb161b 100644 |
| --- a/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc |
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc |
| @@ -110,16 +110,27 @@ TEST_P(GpuMemoryBufferImplTest, Map) { |
| buffer->GetStride(strides.get()); |
| // Copy and compare mapped buffers. |
| - for (size_t i = 0; i < num_planes; ++i) { |
| - size_t width_in_bytes = 0u; |
| - EXPECT_TRUE(GpuMemoryBufferImpl::StrideInBytes( |
| - buffer_size.width(), configuration.format, i, &width_in_bytes)); |
| - EXPECT_GT(width_in_bytes, 0u); |
| - |
| - scoped_ptr<char[]> data(new char[width_in_bytes]); |
| - memset(data.get(), 0x2a + i, width_in_bytes); |
| - memcpy(mapped_buffers[i], data.get(), width_in_bytes); |
| - EXPECT_EQ(memcmp(mapped_buffers[i], data.get(), width_in_bytes), 0); |
| + for (size_t plane = 0; plane < num_planes; ++plane) { |
| + size_t row_size_in_bytes = 0; |
| + EXPECT_TRUE(GpuMemoryBufferImpl::RowSizeInBytes( |
| + buffer_size.width(), configuration.format, plane, |
| + &row_size_in_bytes)); |
| + EXPECT_GT(row_size_in_bytes, 0u); |
| + |
| + scoped_ptr<char[]> data(new char[row_size_in_bytes]); |
| + memset(data.get(), 0x2a + plane, row_size_in_bytes); |
| + |
| + size_t height = |
| + buffer_size.height() / |
| + GpuMemoryBufferImpl::SubsamplingFactor(configuration.format, plane); |
| + for (size_t y = 0; y < height; ++y) { |
| + memcpy(static_cast<char*>(mapped_buffers[plane]) + y * strides[plane], |
| + data.get(), row_size_in_bytes); |
| + EXPECT_EQ(memcmp(static_cast<char*>(mapped_buffers[plane]) + |
|
Daniele Castagna
2015/04/27 19:07:47
Not sure what you're testing here, just that copyi
reveman
2015/04/27 19:30:30
We're testing the storage and the memory mapping,
Daniele Castagna
2015/04/27 19:43:56
Just looking at the code, and seeing
memcpy(target
reveman
2015/04/27 20:28:08
It could crash and it could fail if there's someth
|
| + y * strides[plane], |
| + data.get(), row_size_in_bytes), |
| + 0); |
| + } |
| } |
| buffer->Unmap(); |