| 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 1023120ee2364a6f71768ca042121a112b25505f..b9d73e0f096a07b5d90ddc1fe2955839d880ce22 100644
|
| --- a/content/common/gpu/gpu_memory_manager.h
|
| +++ b/content/common/gpu/gpu_memory_manager.h
|
| @@ -7,17 +7,21 @@
|
|
|
| #if defined(ENABLE_GPU)
|
|
|
| +#include <set>
|
| #include <vector>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/cancelable_callback.h"
|
| #include "base/hash_tables.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/process.h"
|
| #include "content/common/content_export.h"
|
| #include "content/common/gpu/gpu_memory_allocation.h"
|
| +#include "content/public/common/gpu_info.h"
|
| #include "ui/gfx/size.h"
|
|
|
| class GpuCommandBufferStubBase;
|
| +class GpuMemoryTrackingGroup;
|
|
|
| #if defined(COMPILER_GCC)
|
| namespace BASE_HASH_NAMESPACE {
|
| @@ -63,6 +67,14 @@ class CONTENT_EXPORT GpuMemoryManager :
|
| // queued delayed manage.
|
| void ScheduleManage(bool immediate);
|
|
|
| + // Retrieve GPU Resource consumption statistics for the task manager
|
| + void GetVidmemUsageStats(
|
| + content::GPUVidmemUsageStats& vidmem_usage_stats) const;
|
| +
|
| + // Add and remove structures to track context groups' memory consumption
|
| + void AddTrackingGroup(GpuMemoryTrackingGroup* tracking_group);
|
| + void RemoveTrackingGroup(GpuMemoryTrackingGroup* tracking_group);
|
| +
|
| // 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
|
| @@ -81,6 +93,9 @@ class CONTENT_EXPORT GpuMemoryManager :
|
|
|
| void Manage();
|
|
|
| + // The context groups' tracking structures
|
| + std::set<GpuMemoryTrackingGroup*> tracking_groups_;
|
| +
|
| size_t CalculateBonusMemoryAllocationBasedOnSize(gfx::Size size) const;
|
|
|
| size_t GetAvailableGpuMemory() const {
|
| @@ -121,6 +136,44 @@ class CONTENT_EXPORT GpuMemoryManager :
|
| DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager);
|
| };
|
|
|
| +// All decoders in a context group point to a single GpuMemoryTrackingGroup,
|
| +// which tracks GPU resource consumption for the entire context group.
|
| +class GpuMemoryTrackingGroup {
|
| + public:
|
| + GpuMemoryTrackingGroup(base::ProcessId pid, GpuMemoryManager* memory_manager)
|
| + : pid_(pid),
|
| + size_(0),
|
| + memory_manager_(memory_manager) {
|
| + memory_manager_->AddTrackingGroup(this);
|
| + }
|
| + ~GpuMemoryTrackingGroup() {
|
| + memory_manager_->RemoveTrackingGroup(this);
|
| + }
|
| + void TrackMemoryAllocatedChange(size_t old_size, size_t new_size) {
|
| + if (old_size < new_size) {
|
| + size_t delta = new_size - old_size;
|
| + size_ += delta;
|
| + }
|
| + if (new_size < old_size) {
|
| + size_t delta = old_size - new_size;
|
| + DCHECK(size_ >= delta);
|
| + size_ -= delta;
|
| + }
|
| + memory_manager_->TrackMemoryAllocatedChange(old_size, new_size);
|
| + }
|
| + base::ProcessId GetPid() const {
|
| + return pid_;
|
| + }
|
| + size_t GetSize() const {
|
| + return size_;
|
| + }
|
| +
|
| + private:
|
| + base::ProcessId pid_;
|
| + size_t size_;
|
| + GpuMemoryManager* memory_manager_;
|
| +};
|
| +
|
| #endif
|
|
|
| #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_
|
|
|