diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 08:46:48 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 08:46:48 +0000 |
commit | bee73f5d39bf7358d1e1b0590404ed7511fd6f61 (patch) | |
tree | b3250099cbe0cf567184e602676551d4f0636a56 /content/common/gpu/gpu_memory_manager_unittest.cc | |
parent | 3f869667a8206993904b53faf62325dd333ec14e (diff) | |
download | chromium_src-bee73f5d39bf7358d1e1b0590404ed7511fd6f61.zip chromium_src-bee73f5d39bf7358d1e1b0590404ed7511fd6f61.tar.gz chromium_src-bee73f5d39bf7358d1e1b0590404ed7511fd6f61.tar.bz2 |
Add a flag to specify the total amount of memory which may be allocated to GPU resources.
Change constants in GpuMemoryManager to helper functions (and variables).
This is towards (1) automated testing of the GPU memory manager and (2) getting actual vidmem values.
BUG=132994
Review URL: https://chromiumcodereview.appspot.com/10823092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/gpu/gpu_memory_manager_unittest.cc')
-rw-r--r-- | content/common/gpu/gpu_memory_manager_unittest.cc | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/content/common/gpu/gpu_memory_manager_unittest.cc b/content/common/gpu/gpu_memory_manager_unittest.cc index d20742d..3336cc2 100644 --- a/content/common/gpu/gpu_memory_manager_unittest.cc +++ b/content/common/gpu/gpu_memory_manager_unittest.cc @@ -114,40 +114,37 @@ class GpuMemoryManagerTest : public testing::Test { return GpuMemoryManager::StubWithSurfaceComparator()(lhs, rhs); } - static bool IsAllocationForegroundForSurfaceYes( + bool IsAllocationForegroundForSurfaceYes( const GpuMemoryAllocation& alloc) { return alloc.suggest_have_frontbuffer && alloc.suggest_have_backbuffer && - alloc.gpu_resource_size_in_bytes >= - GpuMemoryManager::kMinimumAllocationForTab; + alloc.gpu_resource_size_in_bytes >= GetMinimumTabAllocation(); } - static bool IsAllocationBackgroundForSurfaceYes( + bool IsAllocationBackgroundForSurfaceYes( const GpuMemoryAllocation& alloc) { return alloc.suggest_have_frontbuffer && !alloc.suggest_have_backbuffer && alloc.gpu_resource_size_in_bytes == 0; } - static bool IsAllocationHibernatedForSurfaceYes( + bool IsAllocationHibernatedForSurfaceYes( const GpuMemoryAllocation& alloc) { return !alloc.suggest_have_frontbuffer && !alloc.suggest_have_backbuffer && alloc.gpu_resource_size_in_bytes == 0; } - static bool IsAllocationForegroundForSurfaceNo( + bool IsAllocationForegroundForSurfaceNo( const GpuMemoryAllocation& alloc) { return !alloc.suggest_have_frontbuffer && !alloc.suggest_have_backbuffer && - alloc.gpu_resource_size_in_bytes == - GpuMemoryManager::kMinimumAllocationForTab; + alloc.gpu_resource_size_in_bytes == GetMinimumTabAllocation(); } - static bool IsAllocationBackgroundForSurfaceNo( + bool IsAllocationBackgroundForSurfaceNo( const GpuMemoryAllocation& alloc) { return !alloc.suggest_have_frontbuffer && !alloc.suggest_have_backbuffer && - alloc.gpu_resource_size_in_bytes == - GpuMemoryManager::kMinimumAllocationForTab; + alloc.gpu_resource_size_in_bytes == GetMinimumTabAllocation(); } - static bool IsAllocationHibernatedForSurfaceNo( + bool IsAllocationHibernatedForSurfaceNo( const GpuMemoryAllocation& alloc) { return !alloc.suggest_have_frontbuffer && !alloc.suggest_have_backbuffer && @@ -158,6 +155,14 @@ class GpuMemoryManagerTest : public testing::Test { memory_manager_.Manage(); } + size_t GetAvailableGpuMemory() { + return memory_manager_.GetAvailableGpuMemory(); + } + + size_t GetMinimumTabAllocation() { + return memory_manager_.GetMinimumTabAllocation(); + } + base::TimeTicks older_, newer_, newest_; FakeClient client_; GpuMemoryManager memory_manager_; @@ -481,12 +486,11 @@ TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) { // Test GpuMemoryAllocation memory allocation bonuses: // When the number of visible tabs is small, each tab should get a // gpu_resource_size_in_bytes allocation value that is greater than -// kMinimumAllocationForTab, and when the number of tabs is large, each should -// get exactly kMinimumAllocationForTab and not less. +// GetMinimumTabAllocation(), and when the number of tabs is large, each should +// get exactly GetMinimumTabAllocation() and not less. TEST_F(GpuMemoryManagerTest, TestForegroundStubsGetBonusAllocation) { size_t max_stubs_before_no_bonus = - GpuMemoryManager::kMaximumAllocationForTabs / - (GpuMemoryManager::kMinimumAllocationForTab + 1); + GetAvailableGpuMemory() / (GetMinimumTabAllocation() + 1); std::vector<FakeCommandBufferStub> stubs; for (size_t i = 0; i < max_stubs_before_no_bonus; ++i) { @@ -501,7 +505,7 @@ TEST_F(GpuMemoryManagerTest, TestForegroundStubsGetBonusAllocation) { for (size_t i = 0; i < stubs.size(); ++i) { EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stubs[i].allocation_)); EXPECT_GT(stubs[i].allocation_.gpu_resource_size_in_bytes, - static_cast<size_t>(GpuMemoryManager::kMinimumAllocationForTab)); + static_cast<size_t>(GetMinimumTabAllocation())); } FakeCommandBufferStub extra_stub(GenerateUniqueSurfaceId(), true, older_); @@ -511,7 +515,7 @@ TEST_F(GpuMemoryManagerTest, TestForegroundStubsGetBonusAllocation) { for (size_t i = 0; i < stubs.size(); ++i) { EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stubs[i].allocation_)); EXPECT_EQ(stubs[i].allocation_.gpu_resource_size_in_bytes, - GpuMemoryManager::kMinimumAllocationForTab); + GetMinimumTabAllocation()); } } #else @@ -527,12 +531,12 @@ TEST_F(GpuMemoryManagerTest, TestForegroundStubsGetBonusAllocationAndroid) { Manage(); EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_)); EXPECT_EQ(stub.allocation_.gpu_resource_size_in_bytes, - GpuMemoryManager::kMinimumAllocationForTab); + GetMinimumTabAllocation()); // Keep increasing size, making sure allocation is always increasing // Until it finally reaches the maximum. while (stub.allocation_.gpu_resource_size_in_bytes < - GpuMemoryManager::kMaximumAllocationForTabs) { + GetAvailableGpuMemory()) { size_t previous_allocation = stub.allocation_.gpu_resource_size_in_bytes; stub.size_ = stub.size_.Scale(1, 2); @@ -540,9 +544,9 @@ TEST_F(GpuMemoryManagerTest, TestForegroundStubsGetBonusAllocationAndroid) { Manage(); EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_)); EXPECT_GE(stub.allocation_.gpu_resource_size_in_bytes, - GpuMemoryManager::kMinimumAllocationForTab); + GetMinimumTabAllocation()); EXPECT_LE(stub.allocation_.gpu_resource_size_in_bytes, - GpuMemoryManager::kMaximumAllocationForTabs); + GetAvailableGpuMemory()); EXPECT_GE(stub.allocation_.gpu_resource_size_in_bytes, previous_allocation); } @@ -553,7 +557,7 @@ TEST_F(GpuMemoryManagerTest, TestForegroundStubsGetBonusAllocationAndroid) { Manage(); EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_)); EXPECT_EQ(stub.allocation_.gpu_resource_size_in_bytes, - GpuMemoryManager::kMaximumAllocationForTabs); + GetAvailableGpuMemory()); } #endif |