Chromium Code Reviews| Index: content/common/gpu/gpu_memory_manager.h |
| diff --git a/content/common/gpu/gpu_memory_manager.h b/content/common/gpu/gpu_memory_manager.h |
| index ecab989d857a02effd9b60836fc4ac2c296484e0..8e12e17c31b9748380982f6baf26e25f212328f0 100644 |
| --- a/content/common/gpu/gpu_memory_manager.h |
| +++ b/content/common/gpu/gpu_memory_manager.h |
| @@ -8,11 +8,13 @@ |
| #if defined(ENABLE_GPU) |
| #include <vector> |
| +#include <map> |
| #include "base/basictypes.h" |
| #include "base/cancelable_callback.h" |
| #include "base/memory/weak_ptr.h" |
| #include "content/common/content_export.h" |
| +#include "content/common/gpu/gpu_memory_allocation.h" |
| class GpuCommandBufferStubBase; |
| @@ -46,6 +48,14 @@ class CONTENT_EXPORT GpuMemoryManager : |
| #endif |
| }; |
| + // StubMemoryStat is used to store memory-allocation-related information about |
| + // a GpuCommandBufferStubBase for some time point. |
| + struct StubMemoryStat { |
| + bool visible; |
| + GpuMemoryAllocationRequest requested_allocation; |
| + GpuMemoryAllocation allocation; |
| + }; |
| + |
| GpuMemoryManager(GpuMemoryManagerClient* client, |
| size_t max_surfaces_with_frontbuffer_soft_limit); |
| ~GpuMemoryManager(); |
| @@ -57,6 +67,26 @@ class CONTENT_EXPORT GpuMemoryManager : |
| // queued delayed manage. |
| void ScheduleManage(bool immediate); |
| + // Returns StubMemoryStat's for each GpuCommandBufferStubBase, which were |
| + // assigned during the most recent call to Manage(). |
| + // Useful for tracking the memory-allocation-related presumed state of the |
| + // system, as seen by GpuMemoryManager. |
| + std::map<GpuCommandBufferStubBase*, StubMemoryStat> |
|
piman
2012/07/18 19:59:58
I suggest returning const std::map<...>& to avoid
|
| + GetStubStatsForLastManage() const { |
| + return stub_memory_stats_; |
| + } |
| + |
| + // Tries to estimate the total available gpu memory for use by |
| + // GpuMemoryManager. Ideally should consider other system applications and |
| + // other internal but non GpuMemoryManager managed sources, etc. |
| + size_t GetAvailableGpuMemory() const; |
| + |
| + // GetPeakAssignedAllocationSum() will return the historical max value for the |
| + // sum of all assigned client allocations (ie, peak system memory allocation). |
| + size_t GetPeakAssignedAllocationSum() const { |
|
piman
2012/07/18 19:59:58
nit: usually for trivial inline functions that jus
|
| + return peak_assigned_allocation_sum_; |
| + } |
| + |
| private: |
| friend class GpuMemoryManagerTest; |
| void Manage(); |
| @@ -74,6 +104,9 @@ class CONTENT_EXPORT GpuMemoryManager : |
| size_t max_surfaces_with_frontbuffer_soft_limit_; |
| + std::map<GpuCommandBufferStubBase*, StubMemoryStat> stub_memory_stats_; |
| + size_t peak_assigned_allocation_sum_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); |
| }; |