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 "cc/resources/prioritized_resource.h" | 5 #include "cc/resources/prioritized_resource.h" |
6 | 6 |
7 #include "cc/resources/prioritized_resource_manager.h" | 7 #include "cc/resources/prioritized_resource_manager.h" |
8 #include "cc/resources/resource.h" | 8 #include "cc/resources/resource.h" |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/fake_proxy.h" | 10 #include "cc/test/fake_proxy.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes()); | 249 EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes()); |
250 | 250 |
251 // Do a one-time eviction for one more texture based on priority cutoff | 251 // Do a one-time eviction for one more texture based on priority cutoff |
252 PrioritizedResourceManager::BackingList evicted_backings; | 252 PrioritizedResourceManager::BackingList evicted_backings; |
253 resource_manager->UnlinkAndClearEvictedBackings(); | 253 resource_manager->UnlinkAndClearEvictedBackings(); |
254 { | 254 { |
255 DebugScopedSetImplThreadAndMainThreadBlocked | 255 DebugScopedSetImplThreadAndMainThreadBlocked |
256 impl_thread_and_main_thread_blocked(&proxy_); | 256 impl_thread_and_main_thread_blocked(&proxy_); |
257 resource_manager->ReduceMemoryOnImplThread( | 257 resource_manager->ReduceMemoryOnImplThread( |
258 TexturesMemorySize(8), 104, ResourceProvider()); | 258 TexturesMemorySize(8), 104, ResourceProvider()); |
259 EXPECT_EQ(0, EvictedBackingCount(resource_manager.get())); | 259 EXPECT_EQ(0u, EvictedBackingCount(resource_manager.get())); |
260 resource_manager->ReduceMemoryOnImplThread( | 260 resource_manager->ReduceMemoryOnImplThread( |
261 TexturesMemorySize(8), 103, ResourceProvider()); | 261 TexturesMemorySize(8), 103, ResourceProvider()); |
262 EXPECT_EQ(1, EvictedBackingCount(resource_manager.get())); | 262 EXPECT_EQ(1u, EvictedBackingCount(resource_manager.get())); |
263 } | 263 } |
264 resource_manager->UnlinkAndClearEvictedBackings(); | 264 resource_manager->UnlinkAndClearEvictedBackings(); |
265 EXPECT_EQ(TexturesMemorySize(3), resource_manager->MemoryUseBytes()); | 265 EXPECT_EQ(TexturesMemorySize(3), resource_manager->MemoryUseBytes()); |
266 | 266 |
267 // Re-allocate the the texture after the one-time drop. | 267 // Re-allocate the the texture after the one-time drop. |
268 PrioritizeTexturesAndBackings(resource_manager.get()); | 268 PrioritizeTexturesAndBackings(resource_manager.get()); |
269 for (size_t i = 0; i < kMaxTextures; ++i) | 269 for (size_t i = 0; i < kMaxTextures; ++i) |
270 EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 4); | 270 EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 4); |
271 { | 271 { |
272 DebugScopedSetImplThreadAndMainThreadBlocked | 272 DebugScopedSetImplThreadAndMainThreadBlocked |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 const ResourceUpdate upload = ResourceUpdate::Create( | 687 const ResourceUpdate upload = ResourceUpdate::Create( |
688 textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d()); | 688 textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d()); |
689 queue.AppendFullUpload(upload); | 689 queue.AppendFullUpload(upload); |
690 } | 690 } |
691 | 691 |
692 // Make sure that we have backings for all of the textures. | 692 // Make sure that we have backings for all of the textures. |
693 for (size_t i = 0; i < kMaxTextures; ++i) | 693 for (size_t i = 0; i < kMaxTextures; ++i) |
694 EXPECT_TRUE(textures[i]->have_backing_texture()); | 694 EXPECT_TRUE(textures[i]->have_backing_texture()); |
695 | 695 |
696 queue.ClearUploadsToEvictedResources(); | 696 queue.ClearUploadsToEvictedResources(); |
697 EXPECT_EQ(4, queue.FullUploadSize()); | 697 EXPECT_EQ(4u, queue.FullUploadSize()); |
698 | 698 |
699 resource_manager->ReduceMemoryOnImplThread( | 699 resource_manager->ReduceMemoryOnImplThread( |
700 TexturesMemorySize(1), | 700 TexturesMemorySize(1), |
701 PriorityCalculator::AllowEverythingCutoff(), | 701 PriorityCalculator::AllowEverythingCutoff(), |
702 ResourceProvider()); | 702 ResourceProvider()); |
703 queue.ClearUploadsToEvictedResources(); | 703 queue.ClearUploadsToEvictedResources(); |
704 EXPECT_EQ(1, queue.FullUploadSize()); | 704 EXPECT_EQ(1u, queue.FullUploadSize()); |
705 | 705 |
706 resource_manager->ReduceMemoryOnImplThread( | 706 resource_manager->ReduceMemoryOnImplThread( |
707 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider()); | 707 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider()); |
708 queue.ClearUploadsToEvictedResources(); | 708 queue.ClearUploadsToEvictedResources(); |
709 EXPECT_EQ(0, queue.FullUploadSize()); | 709 EXPECT_EQ(0u, queue.FullUploadSize()); |
710 } | 710 } |
711 | 711 |
712 TEST_F(PrioritizedResourceTest, UsageStatistics) { | 712 TEST_F(PrioritizedResourceTest, UsageStatistics) { |
713 const size_t kMaxTextures = 5; | 713 const size_t kMaxTextures = 5; |
714 scoped_ptr<PrioritizedResourceManager> resource_manager = | 714 scoped_ptr<PrioritizedResourceManager> resource_manager = |
715 CreateManager(kMaxTextures); | 715 CreateManager(kMaxTextures); |
716 scoped_ptr<PrioritizedResource> textures[kMaxTextures]; | 716 scoped_ptr<PrioritizedResource> textures[kMaxTextures]; |
717 | 717 |
718 for (size_t i = 0; i < kMaxTextures; ++i) { | 718 for (size_t i = 0; i < kMaxTextures; ++i) { |
719 textures[i] = | 719 textures[i] = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 resource_manager->MemoryVisibleAndNearbyBytes()); | 783 resource_manager->MemoryVisibleAndNearbyBytes()); |
784 } | 784 } |
785 | 785 |
786 DebugScopedSetImplThreadAndMainThreadBlocked | 786 DebugScopedSetImplThreadAndMainThreadBlocked |
787 impl_thread_and_main_thread_blocked(&proxy_); | 787 impl_thread_and_main_thread_blocked(&proxy_); |
788 resource_manager->ClearAllMemory(ResourceProvider()); | 788 resource_manager->ClearAllMemory(ResourceProvider()); |
789 } | 789 } |
790 | 790 |
791 } // namespace | 791 } // namespace |
792 } // namespace cc | 792 } // namespace cc |
OLD | NEW |