| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | |
| 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <list> | |
| 11 #include <map> | |
| 12 | |
| 13 #include "base/cancelable_callback.h" | |
| 14 #include "base/containers/hash_tables.h" | |
| 15 #include "base/gtest_prod_util.h" | |
| 16 #include "base/macros.h" | |
| 17 #include "base/memory/weak_ptr.h" | |
| 18 #include "content/common/content_export.h" | |
| 19 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | |
| 20 #include "gpu/command_buffer/service/memory_tracking.h" | |
| 21 | |
| 22 namespace gpu { | |
| 23 struct VideoMemoryUsageStats; | |
| 24 } | |
| 25 | |
| 26 namespace content { | |
| 27 | |
| 28 class GpuChannelManager; | |
| 29 class GpuMemoryTrackingGroup; | |
| 30 | |
| 31 class CONTENT_EXPORT GpuMemoryManager : | |
| 32 public base::SupportsWeakPtr<GpuMemoryManager> { | |
| 33 public: | |
| 34 explicit GpuMemoryManager(GpuChannelManager* channel_manager); | |
| 35 ~GpuMemoryManager(); | |
| 36 | |
| 37 // Retrieve GPU Resource consumption statistics for the task manager | |
| 38 void GetVideoMemoryUsageStats( | |
| 39 gpu::VideoMemoryUsageStats* video_memory_usage_stats) const; | |
| 40 | |
| 41 GpuMemoryTrackingGroup* CreateTrackingGroup( | |
| 42 base::ProcessId pid, gpu::gles2::MemoryTracker* memory_tracker); | |
| 43 | |
| 44 uint64_t GetTrackerMemoryUsage(gpu::gles2::MemoryTracker* tracker) const; | |
| 45 | |
| 46 private: | |
| 47 friend class GpuMemoryManagerTest; | |
| 48 friend class GpuMemoryTrackingGroup; | |
| 49 friend class GpuMemoryManagerClientState; | |
| 50 | |
| 51 typedef std::map<gpu::gles2::MemoryTracker*, GpuMemoryTrackingGroup*> | |
| 52 TrackingGroupMap; | |
| 53 | |
| 54 // Send memory usage stats to the browser process. | |
| 55 void SendUmaStatsToHost(); | |
| 56 | |
| 57 // Get the current number of bytes allocated. | |
| 58 uint64_t GetCurrentUsage() const { return bytes_allocated_current_; } | |
| 59 | |
| 60 // GpuMemoryTrackingGroup interface | |
| 61 void TrackMemoryAllocatedChange(GpuMemoryTrackingGroup* tracking_group, | |
| 62 uint64_t old_size, | |
| 63 uint64_t new_size); | |
| 64 void OnDestroyTrackingGroup(GpuMemoryTrackingGroup* tracking_group); | |
| 65 bool EnsureGPUMemoryAvailable(uint64_t size_needed); | |
| 66 | |
| 67 GpuChannelManager* channel_manager_; | |
| 68 | |
| 69 // All context groups' tracking structures | |
| 70 TrackingGroupMap tracking_groups_; | |
| 71 | |
| 72 // The current total memory usage, and historical maximum memory usage | |
| 73 uint64_t bytes_allocated_current_; | |
| 74 uint64_t bytes_allocated_historical_max_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); | |
| 77 }; | |
| 78 | |
| 79 } // namespace content | |
| 80 | |
| 81 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | |
| OLD | NEW |