| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_buffer/service/error_state_mock.h" | 8 #include "gpu/command_buffer/service/error_state_mock.h" |
| 9 #include "gpu/command_buffer/service/feature_info.h" | 9 #include "gpu/command_buffer/service/feature_info.h" |
| 10 #include "gpu/command_buffer/service/framebuffer_manager.h" | 10 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kService1Id))) | 198 EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kService1Id))) |
| 199 .Times(1) | 199 .Times(1) |
| 200 .RetiresOnSaturation(); | 200 .RetiresOnSaturation(); |
| 201 TestHelper::SetupTextureManagerDestructionExpectations(gl_.get(), ""); | 201 TestHelper::SetupTextureManagerDestructionExpectations(gl_.get(), ""); |
| 202 manager.Destroy(true); | 202 manager.Destroy(true); |
| 203 // Check that resources got freed. | 203 // Check that resources got freed. |
| 204 texture = manager.GetTexture(kClient1Id); | 204 texture = manager.GetTexture(kClient1Id); |
| 205 ASSERT_TRUE(texture == NULL); | 205 ASSERT_TRUE(texture == NULL); |
| 206 } | 206 } |
| 207 | 207 |
| 208 TEST_F(TextureManagerTest, DestroyUnowned) { | |
| 209 const GLuint kClient1Id = 1; | |
| 210 const GLuint kService1Id = 11; | |
| 211 TestHelper::SetupTextureManagerInitExpectations(gl_.get(), ""); | |
| 212 TextureManager manager( | |
| 213 NULL, feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize); | |
| 214 manager.Initialize(); | |
| 215 // Check we can create texture. | |
| 216 TextureRef* created_texture = | |
| 217 manager.CreateTexture(kClient1Id, kService1Id); | |
| 218 created_texture->texture()->SetNotOwned(); | |
| 219 | |
| 220 // Check texture got created. | |
| 221 TextureRef* texture = manager.GetTexture(kClient1Id); | |
| 222 ASSERT_TRUE(texture != NULL); | |
| 223 | |
| 224 // Check that it is not freed if it is not owned. | |
| 225 TestHelper::SetupTextureManagerDestructionExpectations(gl_.get(), ""); | |
| 226 manager.Destroy(true); | |
| 227 texture = manager.GetTexture(kClient1Id); | |
| 228 ASSERT_TRUE(texture == NULL); | |
| 229 } | |
| 230 | |
| 231 TEST_F(TextureManagerTest, MaxValues) { | 208 TEST_F(TextureManagerTest, MaxValues) { |
| 232 // Check we get the right values for the max sizes. | 209 // Check we get the right values for the max sizes. |
| 233 EXPECT_EQ(kMax2dLevels, manager_->MaxLevelsForTarget(GL_TEXTURE_2D)); | 210 EXPECT_EQ(kMax2dLevels, manager_->MaxLevelsForTarget(GL_TEXTURE_2D)); |
| 234 EXPECT_EQ(kMaxCubeMapLevels, | 211 EXPECT_EQ(kMaxCubeMapLevels, |
| 235 manager_->MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP)); | 212 manager_->MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP)); |
| 236 EXPECT_EQ(kMaxCubeMapLevels, | 213 EXPECT_EQ(kMaxCubeMapLevels, |
| 237 manager_->MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_POSITIVE_X)); | 214 manager_->MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_POSITIVE_X)); |
| 238 EXPECT_EQ(kMaxCubeMapLevels, | 215 EXPECT_EQ(kMaxCubeMapLevels, |
| 239 manager_->MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_NEGATIVE_X)); | 216 manager_->MaxLevelsForTarget(GL_TEXTURE_CUBE_MAP_NEGATIVE_X)); |
| 240 EXPECT_EQ(kMaxCubeMapLevels, | 217 EXPECT_EQ(kMaxCubeMapLevels, |
| (...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2363 .Times(1) | 2340 .Times(1) |
| 2364 .RetiresOnSaturation(); | 2341 .RetiresOnSaturation(); |
| 2365 ref2 = NULL; | 2342 ref2 = NULL; |
| 2366 texture_manager2_->RemoveTexture(20); | 2343 texture_manager2_->RemoveTexture(20); |
| 2367 EXPECT_EQ(initial_memory2, | 2344 EXPECT_EQ(initial_memory2, |
| 2368 memory_tracker2_->GetSize(MemoryTracker::kUnmanaged)); | 2345 memory_tracker2_->GetSize(MemoryTracker::kUnmanaged)); |
| 2369 } | 2346 } |
| 2370 | 2347 |
| 2371 } // namespace gles2 | 2348 } // namespace gles2 |
| 2372 } // namespace gpu | 2349 } // namespace gpu |
| OLD | NEW |