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 df9b24b2d4a14577f3efe9041653b10bd2bd1fae..95b02bca11a42e23385aa95148cd3d77fc469be4 100644 |
--- a/content/common/gpu/gpu_memory_manager.cc |
+++ b/content/common/gpu/gpu_memory_manager.cc |
@@ -59,8 +59,6 @@ GpuMemoryManager::GpuMemoryManager( |
bytes_minimum_per_client_(0), |
bytes_default_per_client_(0), |
bytes_allocated_managed_current_(0), |
- bytes_allocated_managed_visible_(0), |
- bytes_allocated_managed_nonvisible_(0), |
bytes_allocated_unmanaged_current_(0), |
bytes_allocated_historical_max_(0), |
bytes_allocated_unmanaged_high_(0), |
@@ -81,18 +79,6 @@ GpuMemoryManager::GpuMemoryManager( |
bytes_minimum_per_client_ = 64 * 1024 * 1024; |
#endif |
- // On Android, always discard everything that is nonvisible. |
- // On Linux and Mac, use as little memory as possible to avoid stability |
- // issues. |
- // http://crbug.com/145600 (Linux) |
- // http://crbug.com/141377 (Mac) |
-#if defined(OS_ANDROID) || defined(OS_MACOSX) || \ |
- (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
- allow_nonvisible_memory_ = false; |
-#else |
- allow_nonvisible_memory_ = true; |
-#endif |
- |
if (command_line->HasSwitch(switches::kForceGpuMemAvailableMb)) { |
base::StringToUint64( |
command_line->GetSwitchValueASCII(switches::kForceGpuMemAvailableMb), |
@@ -110,8 +96,6 @@ GpuMemoryManager::~GpuMemoryManager() { |
DCHECK(clients_nonsurface_.empty()); |
DCHECK(!bytes_allocated_managed_current_); |
DCHECK(!bytes_allocated_unmanaged_current_); |
- DCHECK(!bytes_allocated_managed_visible_); |
- DCHECK(!bytes_allocated_managed_nonvisible_); |
} |
uint64 GpuMemoryManager::GetAvailableGpuMemory() const { |
@@ -298,10 +282,6 @@ GpuMemoryManagerClientState* GpuMemoryManager::CreateClientState( |
GpuMemoryManagerClientState* client_state = new GpuMemoryManagerClientState( |
this, client, tracking_group, has_surface, visible); |
- TrackValueChanged(0, client_state->managed_memory_stats_.bytes_allocated, |
- client_state->visible_ ? |
- &bytes_allocated_managed_visible_ : |
- &bytes_allocated_managed_nonvisible_); |
AddClientToList(client_state); |
ScheduleManage(kScheduleManageNow); |
return client_state; |
@@ -310,10 +290,6 @@ GpuMemoryManagerClientState* GpuMemoryManager::CreateClientState( |
void GpuMemoryManager::OnDestroyClientState( |
GpuMemoryManagerClientState* client_state) { |
RemoveClientFromList(client_state); |
- TrackValueChanged(client_state->managed_memory_stats_.bytes_allocated, 0, |
- client_state->visible_ ? |
- &bytes_allocated_managed_visible_ : |
- &bytes_allocated_managed_nonvisible_); |
ScheduleManage(kScheduleManageLater); |
} |
@@ -326,15 +302,6 @@ void GpuMemoryManager::SetClientStateVisible( |
RemoveClientFromList(client_state); |
client_state->visible_ = visible; |
AddClientToList(client_state); |
- |
- TrackValueChanged(client_state->managed_memory_stats_.bytes_allocated, 0, |
- client_state->visible_ ? |
- &bytes_allocated_managed_nonvisible_ : |
- &bytes_allocated_managed_visible_); |
- TrackValueChanged(0, client_state->managed_memory_stats_.bytes_allocated, |
- client_state->visible_ ? |
- &bytes_allocated_managed_visible_ : |
- &bytes_allocated_managed_nonvisible_); |
ScheduleManage(visible ? kScheduleManageNow : kScheduleManageLater); |
} |
@@ -342,11 +309,6 @@ void GpuMemoryManager::SetClientStateManagedMemoryStats( |
GpuMemoryManagerClientState* client_state, |
const ManagedMemoryStats& stats) |
{ |
- TrackValueChanged(client_state->managed_memory_stats_.bytes_allocated, |
- stats.bytes_allocated, |
- client_state->visible_ ? |
- &bytes_allocated_managed_visible_ : |
- &bytes_allocated_managed_nonvisible_); |
client_state->managed_memory_stats_ = stats; |
// If this is the first time that stats have been received for this |
@@ -501,17 +463,6 @@ uint64 GpuMemoryManager::ComputeClientAllocationWhenVisible( |
return allocation; |
} |
-uint64 GpuMemoryManager::ComputeClientAllocationWhenNonvisible( |
- GpuMemoryManagerClientState* client_state) { |
- if (!client_state->managed_memory_stats_received_) |
- return 0; |
- |
- if (!allow_nonvisible_memory_) |
- return 0; |
- |
- return 9 * client_state->managed_memory_stats_.bytes_required / 8; |
-} |
- |
void GpuMemoryManager::ComputeVisibleSurfacesAllocations() { |
uint64 bytes_available_total = GetAvailableGpuMemory(); |
uint64 bytes_above_required_cap = std::numeric_limits<uint64>::max(); |
@@ -610,7 +561,7 @@ void GpuMemoryManager::ComputeVisibleSurfacesAllocations() { |
} |
// Set the limit for nonvisible clients for when they become visible. |
- // Use the same formula, with a lowered overall cap to in case any of the |
+ // Use the same formula, with a lowered overall cap in case any of the |
// currently-nonvisible clients are much more resource-intensive than any |
// of the existing clients. |
uint64 bytes_overall_cap_nonvisible = bytes_allocated_max_client_allocation; |
@@ -633,75 +584,6 @@ void GpuMemoryManager::ComputeVisibleSurfacesAllocations() { |
} |
} |
-void GpuMemoryManager::ComputeNonvisibleSurfacesAllocations() { |
- uint64 bytes_allocated_visible = 0; |
- for (ClientStateList::const_iterator it = clients_visible_mru_.begin(); |
- it != clients_visible_mru_.end(); |
- ++it) { |
- GpuMemoryManagerClientState* client_state = *it; |
- bytes_allocated_visible += client_state->bytes_allocation_when_visible_; |
- } |
- |
- // Allow up to 1/4 of the memory that was available for visible clients to |
- // go to nonvisible clients. |
- uint64 bytes_available_total = GetAvailableGpuMemory(); |
- uint64 bytes_available_nonvisible = 0; |
- uint64 bytes_allocated_nonvisible = 0; |
- if (bytes_available_total > bytes_allocated_visible) { |
- bytes_available_nonvisible = std::min( |
- bytes_available_total / 4, |
- bytes_available_total - bytes_allocated_visible); |
- } |
- |
- // Determine which now-visible clients should keep their contents when |
- // they are made nonvisible. |
- for (ClientStateList::const_iterator it = clients_visible_mru_.begin(); |
- it != clients_visible_mru_.end(); |
- ++it) { |
- GpuMemoryManagerClientState* client_state = *it; |
- |
- // Compute the amount of space available have for this renderer when it is |
- // nonvisible. Do not count this client's allocation while visible against |
- // the nonvisible clients' allocation total. |
- uint64 bytes_available_nonvisible_adjusted = std::min( |
- bytes_available_nonvisible + |
- client_state->bytes_allocation_when_visible_ / 4, |
- bytes_available_total / 4); |
- |
- // Allow this client to keep its contents if they fit in the allocation. |
- client_state->bytes_allocation_when_nonvisible_ = |
- ComputeClientAllocationWhenNonvisible(client_state); |
- if (client_state->bytes_allocation_when_nonvisible_ > |
- bytes_available_nonvisible_adjusted) |
- client_state->bytes_allocation_when_nonvisible_ = 0; |
- } |
- |
- // Compute which currently nonvisible clients should keep their contents. |
- for (ClientStateList::const_iterator it = clients_nonvisible_mru_.begin(); |
- it != clients_nonvisible_mru_.end(); |
- ++it) { |
- GpuMemoryManagerClientState* client_state = *it; |
- |
- // If this client is nonvisible and has already had its contents discarded, |
- // don't re-generate the contents until the client becomes visible again. |
- if (!client_state->bytes_allocation_when_nonvisible_) |
- continue; |
- |
- client_state->bytes_allocation_when_nonvisible_ = |
- ComputeClientAllocationWhenNonvisible(client_state); |
- |
- // Take into account all more recently used nonvisible clients, and only if |
- // this client still fits, all it to keep its contents. |
- if (bytes_allocated_nonvisible + |
- client_state->bytes_allocation_when_nonvisible_ > |
- bytes_available_nonvisible) { |
- client_state->bytes_allocation_when_nonvisible_ = 0; |
- } |
- bytes_allocated_nonvisible += |
- client_state->bytes_allocation_when_nonvisible_; |
- } |
-} |
- |
void GpuMemoryManager::DistributeRemainingMemoryToVisibleSurfaces() { |
uint64 bytes_available_total = GetAvailableGpuMemory(); |
uint64 bytes_allocated_total = 0; |
@@ -712,12 +594,6 @@ void GpuMemoryManager::DistributeRemainingMemoryToVisibleSurfaces() { |
GpuMemoryManagerClientState* client_state = *it; |
bytes_allocated_total += client_state->bytes_allocation_when_visible_; |
} |
- for (ClientStateList::const_iterator it = clients_nonvisible_mru_.begin(); |
- it != clients_nonvisible_mru_.end(); |
- ++it) { |
- GpuMemoryManagerClientState* client_state = *it; |
- bytes_allocated_total += client_state->bytes_allocation_when_nonvisible_; |
- } |
if (bytes_allocated_total >= bytes_available_total) |
return; |
@@ -749,7 +625,6 @@ void GpuMemoryManager::DistributeRemainingMemoryToVisibleSurfaces() { |
void GpuMemoryManager::AssignSurfacesAllocations() { |
// Compute allocation when for all clients. |
ComputeVisibleSurfacesAllocations(); |
- ComputeNonvisibleSurfacesAllocations(); |
// Distribute the remaining memory to visible clients. |
DistributeRemainingMemoryToVisibleSurfaces(); |
@@ -787,11 +662,6 @@ void GpuMemoryManager::AssignSurfacesAllocations() { |
MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; |
#endif |
- allocation.bytes_limit_when_not_visible = |
- client_state->bytes_allocation_when_nonvisible_; |
- allocation.priority_cutoff_when_not_visible = |
- MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; |
- |
client_state->client_->SetMemoryAllocation(allocation); |
client_state->client_->SuggestHaveFrontBuffer(!client_state->hibernated_); |
} |