| 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 ba55d78349e7b44111439920cad1f98c682d4797..d73dae758c4649bce90563fc82d02862091682cf 100644
|
| --- a/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc
|
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc
|
| @@ -52,7 +52,7 @@ class GpuMemoryBufferImplTest
|
| TEST_P(GpuMemoryBufferImplTest, CreateFromHandle) {
|
| const int kBufferId = 1;
|
|
|
| - gfx::Size buffer_size(1, 1);
|
| + gfx::Size buffer_size(8, 8);
|
|
|
| for (auto configuration : supported_configurations_) {
|
| scoped_ptr<GpuMemoryBufferImpl> buffer(
|
| @@ -79,42 +79,50 @@ TEST_P(GpuMemoryBufferImplTest, CreateFromHandle) {
|
| TEST_P(GpuMemoryBufferImplTest, Map) {
|
| const int kBufferId = 1;
|
|
|
| - gfx::Size buffer_size(1, 1);
|
| + gfx::Size buffer_size(2, 2);
|
|
|
| for (auto configuration : supported_configurations_) {
|
| if (configuration.usage != gfx::GpuMemoryBuffer::MAP)
|
| continue;
|
|
|
| - size_t width_in_bytes = 0;
|
| - EXPECT_TRUE(GpuMemoryBufferImpl::StrideInBytes(
|
| - buffer_size.width(), configuration.format, &width_in_bytes));
|
| - EXPECT_GT(width_in_bytes, 0u);
|
| - scoped_ptr<char[]> data(new char[width_in_bytes]);
|
| - memset(data.get(), 0x2a, width_in_bytes);
|
| -
|
| scoped_ptr<GpuMemoryBufferImpl> buffer(
|
| GpuMemoryBufferImpl::CreateFromHandle(
|
| - CreateGpuMemoryBuffer(kBufferId,
|
| - buffer_size,
|
| - configuration.format,
|
| + CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format,
|
| configuration.usage),
|
| - buffer_size,
|
| - configuration.format,
|
| + buffer_size, configuration.format,
|
| base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer,
|
| - base::Unretained(this),
|
| - kBufferId)));
|
| + base::Unretained(this), kBufferId)));
|
| ASSERT_TRUE(buffer);
|
| EXPECT_FALSE(buffer->IsMapped());
|
|
|
| - void* memory;
|
| - bool rv = buffer->Map(&memory);
|
| + size_t num_planes =
|
| + GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat(
|
| + configuration.format);
|
| +
|
| + // Map buffer into user space.
|
| + scoped_ptr<void*[]> mapped_buffers(new void*[num_planes]);
|
| + bool rv = buffer->Map(mapped_buffers.get());
|
| ASSERT_TRUE(rv);
|
| EXPECT_TRUE(buffer->IsMapped());
|
| - uint32 stride;
|
| - buffer->GetStride(&stride);
|
| - EXPECT_GE(stride, width_in_bytes);
|
| - memcpy(memory, data.get(), width_in_bytes);
|
| - EXPECT_EQ(memcmp(memory, data.get(), width_in_bytes), 0);
|
| +
|
| + // Get strides.
|
| + scoped_ptr<uint32[]> strides(new uint32[num_planes]);
|
| + 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);
|
| + EXPECT_GE(strides[i], width_in_bytes);
|
| +
|
| + 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);
|
| + }
|
| +
|
| buffer->Unmap();
|
| EXPECT_FALSE(buffer->IsMapped());
|
| }
|
|
|