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