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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo part of clang-format Created 4 years, 8 months 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 // Tests for GLES2Implementation. 5 // Tests for GLES2Implementation.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
11 #include <GLES2/gl2extchromium.h> 11 #include <GLES2/gl2extchromium.h>
12 #include <GLES3/gl3.h> 12 #include <GLES3/gl3.h>
13 #include <stddef.h> 13 #include <stddef.h>
14 #include <stdint.h> 14 #include <stdint.h>
no sievers 2016/04/05 19:02:40 #include <memory>
Mostyn Bramley-Moore 2016/04/05 21:35:30 Done.
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "gpu/command_buffer/client/client_test_helper.h" 16 #include "gpu/command_buffer/client/client_test_helper.h"
17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
18 #include "gpu/command_buffer/client/program_info_manager.h" 18 #include "gpu/command_buffer/client/program_info_manager.h"
19 #include "gpu/command_buffer/client/query_tracker.h" 19 #include "gpu/command_buffer/client/query_tracker.h"
20 #include "gpu/command_buffer/client/ring_buffer.h" 20 #include "gpu/command_buffer/client/ring_buffer.h"
21 #include "gpu/command_buffer/client/transfer_buffer.h" 21 #include "gpu/command_buffer/client/transfer_buffer.h"
22 #include "gpu/command_buffer/common/command_buffer.h" 22 #include "gpu/command_buffer/common/command_buffer.h"
23 #include "gpu/command_buffer/common/sync_token.h" 23 #include "gpu/command_buffer/common/sync_token.h"
24 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 return command_buffer_.get(); 525 return command_buffer_.get();
526 } 526 }
527 527
528 int GetNextToken() { return ++token_; } 528 int GetNextToken() { return ++token_; }
529 529
530 void ClearCommands() { 530 void ClearCommands() {
531 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); 531 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer();
532 memset(ring_buffer->memory(), kInitialValue, ring_buffer->size()); 532 memset(ring_buffer->memory(), kInitialValue, ring_buffer->size());
533 } 533 }
534 534
535 scoped_ptr<MockClientCommandBuffer> command_buffer_; 535 std::unique_ptr<MockClientCommandBuffer> command_buffer_;
536 scoped_ptr<MockClientGpuControl> gpu_control_; 536 std::unique_ptr<MockClientGpuControl> gpu_control_;
537 scoped_ptr<GLES2CmdHelper> helper_; 537 std::unique_ptr<GLES2CmdHelper> helper_;
538 scoped_ptr<MockTransferBuffer> transfer_buffer_; 538 std::unique_ptr<MockTransferBuffer> transfer_buffer_;
539 scoped_ptr<GLES2Implementation> gl_; 539 std::unique_ptr<GLES2Implementation> gl_;
540 CommandBufferEntry* commands_; 540 CommandBufferEntry* commands_;
541 int token_; 541 int token_;
542 }; 542 };
543 543
544 GLES2ImplementationTest() : commands_(NULL) {} 544 GLES2ImplementationTest() : commands_(NULL) {}
545 545
546 void SetUp() override; 546 void SetUp() override;
547 void TearDown() override; 547 void TearDown() override;
548 548
549 bool NoCommandsWritten() { 549 bool NoCommandsWritten() {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 #endif 853 #endif
854 854
855 TEST_F(GLES2ImplementationTest, Basic) { 855 TEST_F(GLES2ImplementationTest, Basic) {
856 EXPECT_TRUE(gl_->share_group() != NULL); 856 EXPECT_TRUE(gl_->share_group() != NULL);
857 } 857 }
858 858
859 TEST_F(GLES2ImplementationTest, GetBucketContents) { 859 TEST_F(GLES2ImplementationTest, GetBucketContents) {
860 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; 860 const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
861 const uint32_t kTestSize = MaxTransferBufferSize() + 32; 861 const uint32_t kTestSize = MaxTransferBufferSize() + 32;
862 862
863 scoped_ptr<uint8_t[]> buf(new uint8_t[kTestSize]); 863 std::unique_ptr<uint8_t[]> buf(new uint8_t[kTestSize]);
864 uint8_t* expected_data = buf.get(); 864 uint8_t* expected_data = buf.get();
865 for (uint32_t ii = 0; ii < kTestSize; ++ii) { 865 for (uint32_t ii = 0; ii < kTestSize; ++ii) {
866 expected_data[ii] = ii * 3; 866 expected_data[ii] = ii * 3;
867 } 867 }
868 868
869 struct Cmds { 869 struct Cmds {
870 cmd::GetBucketStart get_bucket_start; 870 cmd::GetBucketStart get_bucket_start;
871 cmd::SetToken set_token1; 871 cmd::SetToken set_token1;
872 cmd::GetBucketData get_bucket_data; 872 cmd::GetBucketData get_bucket_data;
873 cmd::SetToken set_token2; 873 cmd::SetToken set_token2;
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 Cmds expected; 1720 Cmds expected;
1721 expected.read1.Init( 1721 expected.read1.Init(
1722 0, 0, kWidth, kHeight / 2, kFormat, kType, 1722 0, 0, kWidth, kHeight / 2, kFormat, kType,
1723 mem1.id, mem1.offset, result1.id, result1.offset, 1723 mem1.id, mem1.offset, result1.id, result1.offset,
1724 false); 1724 false);
1725 expected.set_token1.Init(GetNextToken()); 1725 expected.set_token1.Init(GetNextToken());
1726 expected.read2.Init( 1726 expected.read2.Init(
1727 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, 1727 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType,
1728 mem2.id, mem2.offset, result2.id, result2.offset, false); 1728 mem2.id, mem2.offset, result2.id, result2.offset, false);
1729 expected.set_token2.Init(GetNextToken()); 1729 expected.set_token2.Init(GetNextToken());
1730 scoped_ptr<int8_t[]> buffer(new int8_t[kWidth * kHeight * kBytesPerPixel]); 1730 std::unique_ptr<int8_t[]> buffer(
1731 new int8_t[kWidth * kHeight * kBytesPerPixel]);
1731 1732
1732 EXPECT_CALL(*command_buffer(), OnFlush()) 1733 EXPECT_CALL(*command_buffer(), OnFlush())
1733 .WillOnce(SetMemory(result1.ptr, static_cast<uint32_t>(1))) 1734 .WillOnce(SetMemory(result1.ptr, static_cast<uint32_t>(1)))
1734 .WillOnce(SetMemory(result2.ptr, static_cast<uint32_t>(1))) 1735 .WillOnce(SetMemory(result2.ptr, static_cast<uint32_t>(1)))
1735 .RetiresOnSaturation(); 1736 .RetiresOnSaturation();
1736 1737
1737 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); 1738 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
1738 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 1739 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1739 } 1740 }
1740 1741
(...skipping 11 matching lines...) Expand all
1752 ExpectedMemoryInfo mem1 = 1753 ExpectedMemoryInfo mem1 =
1753 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel); 1754 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel);
1754 ExpectedMemoryInfo result1 = 1755 ExpectedMemoryInfo result1 =
1755 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); 1756 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result));
1756 1757
1757 Cmds expected; 1758 Cmds expected;
1758 expected.read.Init( 1759 expected.read.Init(
1759 0, 0, kWidth, kHeight, kFormat, kType, 1760 0, 0, kWidth, kHeight, kFormat, kType,
1760 mem1.id, mem1.offset, result1.id, result1.offset, false); 1761 mem1.id, mem1.offset, result1.id, result1.offset, false);
1761 expected.set_token.Init(GetNextToken()); 1762 expected.set_token.Init(GetNextToken());
1762 scoped_ptr<int8_t[]> buffer(new int8_t[kWidth * kHeight * kBytesPerPixel]); 1763 std::unique_ptr<int8_t[]> buffer(
1764 new int8_t[kWidth * kHeight * kBytesPerPixel]);
1763 1765
1764 EXPECT_CALL(*command_buffer(), OnFlush()) 1766 EXPECT_CALL(*command_buffer(), OnFlush())
1765 .Times(1) 1767 .Times(1)
1766 .RetiresOnSaturation(); 1768 .RetiresOnSaturation();
1767 1769
1768 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); 1770 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
1769 } 1771 }
1770 1772
1771 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { 1773 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) {
1772 struct Cmds { 1774 struct Cmds {
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 uint32_t padded_row_size = 0; 2424 uint32_t padded_row_size = 0;
2423 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2425 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2424 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2426 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2425 &size, &unpadded_row_size, &padded_row_size)); 2427 &size, &unpadded_row_size, &padded_row_size));
2426 const GLsizei kMaxHeight = (MaxTransferBufferSize() / padded_row_size) * 2; 2428 const GLsizei kMaxHeight = (MaxTransferBufferSize() / padded_row_size) * 2;
2427 const GLsizei kHeight = kMaxHeight * 2; 2429 const GLsizei kHeight = kMaxHeight * 2;
2428 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2430 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2429 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2431 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2430 &size, &unpadded_row_size, &padded_row_size)); 2432 &size, &unpadded_row_size, &padded_row_size));
2431 2433
2432 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2434 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2433 for (uint32_t ii = 0; ii < size; ++ii) { 2435 for (uint32_t ii = 0; ii < size; ++ii) {
2434 pixels[ii] = static_cast<uint8_t>(ii); 2436 pixels[ii] = static_cast<uint8_t>(ii);
2435 } 2437 }
2436 2438
2437 ExpectedMemoryInfo mem1 = GetExpectedMappedMemory(size); 2439 ExpectedMemoryInfo mem1 = GetExpectedMappedMemory(size);
2438 2440
2439 Cmds expected; 2441 Cmds expected;
2440 expected.tex_image_2d.Init( 2442 expected.tex_image_2d.Init(
2441 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, 2443 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
2442 mem1.id, mem1.offset); 2444 mem1.id, mem1.offset);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 &size, &unpadded_row_size, &padded_row_size)); 2480 &size, &unpadded_row_size, &padded_row_size));
2479 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2; 2481 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2;
2480 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2482 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2481 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2483 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2482 &size, NULL, NULL)); 2484 &size, NULL, NULL));
2483 uint32_t half_size = 0; 2485 uint32_t half_size = 0;
2484 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2486 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2485 kWidth, kHeight / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2487 kWidth, kHeight / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2486 &half_size, NULL, NULL)); 2488 &half_size, NULL, NULL));
2487 2489
2488 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2490 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2489 for (uint32_t ii = 0; ii < size; ++ii) { 2491 for (uint32_t ii = 0; ii < size; ++ii) {
2490 pixels[ii] = static_cast<uint8_t>(ii); 2492 pixels[ii] = static_cast<uint8_t>(ii);
2491 } 2493 }
2492 2494
2493 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size); 2495 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size);
2494 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size); 2496 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size);
2495 2497
2496 Cmds expected; 2498 Cmds expected;
2497 expected.tex_image_2d.Init( 2499 expected.tex_image_2d.Init(
2498 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, 2500 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 cmds::TexSubImage2D tex_sub_image_2d; 2561 cmds::TexSubImage2D tex_sub_image_2d;
2560 } texSubImageExpected; 2562 } texSubImageExpected;
2561 2563
2562 uint32_t pixel_size; 2564 uint32_t pixel_size;
2563 PixelStoreParams pixel_params; 2565 PixelStoreParams pixel_params;
2564 // Makes sure the pixels size is large enough for all tests. 2566 // Makes sure the pixels size is large enough for all tests.
2565 pixel_params.alignment = 8; 2567 pixel_params.alignment = 8;
2566 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3( 2568 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3(
2567 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType, 2569 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType,
2568 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr)); 2570 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr));
2569 scoped_ptr<uint8_t[]> src_pixels; 2571 std::unique_ptr<uint8_t[]> src_pixels;
2570 src_pixels.reset(new uint8_t[pixel_size]); 2572 src_pixels.reset(new uint8_t[pixel_size]);
2571 for (size_t i = 0; i < pixel_size; ++i) { 2573 for (size_t i = 0; i < pixel_size; ++i) {
2572 src_pixels[i] = static_cast<uint8_t>(i % 255); 2574 src_pixels[i] = static_cast<uint8_t>(i % 255);
2573 } 2575 }
2574 2576
2575 for (int sub = 0; sub < 2; ++sub) { 2577 for (int sub = 0; sub < 2; ++sub) {
2576 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { 2578 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
2577 const void* commands = GetPut(); 2579 const void* commands = GetPut();
2578 2580
2579 GLint alignment = unpack_alignments[a]; 2581 GLint alignment = unpack_alignments[a];
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 cmds::TexSubImage3D tex_sub_image_3d; 2702 cmds::TexSubImage3D tex_sub_image_3d;
2701 } texSubImageExpected; 2703 } texSubImageExpected;
2702 2704
2703 uint32_t pixel_size; 2705 uint32_t pixel_size;
2704 PixelStoreParams pixel_params; 2706 PixelStoreParams pixel_params;
2705 // Makes sure the pixels size is large enough for all tests. 2707 // Makes sure the pixels size is large enough for all tests.
2706 pixel_params.alignment = 8; 2708 pixel_params.alignment = 8;
2707 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3( 2709 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3(
2708 kSrcWidth, kSrcSubImageY1, kSrcSubImageZ1, kFormat, kType, 2710 kSrcWidth, kSrcSubImageY1, kSrcSubImageZ1, kFormat, kType,
2709 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr)); 2711 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr));
2710 scoped_ptr<uint8_t[]> src_pixels; 2712 std::unique_ptr<uint8_t[]> src_pixels;
2711 src_pixels.reset(new uint8_t[pixel_size]); 2713 src_pixels.reset(new uint8_t[pixel_size]);
2712 for (size_t i = 0; i < pixel_size; ++i) { 2714 for (size_t i = 0; i < pixel_size; ++i) {
2713 src_pixels[i] = static_cast<uint8_t>(i % 255); 2715 src_pixels[i] = static_cast<uint8_t>(i % 255);
2714 } 2716 }
2715 2717
2716 for (int sub = 0; sub < 2; ++sub) { 2718 for (int sub = 0; sub < 2; ++sub) {
2717 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { 2719 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
2718 const void* commands = GetPut(); 2720 const void* commands = GetPut();
2719 2721
2720 GLint alignment = unpack_alignments[a]; 2722 GLint alignment = unpack_alignments[a];
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 uint32_t padded_row_size = 0; 2917 uint32_t padded_row_size = 0;
2916 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2918 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2917 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2919 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2918 &size, &unpadded_row_size, &padded_row_size)); 2920 &size, &unpadded_row_size, &padded_row_size));
2919 // Makes sure we can just send over the data in one command. 2921 // Makes sure we can just send over the data in one command.
2920 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size / kDepth; 2922 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size / kDepth;
2921 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2923 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2922 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2924 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2923 &size, NULL, NULL)); 2925 &size, NULL, NULL));
2924 2926
2925 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2927 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2926 for (uint32_t ii = 0; ii < size; ++ii) { 2928 for (uint32_t ii = 0; ii < size; ++ii) {
2927 pixels[ii] = static_cast<uint8_t>(ii); 2929 pixels[ii] = static_cast<uint8_t>(ii);
2928 } 2930 }
2929 2931
2930 ExpectedMemoryInfo mem = GetExpectedMemory(size); 2932 ExpectedMemoryInfo mem = GetExpectedMemory(size);
2931 2933
2932 Cmds expected; 2934 Cmds expected;
2933 expected.tex_image_3d.Init( 2935 expected.tex_image_3d.Init(
2934 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, 2936 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth,
2935 kFormat, kType, mem.id, mem.offset); 2937 kFormat, kType, mem.id, mem.offset);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2970 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2969 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2971 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2970 &size, &unpadded_row_size, &padded_row_size)); 2972 &size, &unpadded_row_size, &padded_row_size));
2971 // Makes sure we can just send over the data in one command. 2973 // Makes sure we can just send over the data in one command.
2972 const GLsizei kMaxHeight = MaxTransferBufferSize() / padded_row_size / kDepth; 2974 const GLsizei kMaxHeight = MaxTransferBufferSize() / padded_row_size / kDepth;
2973 const GLsizei kHeight = kMaxHeight * 2; 2975 const GLsizei kHeight = kMaxHeight * 2;
2974 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2976 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2975 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2977 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2976 &size, NULL, NULL)); 2978 &size, NULL, NULL));
2977 2979
2978 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2980 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2979 for (uint32_t ii = 0; ii < size; ++ii) { 2981 for (uint32_t ii = 0; ii < size; ++ii) {
2980 pixels[ii] = static_cast<uint8_t>(ii); 2982 pixels[ii] = static_cast<uint8_t>(ii);
2981 } 2983 }
2982 2984
2983 ExpectedMemoryInfo mem = GetExpectedMappedMemory(size); 2985 ExpectedMemoryInfo mem = GetExpectedMappedMemory(size);
2984 2986
2985 Cmds expected; 2987 Cmds expected;
2986 expected.tex_image_3d.Init( 2988 expected.tex_image_3d.Init(
2987 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, 2989 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth,
2988 kFormat, kType, mem.id, mem.offset); 2990 kFormat, kType, mem.id, mem.offset);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 3; 3027 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 3;
3026 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 3028 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
3027 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, 3029 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
3028 &size, NULL, NULL)); 3030 &size, NULL, NULL));
3029 uint32_t first_size = padded_row_size * (kHeight - 3); 3031 uint32_t first_size = padded_row_size * (kHeight - 3);
3030 uint32_t second_size = 3032 uint32_t second_size =
3031 padded_row_size * 3 - (padded_row_size - unpadded_row_size); 3033 padded_row_size * 3 - (padded_row_size - unpadded_row_size);
3032 EXPECT_EQ(size, first_size + second_size); 3034 EXPECT_EQ(size, first_size + second_size);
3033 ExpectedMemoryInfo mem1 = GetExpectedMemory(first_size); 3035 ExpectedMemoryInfo mem1 = GetExpectedMemory(first_size);
3034 ExpectedMemoryInfo mem2 = GetExpectedMemory(second_size); 3036 ExpectedMemoryInfo mem2 = GetExpectedMemory(second_size);
3035 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 3037 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
3036 for (uint32_t ii = 0; ii < size; ++ii) { 3038 for (uint32_t ii = 0; ii < size; ++ii) {
3037 pixels[ii] = static_cast<uint8_t>(ii); 3039 pixels[ii] = static_cast<uint8_t>(ii);
3038 } 3040 }
3039 3041
3040 Cmds expected; 3042 Cmds expected;
3041 expected.tex_image_3d.Init( 3043 expected.tex_image_3d.Init(
3042 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kFormat, kType, 0, 0); 3044 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kFormat, kType, 0, 0);
3043 expected.tex_sub_image_3d1.Init( 3045 expected.tex_sub_image_3d1.Init(
3044 kTarget, kLevel, 0, 0, 0, kWidth, kHeight - 3, 1, kFormat, kType, 3046 kTarget, kLevel, 0, 0, 0, kWidth, kHeight - 3, 1, kFormat, kType,
3045 mem1.id, mem1.offset, GL_TRUE); 3047 mem1.id, mem1.offset, GL_TRUE);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3085 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 2; 3087 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 2;
3086 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 3088 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
3087 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 3089 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
3088 &size, NULL, NULL)); 3090 &size, NULL, NULL));
3089 uint32_t first_size = (kHeight - 2) * padded_row_size; 3091 uint32_t first_size = (kHeight - 2) * padded_row_size;
3090 uint32_t second_size = 2 * padded_row_size; 3092 uint32_t second_size = 2 * padded_row_size;
3091 uint32_t third_size = first_size; 3093 uint32_t third_size = first_size;
3092 uint32_t fourth_size = second_size - (padded_row_size - unpadded_row_size); 3094 uint32_t fourth_size = second_size - (padded_row_size - unpadded_row_size);
3093 EXPECT_EQ(size, first_size + second_size + third_size + fourth_size); 3095 EXPECT_EQ(size, first_size + second_size + third_size + fourth_size);
3094 3096
3095 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 3097 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
3096 for (uint32_t ii = 0; ii < size; ++ii) { 3098 for (uint32_t ii = 0; ii < size; ++ii) {
3097 pixels[ii] = static_cast<uint8_t>(ii); 3099 pixels[ii] = static_cast<uint8_t>(ii);
3098 } 3100 }
3099 3101
3100 ExpectedMemoryInfo mem1_1 = GetExpectedMemory(first_size); 3102 ExpectedMemoryInfo mem1_1 = GetExpectedMemory(first_size);
3101 ExpectedMemoryInfo mem1_2 = GetExpectedMemory(second_size); 3103 ExpectedMemoryInfo mem1_2 = GetExpectedMemory(second_size);
3102 ExpectedMemoryInfo mem2_1 = GetExpectedMemory(third_size); 3104 ExpectedMemoryInfo mem2_1 = GetExpectedMemory(third_size);
3103 ExpectedMemoryInfo mem2_2 = GetExpectedMemory(fourth_size); 3105 ExpectedMemoryInfo mem2_2 = GetExpectedMemory(fourth_size);
3104 3106
3105 Cmds expected; 3107 Cmds expected;
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
4499 ContextInitOptions init_options; 4501 ContextInitOptions init_options;
4500 init_options.transfer_buffer_initialize_fail = true; 4502 init_options.transfer_buffer_initialize_fail = true;
4501 EXPECT_FALSE(Initialize(init_options)); 4503 EXPECT_FALSE(Initialize(init_options));
4502 } 4504 }
4503 4505
4504 #include "base/macros.h" 4506 #include "base/macros.h"
4505 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 4507 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
4506 4508
4507 } // namespace gles2 4509 } // namespace gles2
4508 } // namespace gpu 4510 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698