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/memory/scoped_ptr.h" | 7 #include "base/memory/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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 .RetiresOnSaturation(); | 146 .RetiresOnSaturation(); |
147 EXPECT_CALL(*gl_, DeleteTextures(4, _)) | 147 EXPECT_CALL(*gl_, DeleteTextures(4, _)) |
148 .Times(1) | 148 .Times(1) |
149 .RetiresOnSaturation(); | 149 .RetiresOnSaturation(); |
150 manager_.Destroy(true); | 150 manager_.Destroy(true); |
151 // Check that resources got freed. | 151 // Check that resources got freed. |
152 info1 = manager_.GetTextureInfo(kClient1Id); | 152 info1 = manager_.GetTextureInfo(kClient1Id); |
153 ASSERT_TRUE(info1 == NULL); | 153 ASSERT_TRUE(info1 == NULL); |
154 } | 154 } |
155 | 155 |
| 156 TEST_F(TextureManagerTest, DestroyUnowned) { |
| 157 const GLuint kClient1Id = 1; |
| 158 const GLuint kService1Id = 11; |
| 159 EXPECT_FALSE(manager_.HaveUnrenderableTextures()); |
| 160 // Check we can create texture. |
| 161 TextureManager::TextureInfo* created_info = |
| 162 manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id); |
| 163 created_info->SetNotOwned(); |
| 164 |
| 165 // Check texture got created. |
| 166 TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kClient1Id); |
| 167 ASSERT_TRUE(info1 != NULL); |
| 168 EXPECT_CALL(*gl_, DeleteTextures(4, _)) |
| 169 .Times(1) |
| 170 .RetiresOnSaturation(); |
| 171 |
| 172 // Check that it is not freed if it is not owned. |
| 173 manager_.Destroy(true); |
| 174 info1 = manager_.GetTextureInfo(kClient1Id); |
| 175 ASSERT_TRUE(info1 == NULL); |
| 176 } |
| 177 |
156 TEST_F(TextureManagerTest, MaxValues) { | 178 TEST_F(TextureManagerTest, MaxValues) { |
157 // Check we get the right values for the max sizes. | 179 // Check we get the right values for the max sizes. |
158 EXPECT_EQ(kMax2dLevels, manager_.MaxLevelsForTarget(GL_TEXTURE_2D)); | 180 EXPECT_EQ(kMax2dLevels, manager_.MaxLevelsForTarget(GL_TEXTURE_2D)); |
159 EXPECT_EQ(kMaxCubeMapLevels, | 181 EXPECT_EQ(kMaxCubeMapLevels, |
160 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP)); | 182 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP)); |
161 EXPECT_EQ(kMaxCubeMapLevels, | 183 EXPECT_EQ(kMaxCubeMapLevels, |
162 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_POSITIVE_X)); | 184 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_POSITIVE_X)); |
163 EXPECT_EQ(kMaxCubeMapLevels, | 185 EXPECT_EQ(kMaxCubeMapLevels, |
164 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_NEGATIVE_X)); | 186 manager_.MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_NEGATIVE_X)); |
165 EXPECT_EQ(kMaxCubeMapLevels, | 187 EXPECT_EQ(kMaxCubeMapLevels, |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 manager.SetInfoTarget(info, GL_TEXTURE_EXTERNAL_OES); | 694 manager.SetInfoTarget(info, GL_TEXTURE_EXTERNAL_OES); |
673 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), info->target()); | 695 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), info->target()); |
674 EXPECT_FALSE(info->CanGenerateMipmaps(&feature_info)); | 696 EXPECT_FALSE(info->CanGenerateMipmaps(&feature_info)); |
675 manager.Destroy(false); | 697 manager.Destroy(false); |
676 } | 698 } |
677 | 699 |
678 } // namespace gles2 | 700 } // namespace gles2 |
679 } // namespace gpu | 701 } // namespace gpu |
680 | 702 |
681 | 703 |
OLD | NEW |