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

Unified Diff: content/common/gpu/gpu_memory_manager_unittest.cc

Issue 11677008: Account for unmanaged (e.g, WebGL) use in memory manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/gpu_memory_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_memory_manager_unittest.cc
diff --git a/content/common/gpu/gpu_memory_manager_unittest.cc b/content/common/gpu/gpu_memory_manager_unittest.cc
index 4d7b1c88e9db1c2345077710372250d810d11945..58414f43bee430aa05e3a6bb202d6b2ee6852ff3 100644
--- a/content/common/gpu/gpu_memory_manager_unittest.cc
+++ b/content/common/gpu/gpu_memory_manager_unittest.cc
@@ -145,6 +145,10 @@ class FakeClient : public GpuMemoryManagerClient {
client_state_->SetManagedMemoryStats(stats);
}
+ size_t BytesWhenVisible() const {
+ return allocation_.renderer_allocation.bytes_limit_when_visible;
+ }
+
size_t BytesWhenNotVisible() const {
return allocation_.renderer_allocation.bytes_limit_when_not_visible;
}
@@ -811,4 +815,59 @@ TEST_F(GpuMemoryManagerTest, TestBackgroundMru) {
stub3.BytesWhenNotVisible());
}
+// Test GpuMemoryManager's tracking of unmanaged (e.g, WebGL) memory.
+TEST_F(GpuMemoryManagerTest, TestUnmanagedTracking) {
+ memmgr_.TestingSetAvailableGpuMemory(64);
+ memmgr_.TestingSetBackgroundedAvailableGpuMemory(16);
+ memmgr_.TestingSetUnmanagedLimitStep(16);
+ memmgr_.TestingSetMinimumClientAllocation(8);
+
+ FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true);
+
+ // Expect that the one stub get the maximum tab allocation.
+ Manage();
+ EXPECT_EQ(memmgr_.GetMaximumTabAllocation(),
+ stub1.BytesWhenVisible());
+
+ // Now allocate some unmanaged memory and make sure the amount
+ // goes down.
+ memmgr_.TrackMemoryAllocatedChange(
+ stub1.tracking_group_.get(),
+ 0,
+ 48,
+ gpu::gles2::MemoryTracker::kUnmanaged);
+ Manage();
+ EXPECT_GT(memmgr_.GetMaximumTabAllocation(),
+ stub1.BytesWhenVisible());
+
+ // Now allocate the entire FB worth of unmanaged memory, and
+ // make sure that we stay stuck at the minimum tab allocation.
+ memmgr_.TrackMemoryAllocatedChange(
+ stub1.tracking_group_.get(),
+ 48,
+ 64,
+ gpu::gles2::MemoryTracker::kUnmanaged);
+ Manage();
+ EXPECT_EQ(memmgr_.GetMinimumTabAllocation(),
+ stub1.BytesWhenVisible());
+
+ // Far-oversubscribe the entire FB, and make sure we stay at
+ // the minimum allocation, and don't blow up.
+ memmgr_.TrackMemoryAllocatedChange(
+ stub1.tracking_group_.get(),
+ 64,
+ 999,
+ gpu::gles2::MemoryTracker::kUnmanaged);
+ Manage();
+ EXPECT_EQ(memmgr_.GetMinimumTabAllocation(),
+ stub1.BytesWhenVisible());
+
+ // Delete all tracked memory so we don't hit leak checks.
+ memmgr_.TrackMemoryAllocatedChange(
+ stub1.tracking_group_.get(),
+ 999,
+ 0,
+ gpu::gles2::MemoryTracker::kUnmanaged);
+}
+
} // namespace content
« no previous file with comments | « content/common/gpu/gpu_memory_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698