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

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

Issue 6995114: Resubmit http://codereview.chromium.org/7046057 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gles2_command_buffer.h> 9 #include <GLES2/gles2_command_buffer.h>
10 10
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 namespace gles2 { 14 namespace gles2 {
15 15
16 class GLES2UtilTest : public testing:: Test { 16 class GLES2UtilTest : public testing:: Test {
17 public: 17 public:
18 GLES2UtilTest() 18 GLES2UtilTest()
19 : util_(0) { 19 : util_(0) {
20 } 20 }
21 21
22 protected: 22 protected:
23 GLES2Util util_; 23 GLES2Util util_;
24 }; 24 };
25 25
26 TEST_F(GLES2UtilTest, ComputeImageDataSizeFormats) { 26 TEST_F(GLES2UtilTest, ComputeImageDataSizeFormats) {
27 const int kWidth = 16; 27 const uint32 kWidth = 16;
28 const int kHeight = 12; 28 const uint32 kHeight = 12;
29 uint32 size; 29 uint32 size;
30 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 30 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
31 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size)); 31 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size));
32 EXPECT_EQ(kWidth * kHeight * 3, size); 32 EXPECT_EQ(kWidth * kHeight * 3, size);
33 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 33 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
34 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size)); 34 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size));
35 EXPECT_EQ(kWidth * kHeight * 4, size); 35 EXPECT_EQ(kWidth * kHeight * 4, size);
36 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 36 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
37 kWidth, kHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, 1, &size)); 37 kWidth, kHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, 1, &size));
38 EXPECT_EQ(kWidth * kHeight * 1, size); 38 EXPECT_EQ(kWidth * kHeight * 1, size);
39 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 39 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
40 kWidth, kHeight, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 1, &size)); 40 kWidth, kHeight, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 1, &size));
41 EXPECT_EQ(kWidth * kHeight * 2, size); 41 EXPECT_EQ(kWidth * kHeight * 2, size);
42 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 42 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
43 kWidth, kHeight, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 1, &size)); 43 kWidth, kHeight, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 1, &size));
44 EXPECT_EQ(kWidth * kHeight * 4, size); 44 EXPECT_EQ(kWidth * kHeight * 4, size);
45 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 45 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
46 kWidth, kHeight, GL_ALPHA, GL_UNSIGNED_BYTE, 1, &size)); 46 kWidth, kHeight, GL_ALPHA, GL_UNSIGNED_BYTE, 1, &size));
47 EXPECT_EQ(kWidth * kHeight * 1, size); 47 EXPECT_EQ(kWidth * kHeight * 1, size);
48 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 48 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
49 kWidth, kHeight, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 1, &size)); 49 kWidth, kHeight, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 1, &size));
50 EXPECT_EQ(kWidth * kHeight * 2, size); 50 EXPECT_EQ(kWidth * kHeight * 2, size);
51 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 51 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
52 kWidth, kHeight, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 1, 52 kWidth, kHeight, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 1,
53 &size)); 53 &size));
54 EXPECT_EQ(kWidth * kHeight * 4, size); 54 EXPECT_EQ(kWidth * kHeight * 4, size);
55 } 55 }
56 56
57 TEST_F(GLES2UtilTest, ComputeImageDataSizeTypes) { 57 TEST_F(GLES2UtilTest, ComputeImageDataSizeTypes) {
58 const int kWidth = 16; 58 const uint32 kWidth = 16;
59 const int kHeight = 12; 59 const uint32 kHeight = 12;
60 uint32 size; 60 uint32 size;
61 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 61 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
62 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size)); 62 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size));
63 EXPECT_EQ(kWidth * kHeight * 4, size); 63 EXPECT_EQ(kWidth * kHeight * 4, size);
64 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 64 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
65 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 1, &size)); 65 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 1, &size));
66 EXPECT_EQ(kWidth * kHeight * 2, size); 66 EXPECT_EQ(kWidth * kHeight * 2, size);
67 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 67 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
68 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 1, &size)); 68 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 1, &size));
69 EXPECT_EQ(kWidth * kHeight * 2, size); 69 EXPECT_EQ(kWidth * kHeight * 2, size);
70 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 70 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
71 kWidth, kHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 1, &size)); 71 kWidth, kHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 1, &size));
72 EXPECT_EQ(kWidth * kHeight * 2, size); 72 EXPECT_EQ(kWidth * kHeight * 2, size);
73 } 73 }
74 74
75 TEST_F(GLES2UtilTest, ComputeImageDataSizeUnpackAlignment) { 75 TEST_F(GLES2UtilTest, ComputeImageDataSizeUnpackAlignment) {
76 const int kWidth = 19; 76 const uint32 kWidth = 19;
77 const int kHeight = 12; 77 const uint32 kHeight = 12;
78 uint32 size; 78 uint32 size;
79 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 79 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
80 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size)); 80 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size));
81 EXPECT_EQ(kWidth * kHeight * 3, size); 81 EXPECT_EQ(kWidth * kHeight * 3, size);
82 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 82 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
83 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 2, &size)); 83 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 2, &size));
84 EXPECT_EQ((kWidth * 3 + 1) * (kHeight - 1) + 84 EXPECT_EQ((kWidth * 3 + 1) * (kHeight - 1) +
85 kWidth * 3, size); 85 kWidth * 3, size);
86 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 86 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
87 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 4, &size)); 87 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 4, &size));
88 EXPECT_EQ((kWidth * 3 + 3) * (kHeight - 1) + 88 EXPECT_EQ((kWidth * 3 + 3) * (kHeight - 1) +
89 kWidth * 3, size); 89 kWidth * 3, size);
90 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( 90 EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
91 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 8, &size)); 91 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 8, &size));
92 EXPECT_EQ((kWidth * 3 + 7) * (kHeight - 1) + 92 EXPECT_EQ((kWidth * 3 + 7) * (kHeight - 1) +
93 kWidth * 3, size); 93 kWidth * 3, size);
94 } 94 }
95 95
96 } // namespace gles2 96 } // namespace gles2
97 } // namespace gpu 97 } // namespace gpu
98 98
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698