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

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

Issue 10801014: Add GetStubStats and related functions in GpuMemoryManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing hash specialization on win. Created 8 years, 5 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.h ('k') | content/common/gpu/gpu_memory_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_memory_manager.cc
diff --git a/content/common/gpu/gpu_memory_manager.cc b/content/common/gpu/gpu_memory_manager.cc
index 212b50d0ed90656e91aa3155a9d7695638f7ca89..39b8e48175e3ccec42fd0d52bb15f8a7d4433387 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -48,11 +48,17 @@ size_t CalculateBonusMemoryAllocationBasedOnSize(gfx::Size size) {
#endif
void AssignMemoryAllocations(
- std::vector<GpuCommandBufferStubBase*>& stubs,
- GpuMemoryAllocation allocation) {
- for (std::vector<GpuCommandBufferStubBase*>::iterator it = stubs.begin();
- it != stubs.end(); ++it) {
+ GpuMemoryManager::StubMemoryStatMap* stub_memory_stats,
+ const std::vector<GpuCommandBufferStubBase*>& stubs,
+ GpuMemoryAllocation allocation,
+ bool visible) {
+ for (std::vector<GpuCommandBufferStubBase*>::const_iterator it =
+ stubs.begin();
+ it != stubs.end();
+ ++it) {
(*it)->SetMemoryAllocation(allocation);
+ (*stub_memory_stats)[*it].allocation = allocation;
+ (*stub_memory_stats)[*it].visible = visible;
}
}
@@ -63,7 +69,8 @@ GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
: client_(client),
manage_immediate_scheduled_(false),
max_surfaces_with_frontbuffer_soft_limit_(
- max_surfaces_with_frontbuffer_soft_limit) {
+ max_surfaces_with_frontbuffer_soft_limit),
+ peak_assigned_allocation_sum_(0) {
}
GpuMemoryManager::~GpuMemoryManager() {
@@ -103,6 +110,11 @@ void GpuMemoryManager::ScheduleManage(bool immediate) {
}
}
+size_t GpuMemoryManager::GetAvailableGpuMemory() const {
+ // TODO(mmocny): Implement this with real system figures.
+ return kMaximumAllocationForTabs;
+}
+
// The current Manage algorithm simply classifies contexts (stubs) into
// "foreground", "background", or "hibernated" categories.
// For each of these three categories, there are predefined memory allocation
@@ -216,28 +228,59 @@ void GpuMemoryManager::Manage() {
stubs_with_surface_foreground[0]->GetSurfaceSize());
#endif
+ stub_memory_stats_for_last_manage_.clear();
+
// Now give out allocations to everyone.
- AssignMemoryAllocations(stubs_with_surface_foreground,
+ AssignMemoryAllocations(
+ &stub_memory_stats_for_last_manage_,
+ stubs_with_surface_foreground,
GpuMemoryAllocation(kMinimumAllocationForTab + bonus_allocation,
GpuMemoryAllocation::kHasFrontbuffer |
- GpuMemoryAllocation::kHasBackbuffer));
+ GpuMemoryAllocation::kHasBackbuffer),
+ true);
- AssignMemoryAllocations(stubs_with_surface_background,
- GpuMemoryAllocation(0, GpuMemoryAllocation::kHasFrontbuffer));
+ AssignMemoryAllocations(
+ &stub_memory_stats_for_last_manage_,
+ stubs_with_surface_background,
+ GpuMemoryAllocation(0, GpuMemoryAllocation::kHasFrontbuffer),
+ false);
- AssignMemoryAllocations(stubs_with_surface_hibernated,
- GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers));
+ AssignMemoryAllocations(
+ &stub_memory_stats_for_last_manage_,
+ stubs_with_surface_hibernated,
+ GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers),
+ false);
- AssignMemoryAllocations(stubs_without_surface_foreground,
+ AssignMemoryAllocations(
+ &stub_memory_stats_for_last_manage_,
+ stubs_without_surface_foreground,
GpuMemoryAllocation(kMinimumAllocationForTab,
- GpuMemoryAllocation::kHasNoBuffers));
+ GpuMemoryAllocation::kHasNoBuffers),
+ true);
- AssignMemoryAllocations(stubs_without_surface_background,
+ AssignMemoryAllocations(
+ &stub_memory_stats_for_last_manage_,
+ stubs_without_surface_background,
GpuMemoryAllocation(kMinimumAllocationForTab,
- GpuMemoryAllocation::kHasNoBuffers));
+ GpuMemoryAllocation::kHasNoBuffers),
+ false);
+
+ AssignMemoryAllocations(
+ &stub_memory_stats_for_last_manage_,
+ stubs_without_surface_hibernated,
+ GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers),
+ false);
+
+ size_t assigned_allocation_sum = 0;
+ for (StubMemoryStatMap::iterator it =
+ stub_memory_stats_for_last_manage_.begin();
+ it != stub_memory_stats_for_last_manage_.end();
+ ++it) {
+ assigned_allocation_sum += it->second.allocation.gpu_resource_size_in_bytes;
+ }
- AssignMemoryAllocations(stubs_without_surface_hibernated,
- GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers));
+ if (assigned_allocation_sum > peak_assigned_allocation_sum_)
+ peak_assigned_allocation_sum_ = assigned_allocation_sum;
}
#endif
« no previous file with comments | « content/common/gpu/gpu_memory_manager.h ('k') | content/common/gpu/gpu_memory_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698