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::ComputeImageDataSizesES3( | |
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 > width | |
345 PixelStoreParams params; | |
346 params.row_length = kWidth + 2; | |
347 uint32_t kPadding = 1; // 5 * 3 = 15 -> 16 | |
348 EXPECT_TRUE(GLES2Util::ComputeImageDataSizesES3( | |
349 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
350 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
351 EXPECT_EQ(static_cast<uint32_t>(kWidth * 3), unpadded_row_size); | |
352 EXPECT_EQ(static_cast<uint32_t>(params.row_length * 3 + kPadding), | |
353 padded_row_size); | |
354 EXPECT_EQ(padded_row_size * (kHeight * kDepth - 1) + unpadded_row_size, | |
355 size); | |
356 EXPECT_EQ(0u, skip_size); | |
357 } | |
358 | |
359 { // row_length < width | |
360 PixelStoreParams params; | |
361 params.row_length = kWidth - 1; | |
362 uint32_t kPadding = 2; // 2 * 3 = 6 -> 8 | |
363 EXPECT_TRUE(GLES2Util::ComputeImageDataSizesES3( | |
364 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
365 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
366 EXPECT_EQ(static_cast<uint32_t>(kWidth * 3), unpadded_row_size); | |
367 EXPECT_EQ(static_cast<uint32_t>(params.row_length * 3 + kPadding), | |
368 padded_row_size); | |
369 EXPECT_EQ(padded_row_size * (kHeight * kDepth - 1) + unpadded_row_size, | |
370 size); | |
371 EXPECT_EQ(0u, skip_size); | |
372 } | |
373 | |
374 { // image_height > height | |
375 PixelStoreParams params; | |
376 params.image_height = kHeight + 1; | |
377 uint32_t kPadding = 3; // 3 * 3 = 9 -> 21 | |
378 EXPECT_TRUE(GLES2Util::ComputeImageDataSizesES3( | |
379 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
380 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
381 EXPECT_EQ(kWidth * 3, unpadded_row_size); | |
382 EXPECT_EQ(kWidth * 3 + kPadding, padded_row_size); | |
383 EXPECT_EQ((params.image_height * (kDepth - 1) + kHeight - 1) * | |
384 padded_row_size + unpadded_row_size, size); | |
385 EXPECT_EQ(0u, skip_size); | |
386 } | |
387 | |
388 { // image_height < height | |
389 PixelStoreParams params; | |
390 params.image_height = kHeight - 1; | |
391 uint32_t kPadding = 3; // 3 * 3 = 9 -> 12 | |
392 EXPECT_TRUE(GLES2Util::ComputeImageDataSizesES3( | |
393 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
394 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
395 EXPECT_EQ(kWidth * 3, unpadded_row_size); | |
396 EXPECT_EQ(kWidth * 3 + kPadding, padded_row_size); | |
397 EXPECT_EQ((params.image_height * (kDepth - 1) + kHeight - 1) * | |
398 padded_row_size + unpadded_row_size, size); | |
399 EXPECT_EQ(0u, skip_size); | |
400 } | |
401 | |
402 { // skip_pixels, skip_rows, skip_images, alignment = 4, RGB | |
403 PixelStoreParams params; | |
404 params.skip_pixels = 1; | |
405 params.skip_rows = 10; | |
406 params.skip_images = 2; | |
407 uint32_t kPadding = 3; // 3 * 3 = 9 -> 12 | |
408 EXPECT_TRUE(GLES2Util::ComputeImageDataSizesES3( | |
409 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params, | |
410 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
411 EXPECT_EQ(kWidth * 3, unpadded_row_size); | |
412 EXPECT_EQ(kWidth * 3 + kPadding, padded_row_size); | |
413 EXPECT_EQ(padded_row_size * kHeight * params.skip_images + | |
414 padded_row_size * params.skip_rows + 3 * params.skip_pixels, | |
415 skip_size); | |
416 EXPECT_EQ(padded_row_size * (kWidth * kDepth - 1) + unpadded_row_size, | |
417 size); | |
418 } | |
419 | |
420 { // skip_pixels, skip_rows, skip_images, alignment = 8, RGBA | |
421 PixelStoreParams params; | |
422 params.skip_pixels = 1; | |
423 params.skip_rows = 10; | |
424 params.skip_images = 2; | |
425 params.alignment = 8; | |
426 uint32_t kPadding = 4; // 3 * 4 = 12 -> 16 | |
427 EXPECT_TRUE(GLES2Util::ComputeImageDataSizesES3( | |
428 kWidth, kHeight, kDepth, GL_RGBA, GL_UNSIGNED_BYTE, params, | |
429 &size, &unpadded_row_size, &padded_row_size, &skip_size)); | |
430 EXPECT_EQ(kWidth * 4, unpadded_row_size); | |
431 EXPECT_EQ(kWidth * 4 + kPadding, padded_row_size); | |
432 EXPECT_EQ(padded_row_size * kHeight * params.skip_images + | |
433 padded_row_size * params.skip_rows + 4 * params.skip_pixels, | |
434 skip_size); | |
435 EXPECT_EQ(padded_row_size * (kWidth * kDepth - 1) + unpadded_row_size, | |
436 size); | |
437 } | |
438 } | |
439 | |
440 TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) { | 323 TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) { |
441 EXPECT_EQ(1u, GLES2Util::RenderbufferBytesPerPixel(GL_STENCIL_INDEX8)); | 324 EXPECT_EQ(1u, GLES2Util::RenderbufferBytesPerPixel(GL_STENCIL_INDEX8)); |
442 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA4)); | 325 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA4)); |
443 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB565)); | 326 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB565)); |
444 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB5_A1)); | 327 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB5_A1)); |
445 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT16)); | 328 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT16)); |
446 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB)); | 329 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB)); |
447 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA)); | 330 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA)); |
448 EXPECT_EQ( | 331 EXPECT_EQ( |
449 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES)); | 332 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 if (!parsed_name.IsArrayName()) { | 397 if (!parsed_name.IsArrayName()) { |
515 continue; | 398 continue; |
516 } | 399 } |
517 EXPECT_EQ(testcase.base_name, parsed_name.base_name()); | 400 EXPECT_EQ(testcase.base_name, parsed_name.base_name()); |
518 EXPECT_EQ(testcase.element_index, parsed_name.element_index()); | 401 EXPECT_EQ(testcase.element_index, parsed_name.element_index()); |
519 } | 402 } |
520 } | 403 } |
521 | 404 |
522 } // namespace gles2 | 405 } // namespace gles2 |
523 } // namespace gpu | 406 } // namespace gpu |
OLD | NEW |