Chromium Code Reviews| Index: gpu/command_buffer/common/gles2_cmd_utils_unittest.cc |
| diff --git a/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc b/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc |
| index 3eb2a3870561a00bf21c429863325852f7178a43..02b30dedcf8965237beb8e1d36cf02e0512fbd51 100644 |
| --- a/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc |
| +++ b/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc |
| @@ -320,6 +320,71 @@ TEST_F(GLES2UtilTest, ComputeImageDataSizeDepth) { |
| EXPECT_EQ(kWidth * 3 + 7, padded_row_size); |
| } |
| +TEST_F(GLES2UtilTest, ComputeImageDataSizePixelStoreParams) { |
| + const uint32_t kWidth = 3; |
| + const uint32_t kHeight = 3; |
| + const uint32_t kDepth = 3; |
| + uint32_t size; |
| + uint32_t unpadded_row_size; |
| + uint32_t padded_row_size; |
| + uint32_t skip_size; |
| + |
| + { // Default |
| + PixelStoreParams params; |
| + EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( |
| + kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, |
| + &size, &unpadded_row_size, &padded_row_size, &skip_size)); |
| + EXPECT_EQ(kWidth * 3, unpadded_row_size); |
| + EXPECT_EQ(kWidth * 3 + 3, padded_row_size); |
| + EXPECT_EQ(padded_row_size * (kHeight * kDepth - 1) + unpadded_row_size, |
| + size); |
| + EXPECT_EQ(0u, skip_size); |
| + } |
| + |
| + { // row_length |
| + PixelStoreParams params; |
| + params.row_length = kWidth + 1; |
| + EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( |
| + kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, |
| + &size, &unpadded_row_size, &padded_row_size, &skip_size)); |
| + EXPECT_EQ(static_cast<uint32_t>(kWidth * 3), unpadded_row_size); |
| + EXPECT_EQ(static_cast<uint32_t>(params.row_length * 3), padded_row_size); |
| + EXPECT_EQ(padded_row_size * (kHeight * kDepth - 1) + unpadded_row_size, |
| + size); |
| + EXPECT_EQ(0u, skip_size); |
| + } |
| + |
| + { // image_height |
| + PixelStoreParams params; |
| + params.image_height = kHeight + 1; |
| + EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( |
| + kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, |
| + &size, &unpadded_row_size, &padded_row_size, &skip_size)); |
| + EXPECT_EQ(kWidth * 3, unpadded_row_size); |
| + EXPECT_EQ(kWidth * 3 + 3, padded_row_size); |
| + EXPECT_EQ((params.image_height * (kDepth - 1) + kHeight - 1) * |
| + padded_row_size + unpadded_row_size, size); |
| + EXPECT_EQ(0u, skip_size); |
| + } |
| + |
| + { // skip_pixels, skip_rows, skip_images |
|
Ken Russell (switch to Gerrit)
2015/12/09 00:05:50
Perhaps add another test that also changes the pac
Zhenyao Mo
2015/12/09 00:27:57
Done.
|
| + PixelStoreParams params; |
| + params.skip_pixels = 1; |
| + params.skip_rows = 10; |
| + params.skip_images = 2; |
| + EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( |
| + kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, |
| + &size, &unpadded_row_size, &padded_row_size, &skip_size)); |
| + EXPECT_EQ(kWidth * 3, unpadded_row_size); |
| + EXPECT_EQ(kWidth * 3 + 3, padded_row_size); |
| + EXPECT_EQ(padded_row_size * kHeight * params.skip_images + |
| + padded_row_size * params.skip_rows + 3 * params.skip_pixels, |
| + skip_size); |
| + EXPECT_EQ(padded_row_size * (kWidth * kDepth - 1) + unpadded_row_size, |
| + size); |
| + } |
| +} |
| + |
| TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) { |
| EXPECT_EQ(1u, GLES2Util::RenderbufferBytesPerPixel(GL_STENCIL_INDEX8)); |
| EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA4)); |