| OLD | NEW |
| 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: | |
| 18 GLES2UtilTest() | |
| 19 : util_(0) { | |
| 20 } | |
| 21 | |
| 22 protected: | 17 protected: |
| 23 GLES2Util util_; | 18 GLES2Util util_; |
| 24 }; | 19 }; |
| 25 | 20 |
| 21 TEST_F(GLES2UtilTest, GLGetNumValuesReturned) { |
| 22 EXPECT_EQ(0, util_.GLGetNumValuesReturned(GL_COMPRESSED_TEXTURE_FORMATS)); |
| 23 EXPECT_EQ(0, util_.GLGetNumValuesReturned(GL_SHADER_BINARY_FORMATS)); |
| 24 |
| 25 EXPECT_EQ(0, util_.num_compressed_texture_formats()); |
| 26 EXPECT_EQ(0, util_.num_shader_binary_formats()); |
| 27 |
| 28 util_.set_num_compressed_texture_formats(1); |
| 29 util_.set_num_shader_binary_formats(2); |
| 30 |
| 31 EXPECT_EQ(1, util_.GLGetNumValuesReturned(GL_COMPRESSED_TEXTURE_FORMATS)); |
| 32 EXPECT_EQ(2, util_.GLGetNumValuesReturned(GL_SHADER_BINARY_FORMATS)); |
| 33 |
| 34 EXPECT_EQ(1, util_.num_compressed_texture_formats()); |
| 35 EXPECT_EQ(2, util_.num_shader_binary_formats()); |
| 36 } |
| 37 |
| 26 TEST_F(GLES2UtilTest, ComputeImageDataSizeFormats) { | 38 TEST_F(GLES2UtilTest, ComputeImageDataSizeFormats) { |
| 27 const uint32 kWidth = 16; | 39 const uint32 kWidth = 16; |
| 28 const uint32 kHeight = 12; | 40 const uint32 kHeight = 12; |
| 29 uint32 size; | 41 uint32 size; |
| 30 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( | 42 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( |
| 31 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size)); | 43 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size)); |
| 32 EXPECT_EQ(kWidth * kHeight * 3, size); | 44 EXPECT_EQ(kWidth * kHeight * 3, size); |
| 33 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( | 45 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( |
| 34 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size)); | 46 kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size)); |
| 35 EXPECT_EQ(kWidth * kHeight * 4, size); | 47 EXPECT_EQ(kWidth * kHeight * 4, size); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 kWidth * 3, size); | 101 kWidth * 3, size); |
| 90 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( | 102 EXPECT_TRUE(GLES2Util::ComputeImageDataSize( |
| 91 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 8, &size)); | 103 kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 8, &size)); |
| 92 EXPECT_EQ((kWidth * 3 + 7) * (kHeight - 1) + | 104 EXPECT_EQ((kWidth * 3 + 7) * (kHeight - 1) + |
| 93 kWidth * 3, size); | 105 kWidth * 3, size); |
| 94 } | 106 } |
| 95 | 107 |
| 96 } // namespace gles2 | 108 } // namespace gles2 |
| 97 } // namespace gpu | 109 } // namespace gpu |
| 98 | 110 |
| OLD | NEW |