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

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: rebase on master 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
13 #include <stddef.h> 14 #include <stddef.h>
14 #include <stdint.h> 15 #include <stdint.h>
16
17 #include <memory>
18
15 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
16 #include "gpu/command_buffer/client/client_test_helper.h" 20 #include "gpu/command_buffer/client/client_test_helper.h"
17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 21 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
18 #include "gpu/command_buffer/client/program_info_manager.h" 22 #include "gpu/command_buffer/client/program_info_manager.h"
19 #include "gpu/command_buffer/client/query_tracker.h" 23 #include "gpu/command_buffer/client/query_tracker.h"
20 #include "gpu/command_buffer/client/ring_buffer.h" 24 #include "gpu/command_buffer/client/ring_buffer.h"
21 #include "gpu/command_buffer/client/transfer_buffer.h" 25 #include "gpu/command_buffer/client/transfer_buffer.h"
22 #include "gpu/command_buffer/common/command_buffer.h" 26 #include "gpu/command_buffer/common/command_buffer.h"
23 #include "gpu/command_buffer/common/sync_token.h" 27 #include "gpu/command_buffer/common/sync_token.h"
24 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return command_buffer_.get(); 532 return command_buffer_.get();
529 } 533 }
530 534
531 int GetNextToken() { return ++token_; } 535 int GetNextToken() { return ++token_; }
532 536
533 void ClearCommands() { 537 void ClearCommands() {
534 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); 538 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer();
535 memset(ring_buffer->memory(), kInitialValue, ring_buffer->size()); 539 memset(ring_buffer->memory(), kInitialValue, ring_buffer->size());
536 } 540 }
537 541
538 scoped_ptr<MockClientCommandBuffer> command_buffer_; 542 std::unique_ptr<MockClientCommandBuffer> command_buffer_;
539 scoped_ptr<MockClientGpuControl> gpu_control_; 543 std::unique_ptr<MockClientGpuControl> gpu_control_;
540 scoped_ptr<GLES2CmdHelper> helper_; 544 std::unique_ptr<GLES2CmdHelper> helper_;
541 scoped_ptr<MockTransferBuffer> transfer_buffer_; 545 std::unique_ptr<MockTransferBuffer> transfer_buffer_;
542 scoped_ptr<GLES2Implementation> gl_; 546 std::unique_ptr<GLES2Implementation> gl_;
543 CommandBufferEntry* commands_; 547 CommandBufferEntry* commands_;
544 int token_; 548 int token_;
545 }; 549 };
546 550
547 GLES2ImplementationTest() : commands_(NULL) {} 551 GLES2ImplementationTest() : commands_(NULL) {}
548 552
549 void SetUp() override; 553 void SetUp() override;
550 void TearDown() override; 554 void TearDown() override;
551 555
552 bool NoCommandsWritten() { 556 bool NoCommandsWritten() {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 #endif 860 #endif
857 861
858 TEST_F(GLES2ImplementationTest, Basic) { 862 TEST_F(GLES2ImplementationTest, Basic) {
859 EXPECT_TRUE(gl_->share_group() != NULL); 863 EXPECT_TRUE(gl_->share_group() != NULL);
860 } 864 }
861 865
862 TEST_F(GLES2ImplementationTest, GetBucketContents) { 866 TEST_F(GLES2ImplementationTest, GetBucketContents) {
863 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; 867 const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
864 const uint32_t kTestSize = MaxTransferBufferSize() + 32; 868 const uint32_t kTestSize = MaxTransferBufferSize() + 32;
865 869
866 scoped_ptr<uint8_t[]> buf(new uint8_t[kTestSize]); 870 std::unique_ptr<uint8_t[]> buf(new uint8_t[kTestSize]);
867 uint8_t* expected_data = buf.get(); 871 uint8_t* expected_data = buf.get();
868 for (uint32_t ii = 0; ii < kTestSize; ++ii) { 872 for (uint32_t ii = 0; ii < kTestSize; ++ii) {
869 expected_data[ii] = ii * 3; 873 expected_data[ii] = ii * 3;
870 } 874 }
871 875
872 struct Cmds { 876 struct Cmds {
873 cmd::GetBucketStart get_bucket_start; 877 cmd::GetBucketStart get_bucket_start;
874 cmd::SetToken set_token1; 878 cmd::SetToken set_token1;
875 cmd::GetBucketData get_bucket_data; 879 cmd::GetBucketData get_bucket_data;
876 cmd::SetToken set_token2; 880 cmd::SetToken set_token2;
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 Cmds expected; 1727 Cmds expected;
1724 expected.read1.Init( 1728 expected.read1.Init(
1725 0, 0, kWidth, kHeight / 2, kFormat, kType, 1729 0, 0, kWidth, kHeight / 2, kFormat, kType,
1726 mem1.id, mem1.offset, result1.id, result1.offset, 1730 mem1.id, mem1.offset, result1.id, result1.offset,
1727 false); 1731 false);
1728 expected.set_token1.Init(GetNextToken()); 1732 expected.set_token1.Init(GetNextToken());
1729 expected.read2.Init( 1733 expected.read2.Init(
1730 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, 1734 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType,
1731 mem2.id, mem2.offset, result2.id, result2.offset, false); 1735 mem2.id, mem2.offset, result2.id, result2.offset, false);
1732 expected.set_token2.Init(GetNextToken()); 1736 expected.set_token2.Init(GetNextToken());
1733 scoped_ptr<int8_t[]> buffer(new int8_t[kWidth * kHeight * kBytesPerPixel]); 1737 std::unique_ptr<int8_t[]> buffer(
1738 new int8_t[kWidth * kHeight * kBytesPerPixel]);
1734 1739
1735 EXPECT_CALL(*command_buffer(), OnFlush()) 1740 EXPECT_CALL(*command_buffer(), OnFlush())
1736 .WillOnce(SetMemory(result1.ptr, static_cast<uint32_t>(1))) 1741 .WillOnce(SetMemory(result1.ptr, static_cast<uint32_t>(1)))
1737 .WillOnce(SetMemory(result2.ptr, static_cast<uint32_t>(1))) 1742 .WillOnce(SetMemory(result2.ptr, static_cast<uint32_t>(1)))
1738 .RetiresOnSaturation(); 1743 .RetiresOnSaturation();
1739 1744
1740 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); 1745 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
1741 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 1746 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1742 } 1747 }
1743 1748
(...skipping 11 matching lines...) Expand all
1755 ExpectedMemoryInfo mem1 = 1760 ExpectedMemoryInfo mem1 =
1756 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel); 1761 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel);
1757 ExpectedMemoryInfo result1 = 1762 ExpectedMemoryInfo result1 =
1758 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); 1763 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result));
1759 1764
1760 Cmds expected; 1765 Cmds expected;
1761 expected.read.Init( 1766 expected.read.Init(
1762 0, 0, kWidth, kHeight, kFormat, kType, 1767 0, 0, kWidth, kHeight, kFormat, kType,
1763 mem1.id, mem1.offset, result1.id, result1.offset, false); 1768 mem1.id, mem1.offset, result1.id, result1.offset, false);
1764 expected.set_token.Init(GetNextToken()); 1769 expected.set_token.Init(GetNextToken());
1765 scoped_ptr<int8_t[]> buffer(new int8_t[kWidth * kHeight * kBytesPerPixel]); 1770 std::unique_ptr<int8_t[]> buffer(
1771 new int8_t[kWidth * kHeight * kBytesPerPixel]);
1766 1772
1767 EXPECT_CALL(*command_buffer(), OnFlush()) 1773 EXPECT_CALL(*command_buffer(), OnFlush())
1768 .Times(1) 1774 .Times(1)
1769 .RetiresOnSaturation(); 1775 .RetiresOnSaturation();
1770 1776
1771 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); 1777 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
1772 } 1778 }
1773 1779
1774 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { 1780 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) {
1775 struct Cmds { 1781 struct Cmds {
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 uint32_t padded_row_size = 0; 2431 uint32_t padded_row_size = 0;
2426 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2432 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2427 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2433 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2428 &size, &unpadded_row_size, &padded_row_size)); 2434 &size, &unpadded_row_size, &padded_row_size));
2429 const GLsizei kMaxHeight = (MaxTransferBufferSize() / padded_row_size) * 2; 2435 const GLsizei kMaxHeight = (MaxTransferBufferSize() / padded_row_size) * 2;
2430 const GLsizei kHeight = kMaxHeight * 2; 2436 const GLsizei kHeight = kMaxHeight * 2;
2431 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2437 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2432 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2438 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2433 &size, &unpadded_row_size, &padded_row_size)); 2439 &size, &unpadded_row_size, &padded_row_size));
2434 2440
2435 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2441 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2436 for (uint32_t ii = 0; ii < size; ++ii) { 2442 for (uint32_t ii = 0; ii < size; ++ii) {
2437 pixels[ii] = static_cast<uint8_t>(ii); 2443 pixels[ii] = static_cast<uint8_t>(ii);
2438 } 2444 }
2439 2445
2440 ExpectedMemoryInfo mem1 = GetExpectedMappedMemory(size); 2446 ExpectedMemoryInfo mem1 = GetExpectedMappedMemory(size);
2441 2447
2442 Cmds expected; 2448 Cmds expected;
2443 expected.tex_image_2d.Init( 2449 expected.tex_image_2d.Init(
2444 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, 2450 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
2445 mem1.id, mem1.offset); 2451 mem1.id, mem1.offset);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 &size, &unpadded_row_size, &padded_row_size)); 2487 &size, &unpadded_row_size, &padded_row_size));
2482 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2; 2488 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2;
2483 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2489 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2484 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2490 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2485 &size, NULL, NULL)); 2491 &size, NULL, NULL));
2486 uint32_t half_size = 0; 2492 uint32_t half_size = 0;
2487 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2493 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2488 kWidth, kHeight / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, 2494 kWidth, kHeight / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2489 &half_size, NULL, NULL)); 2495 &half_size, NULL, NULL));
2490 2496
2491 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2497 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2492 for (uint32_t ii = 0; ii < size; ++ii) { 2498 for (uint32_t ii = 0; ii < size; ++ii) {
2493 pixels[ii] = static_cast<uint8_t>(ii); 2499 pixels[ii] = static_cast<uint8_t>(ii);
2494 } 2500 }
2495 2501
2496 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size); 2502 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size);
2497 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size); 2503 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size);
2498 2504
2499 Cmds expected; 2505 Cmds expected;
2500 expected.tex_image_2d.Init( 2506 expected.tex_image_2d.Init(
2501 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, 2507 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 cmds::TexSubImage2D tex_sub_image_2d; 2568 cmds::TexSubImage2D tex_sub_image_2d;
2563 } texSubImageExpected; 2569 } texSubImageExpected;
2564 2570
2565 uint32_t pixel_size; 2571 uint32_t pixel_size;
2566 PixelStoreParams pixel_params; 2572 PixelStoreParams pixel_params;
2567 // Makes sure the pixels size is large enough for all tests. 2573 // Makes sure the pixels size is large enough for all tests.
2568 pixel_params.alignment = 8; 2574 pixel_params.alignment = 8;
2569 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3( 2575 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3(
2570 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType, 2576 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType,
2571 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr)); 2577 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr));
2572 scoped_ptr<uint8_t[]> src_pixels; 2578 std::unique_ptr<uint8_t[]> src_pixels;
2573 src_pixels.reset(new uint8_t[pixel_size]); 2579 src_pixels.reset(new uint8_t[pixel_size]);
2574 for (size_t i = 0; i < pixel_size; ++i) { 2580 for (size_t i = 0; i < pixel_size; ++i) {
2575 src_pixels[i] = static_cast<uint8_t>(i % 255); 2581 src_pixels[i] = static_cast<uint8_t>(i % 255);
2576 } 2582 }
2577 2583
2578 for (int sub = 0; sub < 2; ++sub) { 2584 for (int sub = 0; sub < 2; ++sub) {
2579 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { 2585 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
2580 const void* commands = GetPut(); 2586 const void* commands = GetPut();
2581 2587
2582 GLint alignment = unpack_alignments[a]; 2588 GLint alignment = unpack_alignments[a];
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 cmds::TexSubImage3D tex_sub_image_3d; 2709 cmds::TexSubImage3D tex_sub_image_3d;
2704 } texSubImageExpected; 2710 } texSubImageExpected;
2705 2711
2706 uint32_t pixel_size; 2712 uint32_t pixel_size;
2707 PixelStoreParams pixel_params; 2713 PixelStoreParams pixel_params;
2708 // Makes sure the pixels size is large enough for all tests. 2714 // Makes sure the pixels size is large enough for all tests.
2709 pixel_params.alignment = 8; 2715 pixel_params.alignment = 8;
2710 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3( 2716 ASSERT_TRUE(GLES2Util::ComputeImageDataSizesES3(
2711 kSrcWidth, kSrcSubImageY1, kSrcSubImageZ1, kFormat, kType, 2717 kSrcWidth, kSrcSubImageY1, kSrcSubImageZ1, kFormat, kType,
2712 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr)); 2718 pixel_params, &pixel_size, nullptr, nullptr, nullptr, nullptr));
2713 scoped_ptr<uint8_t[]> src_pixels; 2719 std::unique_ptr<uint8_t[]> src_pixels;
2714 src_pixels.reset(new uint8_t[pixel_size]); 2720 src_pixels.reset(new uint8_t[pixel_size]);
2715 for (size_t i = 0; i < pixel_size; ++i) { 2721 for (size_t i = 0; i < pixel_size; ++i) {
2716 src_pixels[i] = static_cast<uint8_t>(i % 255); 2722 src_pixels[i] = static_cast<uint8_t>(i % 255);
2717 } 2723 }
2718 2724
2719 for (int sub = 0; sub < 2; ++sub) { 2725 for (int sub = 0; sub < 2; ++sub) {
2720 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { 2726 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
2721 const void* commands = GetPut(); 2727 const void* commands = GetPut();
2722 2728
2723 GLint alignment = unpack_alignments[a]; 2729 GLint alignment = unpack_alignments[a];
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 uint32_t padded_row_size = 0; 2924 uint32_t padded_row_size = 0;
2919 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2925 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2920 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2926 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2921 &size, &unpadded_row_size, &padded_row_size)); 2927 &size, &unpadded_row_size, &padded_row_size));
2922 // Makes sure we can just send over the data in one command. 2928 // Makes sure we can just send over the data in one command.
2923 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size / kDepth; 2929 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size / kDepth;
2924 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2930 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2925 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2931 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2926 &size, NULL, NULL)); 2932 &size, NULL, NULL));
2927 2933
2928 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2934 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2929 for (uint32_t ii = 0; ii < size; ++ii) { 2935 for (uint32_t ii = 0; ii < size; ++ii) {
2930 pixels[ii] = static_cast<uint8_t>(ii); 2936 pixels[ii] = static_cast<uint8_t>(ii);
2931 } 2937 }
2932 2938
2933 ExpectedMemoryInfo mem = GetExpectedMemory(size); 2939 ExpectedMemoryInfo mem = GetExpectedMemory(size);
2934 2940
2935 Cmds expected; 2941 Cmds expected;
2936 expected.tex_image_3d.Init( 2942 expected.tex_image_3d.Init(
2937 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, 2943 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth,
2938 kFormat, kType, mem.id, mem.offset); 2944 kFormat, kType, mem.id, mem.offset);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2977 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2972 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2978 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2973 &size, &unpadded_row_size, &padded_row_size)); 2979 &size, &unpadded_row_size, &padded_row_size));
2974 // Makes sure we can just send over the data in one command. 2980 // Makes sure we can just send over the data in one command.
2975 const GLsizei kMaxHeight = MaxTransferBufferSize() / padded_row_size / kDepth; 2981 const GLsizei kMaxHeight = MaxTransferBufferSize() / padded_row_size / kDepth;
2976 const GLsizei kHeight = kMaxHeight * 2; 2982 const GLsizei kHeight = kMaxHeight * 2;
2977 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2983 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2978 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2984 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2979 &size, NULL, NULL)); 2985 &size, NULL, NULL));
2980 2986
2981 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 2987 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
2982 for (uint32_t ii = 0; ii < size; ++ii) { 2988 for (uint32_t ii = 0; ii < size; ++ii) {
2983 pixels[ii] = static_cast<uint8_t>(ii); 2989 pixels[ii] = static_cast<uint8_t>(ii);
2984 } 2990 }
2985 2991
2986 ExpectedMemoryInfo mem = GetExpectedMappedMemory(size); 2992 ExpectedMemoryInfo mem = GetExpectedMappedMemory(size);
2987 2993
2988 Cmds expected; 2994 Cmds expected;
2989 expected.tex_image_3d.Init( 2995 expected.tex_image_3d.Init(
2990 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, 2996 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth,
2991 kFormat, kType, mem.id, mem.offset); 2997 kFormat, kType, mem.id, mem.offset);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 3; 3034 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 3;
3029 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 3035 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
3030 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, 3036 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
3031 &size, NULL, NULL)); 3037 &size, NULL, NULL));
3032 uint32_t first_size = padded_row_size * (kHeight - 3); 3038 uint32_t first_size = padded_row_size * (kHeight - 3);
3033 uint32_t second_size = 3039 uint32_t second_size =
3034 padded_row_size * 3 - (padded_row_size - unpadded_row_size); 3040 padded_row_size * 3 - (padded_row_size - unpadded_row_size);
3035 EXPECT_EQ(size, first_size + second_size); 3041 EXPECT_EQ(size, first_size + second_size);
3036 ExpectedMemoryInfo mem1 = GetExpectedMemory(first_size); 3042 ExpectedMemoryInfo mem1 = GetExpectedMemory(first_size);
3037 ExpectedMemoryInfo mem2 = GetExpectedMemory(second_size); 3043 ExpectedMemoryInfo mem2 = GetExpectedMemory(second_size);
3038 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 3044 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
3039 for (uint32_t ii = 0; ii < size; ++ii) { 3045 for (uint32_t ii = 0; ii < size; ++ii) {
3040 pixels[ii] = static_cast<uint8_t>(ii); 3046 pixels[ii] = static_cast<uint8_t>(ii);
3041 } 3047 }
3042 3048
3043 Cmds expected; 3049 Cmds expected;
3044 expected.tex_image_3d.Init( 3050 expected.tex_image_3d.Init(
3045 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kFormat, kType, 0, 0); 3051 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kFormat, kType, 0, 0);
3046 expected.tex_sub_image_3d1.Init( 3052 expected.tex_sub_image_3d1.Init(
3047 kTarget, kLevel, 0, 0, 0, kWidth, kHeight - 3, 1, kFormat, kType, 3053 kTarget, kLevel, 0, 0, 0, kWidth, kHeight - 3, 1, kFormat, kType,
3048 mem1.id, mem1.offset, GL_TRUE); 3054 mem1.id, mem1.offset, GL_TRUE);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3088 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 2; 3094 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 2;
3089 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 3095 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
3090 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 3096 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
3091 &size, NULL, NULL)); 3097 &size, NULL, NULL));
3092 uint32_t first_size = (kHeight - 2) * padded_row_size; 3098 uint32_t first_size = (kHeight - 2) * padded_row_size;
3093 uint32_t second_size = 2 * padded_row_size; 3099 uint32_t second_size = 2 * padded_row_size;
3094 uint32_t third_size = first_size; 3100 uint32_t third_size = first_size;
3095 uint32_t fourth_size = second_size - (padded_row_size - unpadded_row_size); 3101 uint32_t fourth_size = second_size - (padded_row_size - unpadded_row_size);
3096 EXPECT_EQ(size, first_size + second_size + third_size + fourth_size); 3102 EXPECT_EQ(size, first_size + second_size + third_size + fourth_size);
3097 3103
3098 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); 3104 std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);
3099 for (uint32_t ii = 0; ii < size; ++ii) { 3105 for (uint32_t ii = 0; ii < size; ++ii) {
3100 pixels[ii] = static_cast<uint8_t>(ii); 3106 pixels[ii] = static_cast<uint8_t>(ii);
3101 } 3107 }
3102 3108
3103 ExpectedMemoryInfo mem1_1 = GetExpectedMemory(first_size); 3109 ExpectedMemoryInfo mem1_1 = GetExpectedMemory(first_size);
3104 ExpectedMemoryInfo mem1_2 = GetExpectedMemory(second_size); 3110 ExpectedMemoryInfo mem1_2 = GetExpectedMemory(second_size);
3105 ExpectedMemoryInfo mem2_1 = GetExpectedMemory(third_size); 3111 ExpectedMemoryInfo mem2_1 = GetExpectedMemory(third_size);
3106 ExpectedMemoryInfo mem2_2 = GetExpectedMemory(fourth_size); 3112 ExpectedMemoryInfo mem2_2 = GetExpectedMemory(fourth_size);
3107 3113
3108 Cmds expected; 3114 Cmds expected;
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
4502 ContextInitOptions init_options; 4508 ContextInitOptions init_options;
4503 init_options.transfer_buffer_initialize_fail = true; 4509 init_options.transfer_buffer_initialize_fail = true;
4504 EXPECT_FALSE(Initialize(init_options)); 4510 EXPECT_FALSE(Initialize(init_options));
4505 } 4511 }
4506 4512
4507 #include "base/macros.h" 4513 #include "base/macros.h"
4508 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 4514 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
4509 4515
4510 } // namespace gles2 4516 } // namespace gles2
4511 } // namespace gpu 4517 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gpu_memory_buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698