| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/prioritized_texture.h" | 7 #include "cc/prioritized_texture.h" |
| 8 | 8 |
| 9 #include "cc/prioritized_texture_manager.h" | 9 #include "cc/prioritized_texture_manager.h" |
| 10 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread | 10 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 83 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 84 textureManager->assertInvariants(); | 84 textureManager->assertInvariants(); |
| 85 #endif | 85 #endif |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool textureBackingIsAbovePriorityCutoff(PrioritizedTexture* texture) | 88 bool textureBackingIsAbovePriorityCutoff(PrioritizedTexture* texture) |
| 89 { | 89 { |
| 90 return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate(); | 90 return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 size_t evictedBackingCount(PrioritizedTextureManager* resourceManager) |
| 94 { |
| 95 return resourceManager->m_evictedBackings.size(); |
| 96 } |
| 97 |
| 93 protected: | 98 protected: |
| 94 const IntSize m_textureSize; | 99 const IntSize m_textureSize; |
| 95 const GLenum m_textureFormat; | 100 const GLenum m_textureFormat; |
| 96 WebCompositorInitializer m_compositorInitializer; | 101 WebCompositorInitializer m_compositorInitializer; |
| 97 scoped_ptr<GraphicsContext> m_context; | 102 scoped_ptr<GraphicsContext> m_context; |
| 98 scoped_ptr<ResourceProvider> m_resourceProvider; | 103 scoped_ptr<ResourceProvider> m_resourceProvider; |
| 99 }; | 104 }; |
| 100 | 105 |
| 101 } | 106 } |
| 102 | 107 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 prioritizeTexturesAndBackings(textureManager.get()); | 232 prioritizeTexturesAndBackings(textureManager.get()); |
| 228 for (size_t i = 0; i < maxTextures; ++i) | 233 for (size_t i = 0; i < maxTextures; ++i) |
| 229 EXPECT_EQ(validateTexture(textures[i], false), i < 4); | 234 EXPECT_EQ(validateTexture(textures[i], false), i < 4); |
| 230 { | 235 { |
| 231 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 236 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 232 textureManager->reduceMemory(resourceProvider()); | 237 textureManager->reduceMemory(resourceProvider()); |
| 233 } | 238 } |
| 234 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); | 239 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); |
| 235 | 240 |
| 236 // Do a one-time eviction for one more texture based on priority cutoff | 241 // Do a one-time eviction for one more texture based on priority cutoff |
| 237 PrioritizedTextureManager::BackingList evictedBackings; | 242 textureManager->unlinkAndClearEvictedBackings(); |
| 238 { | 243 { |
| 239 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 244 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 240 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, res
ourceProvider()); | 245 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, res
ourceProvider()); |
| 241 textureManager->getEvictedBackings(evictedBackings); | 246 EXPECT_EQ(0, evictedBackingCount(textureManager.get())); |
| 242 EXPECT_EQ(0, evictedBackings.size()); | |
| 243 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, res
ourceProvider()); | 247 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, res
ourceProvider()); |
| 244 textureManager->getEvictedBackings(evictedBackings); | 248 EXPECT_EQ(1, evictedBackingCount(textureManager.get())); |
| 245 EXPECT_EQ(1, evictedBackings.size()); | |
| 246 } | 249 } |
| 247 textureManager->unlinkEvictedBackings(evictedBackings); | 250 textureManager->unlinkAndClearEvictedBackings(); |
| 248 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryUseBytes()); | 251 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryUseBytes()); |
| 249 | 252 |
| 250 // Re-allocate the the texture after the one-time drop. | 253 // Re-allocate the the texture after the one-time drop. |
| 251 prioritizeTexturesAndBackings(textureManager.get()); | 254 prioritizeTexturesAndBackings(textureManager.get()); |
| 252 for (size_t i = 0; i < maxTextures; ++i) | 255 for (size_t i = 0; i < maxTextures; ++i) |
| 253 EXPECT_EQ(validateTexture(textures[i], false), i < 4); | 256 EXPECT_EQ(validateTexture(textures[i], false), i < 4); |
| 254 { | 257 { |
| 255 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 258 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 256 textureManager->reduceMemory(resourceProvider()); | 259 textureManager->reduceMemory(resourceProvider()); |
| 257 } | 260 } |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleBytes()); | 702 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleBytes()); |
| 700 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryVisibleAndNearbyB
ytes()); | 703 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryVisibleAndNearbyB
ytes()); |
| 701 } | 704 } |
| 702 | 705 |
| 703 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; | 706 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
| 704 textureManager->clearAllMemory(resourceProvider()); | 707 textureManager->clearAllMemory(resourceProvider()); |
| 705 } | 708 } |
| 706 | 709 |
| 707 | 710 |
| 708 } // namespace | 711 } // namespace |
| OLD | NEW |