Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils_unittest.cc

Issue 1508953002: Implement helper functionalities for computing image size with ES3 settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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>(params.row_length * 3), unpadded_row_size);
351 EXPECT_EQ(unpadded_row_size, padded_row_size);
352 EXPECT_EQ(padded_row_size * kHeight * kDepth, size);
353 EXPECT_EQ(0u, skip_size);
354 }
355
356 { // image_height
357 PixelStoreParams params;
358 params.image_height = kHeight + 1;
359 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes(
360 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params,
361 &size, &unpadded_row_size, &padded_row_size, &skip_size));
362 EXPECT_EQ(kWidth * 3, unpadded_row_size);
363 EXPECT_EQ(kWidth * 3 + 3, padded_row_size);
364 EXPECT_EQ(padded_row_size * (params.image_height * kDepth - 1) +
365 unpadded_row_size, size);
366 EXPECT_EQ(0u, skip_size);
367 }
368
369 { // skip_pixels, skip_rows, skip_images
370 PixelStoreParams params;
371 params.skip_pixels = 1;
372 params.skip_rows = 10;
373 params.skip_images = 2;
374 EXPECT_TRUE(GLES2Util::ComputeImageDataSizes(
375 kWidth, kHeight, kDepth, GL_RGB, GL_UNSIGNED_BYTE, params,
376 &size, &unpadded_row_size, &padded_row_size, &skip_size));
377 EXPECT_EQ(kWidth * 3, unpadded_row_size);
378 EXPECT_EQ(kWidth * 3 + 3, padded_row_size);
379 EXPECT_EQ(padded_row_size * kHeight * params.skip_images +
380 padded_row_size * params.skip_rows + 3 * params.skip_pixels,
381 skip_size);
382 EXPECT_EQ(padded_row_size * (kWidth * kDepth - 1) + unpadded_row_size +
383 skip_size, size);
384 }
385 }
386
323 TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) { 387 TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) {
324 EXPECT_EQ(1u, GLES2Util::RenderbufferBytesPerPixel(GL_STENCIL_INDEX8)); 388 EXPECT_EQ(1u, GLES2Util::RenderbufferBytesPerPixel(GL_STENCIL_INDEX8));
325 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA4)); 389 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA4));
326 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB565)); 390 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB565));
327 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB5_A1)); 391 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB5_A1));
328 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT16)); 392 EXPECT_EQ(2u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH_COMPONENT16));
329 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB)); 393 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGB));
330 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA)); 394 EXPECT_EQ(4u, GLES2Util::RenderbufferBytesPerPixel(GL_RGBA));
331 EXPECT_EQ( 395 EXPECT_EQ(
332 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES)); 396 4u, GLES2Util::RenderbufferBytesPerPixel(GL_DEPTH24_STENCIL8_OES));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 if (!parsed_name.IsArrayName()) { 461 if (!parsed_name.IsArrayName()) {
398 continue; 462 continue;
399 } 463 }
400 EXPECT_EQ(testcase.base_name, parsed_name.base_name()); 464 EXPECT_EQ(testcase.base_name, parsed_name.base_name());
401 EXPECT_EQ(testcase.element_index, parsed_name.element_index()); 465 EXPECT_EQ(testcase.element_index, parsed_name.element_index());
402 } 466 }
403 } 467 }
404 468
405 } // namespace gles2 469 } // namespace gles2
406 } // namespace gpu 470 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698