Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: cc/resources/prioritized_resource_unittest.cc

Issue 13206004: cc: Fix build issues for adding ‘chromium_code’: 1 to cc.gyp and cc_tests.gyp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes()); 255 EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes());
256 256
257 // Do a one-time eviction for one more texture based on priority cutoff 257 // Do a one-time eviction for one more texture based on priority cutoff
258 PrioritizedResourceManager::BackingList evicted_backings; 258 PrioritizedResourceManager::BackingList evicted_backings;
259 resource_manager->UnlinkAndClearEvictedBackings(); 259 resource_manager->UnlinkAndClearEvictedBackings();
260 { 260 {
261 DebugScopedSetImplThreadAndMainThreadBlocked 261 DebugScopedSetImplThreadAndMainThreadBlocked
262 impl_thread_and_main_thread_blocked(&proxy_); 262 impl_thread_and_main_thread_blocked(&proxy_);
263 resource_manager->ReduceMemoryOnImplThread( 263 resource_manager->ReduceMemoryOnImplThread(
264 TexturesMemorySize(8), 104, ResourceProvider()); 264 TexturesMemorySize(8), 104, ResourceProvider());
265 EXPECT_EQ(0, EvictedBackingCount(resource_manager.get())); 265 EXPECT_EQ(0u, EvictedBackingCount(resource_manager.get()));
266 resource_manager->ReduceMemoryOnImplThread( 266 resource_manager->ReduceMemoryOnImplThread(
267 TexturesMemorySize(8), 103, ResourceProvider()); 267 TexturesMemorySize(8), 103, ResourceProvider());
268 EXPECT_EQ(1, EvictedBackingCount(resource_manager.get())); 268 EXPECT_EQ(1u, EvictedBackingCount(resource_manager.get()));
269 } 269 }
270 resource_manager->UnlinkAndClearEvictedBackings(); 270 resource_manager->UnlinkAndClearEvictedBackings();
271 EXPECT_EQ(TexturesMemorySize(3), resource_manager->MemoryUseBytes()); 271 EXPECT_EQ(TexturesMemorySize(3), resource_manager->MemoryUseBytes());
272 272
273 // Re-allocate the the texture after the one-time drop. 273 // Re-allocate the the texture after the one-time drop.
274 PrioritizeTexturesAndBackings(resource_manager.get()); 274 PrioritizeTexturesAndBackings(resource_manager.get());
275 for (size_t i = 0; i < kMaxTextures; ++i) 275 for (size_t i = 0; i < kMaxTextures; ++i)
276 EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 4); 276 EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 4);
277 { 277 {
278 DebugScopedSetImplThreadAndMainThreadBlocked 278 DebugScopedSetImplThreadAndMainThreadBlocked
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 const ResourceUpdate upload = ResourceUpdate::Create( 697 const ResourceUpdate upload = ResourceUpdate::Create(
698 textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d()); 698 textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d());
699 queue.AppendFullUpload(upload); 699 queue.AppendFullUpload(upload);
700 } 700 }
701 701
702 // Make sure that we have backings for all of the textures. 702 // Make sure that we have backings for all of the textures.
703 for (size_t i = 0; i < kMaxTextures; ++i) 703 for (size_t i = 0; i < kMaxTextures; ++i)
704 EXPECT_TRUE(textures[i]->have_backing_texture()); 704 EXPECT_TRUE(textures[i]->have_backing_texture());
705 705
706 queue.ClearUploadsToEvictedResources(); 706 queue.ClearUploadsToEvictedResources();
707 EXPECT_EQ(4, queue.FullUploadSize()); 707 EXPECT_EQ(4u, queue.FullUploadSize());
708 708
709 resource_manager->ReduceMemoryOnImplThread( 709 resource_manager->ReduceMemoryOnImplThread(
710 TexturesMemorySize(1), 710 TexturesMemorySize(1),
711 PriorityCalculator::AllowEverythingCutoff(), 711 PriorityCalculator::AllowEverythingCutoff(),
712 ResourceProvider()); 712 ResourceProvider());
713 queue.ClearUploadsToEvictedResources(); 713 queue.ClearUploadsToEvictedResources();
714 EXPECT_EQ(1, queue.FullUploadSize()); 714 EXPECT_EQ(1u, queue.FullUploadSize());
715 715
716 resource_manager->ReduceMemoryOnImplThread( 716 resource_manager->ReduceMemoryOnImplThread(
717 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider()); 717 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider());
718 queue.ClearUploadsToEvictedResources(); 718 queue.ClearUploadsToEvictedResources();
719 EXPECT_EQ(0, queue.FullUploadSize()); 719 EXPECT_EQ(0u, queue.FullUploadSize());
720 } 720 }
721 721
722 TEST_F(PrioritizedResourceTest, UsageStatistics) { 722 TEST_F(PrioritizedResourceTest, UsageStatistics) {
723 const size_t kMaxTextures = 5; 723 const size_t kMaxTextures = 5;
724 scoped_ptr<PrioritizedResourceManager> resource_manager = 724 scoped_ptr<PrioritizedResourceManager> resource_manager =
725 CreateManager(kMaxTextures); 725 CreateManager(kMaxTextures);
726 scoped_ptr<PrioritizedResource> textures[kMaxTextures]; 726 scoped_ptr<PrioritizedResource> textures[kMaxTextures];
727 727
728 for (size_t i = 0; i < kMaxTextures; ++i) { 728 for (size_t i = 0; i < kMaxTextures; ++i) {
729 textures[i] = 729 textures[i] =
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 resource_manager->MemoryVisibleAndNearbyBytes()); 793 resource_manager->MemoryVisibleAndNearbyBytes());
794 } 794 }
795 795
796 DebugScopedSetImplThreadAndMainThreadBlocked 796 DebugScopedSetImplThreadAndMainThreadBlocked
797 impl_thread_and_main_thread_blocked(&proxy_); 797 impl_thread_and_main_thread_blocked(&proxy_);
798 resource_manager->ClearAllMemory(ResourceProvider()); 798 resource_manager->ClearAllMemory(ResourceProvider());
799 } 799 }
800 800
801 } // namespace 801 } // namespace
802 } // namespace cc 802 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/prioritized_resource_manager.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698