| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/service/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 namespace gpu { | 8 namespace gpu { |
| 9 namespace gles2 { | 9 namespace gles2 { |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // GCC requires these declarations, but MSVC requires they not be present | 32 // GCC requires these declarations, but MSVC requires they not be present |
| 33 #ifndef COMPILER_MSVC | 33 #ifndef COMPILER_MSVC |
| 34 const GLint TextureManagerTest::kMaxTextureSize; | 34 const GLint TextureManagerTest::kMaxTextureSize; |
| 35 const GLint TextureManagerTest::kMaxCubeMapTextureSize; | 35 const GLint TextureManagerTest::kMaxCubeMapTextureSize; |
| 36 const GLint TextureManagerTest::kMax2dLevels; | 36 const GLint TextureManagerTest::kMax2dLevels; |
| 37 const GLint TextureManagerTest::kMaxCubeMapLevels; | 37 const GLint TextureManagerTest::kMaxCubeMapLevels; |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 TEST_F(TextureManagerTest, Basic) { | 40 TEST_F(TextureManagerTest, Basic) { |
| 41 const GLuint kTexture1Id = 1; | 41 const GLuint kClient1Id = 1; |
| 42 const GLuint kTexture2Id = 2; | 42 const GLuint kService1Id = 11; |
| 43 const GLuint kClient2Id = 2; |
| 43 // Check we can create texture. | 44 // Check we can create texture. |
| 44 manager_.CreateTextureInfo(kTexture1Id); | 45 manager_.CreateTextureInfo(kClient1Id, kService1Id); |
| 45 // Check texture got created. | 46 // Check texture got created. |
| 46 TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kTexture1Id); | 47 TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kClient1Id); |
| 47 ASSERT_TRUE(info1 != NULL); | 48 ASSERT_TRUE(info1 != NULL); |
| 49 EXPECT_EQ(kService1Id, info1->service_id()); |
| 48 // Check we get nothing for a non-existent texture. | 50 // Check we get nothing for a non-existent texture. |
| 49 EXPECT_TRUE(manager_.GetTextureInfo(kTexture2Id) == NULL); | 51 EXPECT_TRUE(manager_.GetTextureInfo(kClient2Id) == NULL); |
| 50 // Check trying to a remove non-existent textures does not crash. | 52 // Check trying to a remove non-existent textures does not crash. |
| 51 manager_.RemoveTextureInfo(kTexture2Id); | 53 manager_.RemoveTextureInfo(kClient2Id); |
| 52 // Check we can't get the texture after we remove it. | 54 // Check we can't get the texture after we remove it. |
| 53 manager_.RemoveTextureInfo(kTexture1Id); | 55 manager_.RemoveTextureInfo(kClient1Id); |
| 54 EXPECT_TRUE(manager_.GetTextureInfo(kTexture1Id) == NULL); | 56 EXPECT_TRUE(manager_.GetTextureInfo(kClient1Id) == NULL); |
| 55 } | 57 } |
| 56 | 58 |
| 57 TEST_F(TextureManagerTest, MaxValues) { | 59 TEST_F(TextureManagerTest, MaxValues) { |
| 58 // Check we get the right values for the max sizes. | 60 // Check we get the right values for the max sizes. |
| 59 EXPECT_EQ(kMax2dLevels, manager_.MaxLevelsForTarget(GL_TEXTURE_2D)); | 61 EXPECT_EQ(kMax2dLevels, manager_.MaxLevelsForTarget(GL_TEXTURE_2D)); |
| 60 EXPECT_EQ(kMaxCubeMapLevels, | 62 EXPECT_EQ(kMaxCubeMapLevels, |
| 61 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP)); | 63 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP)); |
| 62 EXPECT_EQ(kMaxTextureSize, manager_.MaxSizeForTarget(GL_TEXTURE_2D)); | 64 EXPECT_EQ(kMaxTextureSize, manager_.MaxSizeForTarget(GL_TEXTURE_2D)); |
| 63 EXPECT_EQ(kMaxCubeMapTextureSize, | 65 EXPECT_EQ(kMaxCubeMapTextureSize, |
| 64 manager_.MaxSizeForTarget(GL_TEXTURE_CUBE_MAP)); | 66 manager_.MaxSizeForTarget(GL_TEXTURE_CUBE_MAP)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels, | 109 GL_TEXTURE_CUBE_MAP, kMaxCubeMapLevels, |
| 108 kMaxCubeMapTextureSize, 1, 2)); | 110 kMaxCubeMapTextureSize, 1, 2)); |
| 109 } | 111 } |
| 110 | 112 |
| 111 class TextureInfoTest : public testing::Test { | 113 class TextureInfoTest : public testing::Test { |
| 112 public: | 114 public: |
| 113 static const GLint kMaxTextureSize = 16; | 115 static const GLint kMaxTextureSize = 16; |
| 114 static const GLint kMaxCubeMapTextureSize = 8; | 116 static const GLint kMaxCubeMapTextureSize = 8; |
| 115 static const GLint kMax2dLevels = 5; | 117 static const GLint kMax2dLevels = 5; |
| 116 static const GLint kMaxCubeMapLevels = 4; | 118 static const GLint kMaxCubeMapLevels = 4; |
| 117 static const GLuint kTexture1Id = 1; | 119 static const GLuint kClient1Id = 1; |
| 120 static const GLuint kService1Id = 11; |
| 118 | 121 |
| 119 TextureInfoTest() | 122 TextureInfoTest() |
| 120 : manager_(kMaxTextureSize, kMaxCubeMapTextureSize) { | 123 : manager_(kMaxTextureSize, kMaxCubeMapTextureSize) { |
| 121 } | 124 } |
| 122 | 125 |
| 123 protected: | 126 protected: |
| 124 virtual void SetUp() { | 127 virtual void SetUp() { |
| 125 manager_.CreateTextureInfo(kTexture1Id); | 128 manager_.CreateTextureInfo(kClient1Id, kService1Id); |
| 126 info_ = manager_.GetTextureInfo(kTexture1Id); | 129 info_ = manager_.GetTextureInfo(kClient1Id); |
| 127 ASSERT_TRUE(info_ != NULL); | 130 ASSERT_TRUE(info_ != NULL); |
| 128 } | 131 } |
| 129 | 132 |
| 130 virtual void TearDown() { | 133 virtual void TearDown() { |
| 131 } | 134 } |
| 132 | 135 |
| 133 TextureManager manager_; | 136 TextureManager manager_; |
| 134 TextureManager::TextureInfo* info_; | 137 TextureManager::TextureInfo* info_; |
| 135 }; | 138 }; |
| 136 | 139 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 GLsizei width = -1; | 291 GLsizei width = -1; |
| 289 GLsizei height = -1; | 292 GLsizei height = -1; |
| 290 EXPECT_FALSE(info_->GetLevelSize(GL_TEXTURE_2D, -1, &width, &height)); | 293 EXPECT_FALSE(info_->GetLevelSize(GL_TEXTURE_2D, -1, &width, &height)); |
| 291 EXPECT_FALSE(info_->GetLevelSize(GL_TEXTURE_2D, 1000, &width, &height)); | 294 EXPECT_FALSE(info_->GetLevelSize(GL_TEXTURE_2D, 1000, &width, &height)); |
| 292 EXPECT_TRUE(info_->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 295 EXPECT_TRUE(info_->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 293 EXPECT_EQ(0, width); | 296 EXPECT_EQ(0, width); |
| 294 EXPECT_EQ(0, height); | 297 EXPECT_EQ(0, height); |
| 295 EXPECT_TRUE(info_->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); | 298 EXPECT_TRUE(info_->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 296 EXPECT_EQ(4, width); | 299 EXPECT_EQ(4, width); |
| 297 EXPECT_EQ(5, height); | 300 EXPECT_EQ(5, height); |
| 298 manager_.RemoveTextureInfo(info_->texture_id()); | 301 manager_.RemoveTextureInfo(kClient1Id); |
| 299 EXPECT_FALSE(info_->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); | 302 EXPECT_FALSE(info_->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 300 } | 303 } |
| 301 | 304 |
| 302 } // namespace gles2 | 305 } // namespace gles2 |
| 303 } // namespace gpu | 306 } // namespace gpu |
| 304 | 307 |
| 305 | 308 |
| OLD | NEW |