OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/common/gles2_cmd_utils.h" | 5 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 EXPECT_EQ(kWidth * 3 + 3, padded_row_size); | 313 EXPECT_EQ(kWidth * 3 + 3, padded_row_size); |
314 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( | 314 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( |
315 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, 8, &size, | 315 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, 8, &size, |
316 &unpadded_row_size, &padded_row_size)); | 316 &unpadded_row_size, &padded_row_size)); |
317 EXPECT_EQ((kWidth * 3 + 7) * (kHeight * kDepth - 1) + | 317 EXPECT_EQ((kWidth * 3 + 7) * (kHeight * kDepth - 1) + |
318 kWidth * 3, size); | 318 kWidth * 3, size); |
319 EXPECT_EQ(kWidth * 3, unpadded_row_size); | 319 EXPECT_EQ(kWidth * 3, unpadded_row_size); |
320 EXPECT_EQ(kWidth * 3 + 7, padded_row_size); | 320 EXPECT_EQ(kWidth * 3 + 7, padded_row_size); |
321 } | 321 } |
322 | 322 |
323 TEST_F(GLES2UtilTest, ComputeImageDataSizePixelStoreParams) { | |
324 const uint32_t kWidth = 3; | |
325 const uint32_t kHeight = 3; | |
326 const uint32_t kDepth = 3; | |
327 uint32_t size; | |
328 uint32_t unpadded_row_size; | |
329 uint32_t padded_row_size; | |
330 uint32_t skip_size; | |
331 | |
332 { // Default | |
333 PixelStoreParams params; | |
334 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( | |
335 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
336 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
337 EXPECT_EQ(kWidth * 3, unpadded_row_size); | |
338 EXPECT_EQ(kWidth * 3 + 3, padded_row_size); | |
339 EXPECT_EQ(padded_row_size * (kHeight * kDepth - 1) + unpadded_row_size, | |
340 size); | |
341 EXPECT_EQ(0u, skip_size); | |
342 } | |
343 | |
344 { // row_length | |
345 PixelStoreParams params; | |
346 params.row_length = kWidth + 1; | |
347 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( | |
348 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
349 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
350 EXPECT_EQ(static_cast<uint32_t>(kWidth * 3), unpadded_row_size); | |
351 EXPECT_EQ(static_cast<uint32_t>(params.row_length * 3), padded_row_size); | |
352 EXPECT_EQ(padded_row_size * (kHeight * kDepth - 1) + unpadded_row_size, | |
353 size); | |
354 EXPECT_EQ(0u, skip_size); | |
355 } | |
356 | |
357 { // image_height | |
358 PixelStoreParams params; | |
359 params.image_height = kHeight + 1; | |
360 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( | |
361 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
362 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
363 EXPECT_EQ(kWidth * 3, unpadded_row_size); | |
364 EXPECT_EQ(kWidth * 3 + 3, padded_row_size); | |
365 EXPECT_EQ((params.image_height * (kDepth - 1) + kHeight - 1) * | |
366 padded_row_size + unpadded_row_size, size); | |
367 EXPECT_EQ(0u, skip_size); | |
368 } | |
369 | |
370 { // 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.
| |
371 PixelStoreParams params; | |
372 params.skip_pixels = 1; | |
373 params.skip_rows = 10; | |
374 params.skip_images = 2; | |
375 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes( | |
376 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
377 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
378 EXPECT_EQ(kWidth * 3, unpadded_row_size); | |
379 EXPECT_EQ(kWidth * 3 + 3, padded_row_size); | |
380 EXPECT_EQ(padded_row_size * kHeight * params.skip_images + | |
381 padded_row_size * params.skip_rows + 3 * params.skip_pixels, | |
382 skip_size); | |
383 EXPECT_EQ(padded_row_size * (kWidth * kDepth - 1) + unpadded_row_size, | |
384 size); | |
385 } | |
386 } | |
387 | |
323 TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) { | 388 TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) { |
324 EXPECT_EQ(1u, GLES2Util::RenderbufferBytesPerPixel(GL_STENCIL_INDEX8)); | 389 EXPECT_EQ(1u, GLES2Util::RenderbufferBytesPerPixel(GL_STENCIL_INDEX8)); |
325 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA4)); | 390 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA4)); |
326 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB565)); | 391 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB565)); |
327 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB5_A1)); | 392 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB5_A1)); |
328 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT16)); | 393 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT16)); |
329 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB)); | 394 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB)); |
330 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA)); | 395 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA)); |
331 EXPECT_EQ( | 396 EXPECT_EQ( |
332 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES)); | 397 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 if (!parsed_name.IsArrayName()) { | 462 if (!parsed_name.IsArrayName()) { |
398 continue; | 463 continue; |
399 } | 464 } |
400 EXPECT_EQ(testcase.base_name, parsed_name.base_name()); | 465 EXPECT_EQ(testcase.base_name, parsed_name.base_name()); |
401 EXPECT_EQ(testcase.element_index, parsed_name.element_index()); | 466 EXPECT_EQ(testcase.element_index, parsed_name.element_index()); |
402 } | 467 } |
403 } | 468 } |
404 | 469 |
405 } // namespace gles2 | 470 } // namespace gles2 |
406 } // namespace gpu | 471 } // namespace gpu |
OLD | NEW |