| 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 39b8e48175e3ccec42fd0d52bb15f8a7d4433387..10883287bcc803ef7c16f44f85ed54d58757154b 100644
|
| --- a/content/common/gpu/gpu_memory_manager.cc
|
| +++ b/content/common/gpu/gpu_memory_manager.cc
|
| @@ -9,6 +9,7 @@
|
| #include <algorithm>
|
|
|
| #include "base/bind.h"
|
| +#include "base/debug/trace_event.h"
|
| #include "base/message_loop.h"
|
| #include "content/common/gpu/gpu_command_buffer_stub.h"
|
| #include "content/common/gpu/gpu_memory_allocation.h"
|
| @@ -70,7 +71,8 @@ GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
|
| manage_immediate_scheduled_(false),
|
| max_surfaces_with_frontbuffer_soft_limit_(
|
| max_surfaces_with_frontbuffer_soft_limit),
|
| - peak_assigned_allocation_sum_(0) {
|
| + bytes_allocated_current_(0),
|
| + bytes_allocated_historical_max_(0) {
|
| }
|
|
|
| GpuMemoryManager::~GpuMemoryManager() {
|
| @@ -115,6 +117,29 @@ size_t GpuMemoryManager::GetAvailableGpuMemory() const {
|
| return kMaximumAllocationForTabs;
|
| }
|
|
|
| +void GpuMemoryManager::TrackMemoryAllocatedChange(size_t old_size,
|
| + size_t new_size)
|
| +{
|
| + if (new_size < old_size) {
|
| + size_t delta = old_size - new_size;
|
| + DCHECK(bytes_allocated_current_ >= delta);
|
| + bytes_allocated_current_ -= delta;
|
| + }
|
| + else {
|
| + size_t delta = new_size - old_size;
|
| + bytes_allocated_current_ += delta;
|
| + if (bytes_allocated_current_ > bytes_allocated_historical_max_) {
|
| + bytes_allocated_historical_max_ = bytes_allocated_current_;
|
| + }
|
| + }
|
| + if (new_size != old_size) {
|
| + TRACE_COUNTER_ID1("GpuMemoryManager",
|
| + "GpuMemoryUsage",
|
| + this,
|
| + bytes_allocated_current_);
|
| + }
|
| +}
|
| +
|
| // 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
|
| @@ -278,9 +303,6 @@ void GpuMemoryManager::Manage() {
|
| ++it) {
|
| assigned_allocation_sum += it->second.allocation.gpu_resource_size_in_bytes;
|
| }
|
| -
|
| - if (assigned_allocation_sum > peak_assigned_allocation_sum_)
|
| - peak_assigned_allocation_sum_ = assigned_allocation_sum;
|
| }
|
|
|
| #endif
|
|
|