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/service/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 | 6 |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "gpu/GLES2/gles2_command_buffer.h" | 8 #include "gpu/GLES2/gles2_command_buffer.h" |
9 #include "gpu/command_buffer/common/gl_mock.h" | 9 #include "gpu/command_buffer/common/gl_mock.h" |
10 #include "gpu/command_buffer/service/feature_info.h" | 10 #include "gpu/command_buffer/service/feature_info.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 EXPECT_EQ(kClient1Id, client_id); | 86 EXPECT_EQ(kClient1Id, client_id); |
87 // Check we get nothing for a non-existent texture. | 87 // Check we get nothing for a non-existent texture. |
88 EXPECT_TRUE(manager_.GetTextureInfo(kClient2Id) == NULL); | 88 EXPECT_TRUE(manager_.GetTextureInfo(kClient2Id) == NULL); |
89 // Check trying to a remove non-existent textures does not crash. | 89 // Check trying to a remove non-existent textures does not crash. |
90 manager_.RemoveTextureInfo(&feature_info_, kClient2Id); | 90 manager_.RemoveTextureInfo(&feature_info_, kClient2Id); |
91 // Check we can't get the texture after we remove it. | 91 // Check we can't get the texture after we remove it. |
92 manager_.RemoveTextureInfo(&feature_info_, kClient1Id); | 92 manager_.RemoveTextureInfo(&feature_info_, kClient1Id); |
93 EXPECT_TRUE(manager_.GetTextureInfo(kClient1Id) == NULL); | 93 EXPECT_TRUE(manager_.GetTextureInfo(kClient1Id) == NULL); |
94 } | 94 } |
95 | 95 |
| 96 TEST_F(TextureManagerTest, SetParameter) { |
| 97 const GLuint kClient1Id = 1; |
| 98 const GLuint kService1Id = 11; |
| 99 EXPECT_FALSE(manager_.HaveUnrenderableTextures()); |
| 100 // Check we can create texture. |
| 101 manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id); |
| 102 // Check texture got created. |
| 103 TextureManager::TextureInfo* info = manager_.GetTextureInfo(kClient1Id); |
| 104 ASSERT_TRUE(info != NULL); |
| 105 manager_.SetParameter( |
| 106 &feature_info_, info, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 107 EXPECT_EQ(static_cast<GLenum>(GL_NEAREST), info->min_filter()); |
| 108 manager_.SetParameter( |
| 109 &feature_info_, info, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 110 EXPECT_EQ(static_cast<GLenum>(GL_NEAREST), info->mag_filter()); |
| 111 manager_.SetParameter( |
| 112 &feature_info_, info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 113 EXPECT_EQ(static_cast<GLenum>(GL_CLAMP_TO_EDGE), info->wrap_s()); |
| 114 manager_.SetParameter( |
| 115 &feature_info_, info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 116 EXPECT_EQ(static_cast<GLenum>(GL_CLAMP_TO_EDGE), info->wrap_t()); |
| 117 } |
| 118 |
96 TEST_F(TextureManagerTest, Destroy) { | 119 TEST_F(TextureManagerTest, Destroy) { |
97 const GLuint kClient1Id = 1; | 120 const GLuint kClient1Id = 1; |
98 const GLuint kService1Id = 11; | 121 const GLuint kService1Id = 11; |
99 EXPECT_FALSE(manager_.HaveUnrenderableTextures()); | 122 EXPECT_FALSE(manager_.HaveUnrenderableTextures()); |
100 // Check we can create texture. | 123 // Check we can create texture. |
101 manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id); | 124 manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id); |
102 // Check texture got created. | 125 // Check texture got created. |
103 TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kClient1Id); | 126 TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kClient1Id); |
104 ASSERT_TRUE(info1 != NULL); | 127 ASSERT_TRUE(info1 != NULL); |
105 EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kService1Id))) | 128 EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kService1Id))) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 FeatureInfo feature_info_; | 279 FeatureInfo feature_info_; |
257 }; | 280 }; |
258 | 281 |
259 TEST_F(TextureInfoTest, Basic) { | 282 TEST_F(TextureInfoTest, Basic) { |
260 EXPECT_EQ(0u, info_->target()); | 283 EXPECT_EQ(0u, info_->target()); |
261 EXPECT_FALSE(info_->texture_complete()); | 284 EXPECT_FALSE(info_->texture_complete()); |
262 EXPECT_FALSE(info_->cube_complete()); | 285 EXPECT_FALSE(info_->cube_complete()); |
263 EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_)); | 286 EXPECT_FALSE(info_->CanGenerateMipmaps(&feature_info_)); |
264 EXPECT_FALSE(info_->npot()); | 287 EXPECT_FALSE(info_->npot()); |
265 EXPECT_FALSE(info_->CanRender(&feature_info_)); | 288 EXPECT_FALSE(info_->CanRender(&feature_info_)); |
| 289 EXPECT_EQ(static_cast<GLenum>(GL_NEAREST_MIPMAP_LINEAR), info_->min_filter()); |
| 290 EXPECT_EQ(static_cast<GLenum>(GL_LINEAR), info_->mag_filter()); |
| 291 EXPECT_EQ(static_cast<GLenum>(GL_REPEAT), info_->wrap_s()); |
| 292 EXPECT_EQ(static_cast<GLenum>(GL_REPEAT), info_->wrap_t()); |
266 EXPECT_TRUE(manager_.HaveUnrenderableTextures()); | 293 EXPECT_TRUE(manager_.HaveUnrenderableTextures()); |
267 } | 294 } |
268 | 295 |
269 TEST_F(TextureInfoTest, POT2D) { | 296 TEST_F(TextureInfoTest, POT2D) { |
270 manager_.SetInfoTarget(info_, GL_TEXTURE_2D); | 297 manager_.SetInfoTarget(info_, GL_TEXTURE_2D); |
271 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info_->target()); | 298 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info_->target()); |
272 // Check Setting level 0 to POT | 299 // Check Setting level 0 to POT |
273 manager_.SetLevelInfo(&feature_info_, info_, | 300 manager_.SetLevelInfo(&feature_info_, info_, |
274 GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 301 GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
275 EXPECT_FALSE(info_->npot()); | 302 EXPECT_FALSE(info_->npot()); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 manager.SetLevelInfo(&feature_info, info, | 639 manager.SetLevelInfo(&feature_info, info, |
613 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES); | 640 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES); |
614 EXPECT_TRUE(info->texture_complete()); | 641 EXPECT_TRUE(info->texture_complete()); |
615 manager.Destroy(false); | 642 manager.Destroy(false); |
616 } | 643 } |
617 | 644 |
618 } // namespace gles2 | 645 } // namespace gles2 |
619 } // namespace gpu | 646 } // namespace gpu |
620 | 647 |
621 | 648 |
OLD | NEW |