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 CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 StubMemoryStatsForLastManageTests); | 88 StubMemoryStatsForLastManageTests); |
89 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, | 89 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, |
90 TestManagedUsageTracking); | 90 TestManagedUsageTracking); |
91 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, | 91 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, |
92 TestBackgroundCutoff); | 92 TestBackgroundCutoff); |
93 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, | 93 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, |
94 TestBackgroundMru); | 94 TestBackgroundMru); |
95 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, | 95 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, |
96 TestUnmanagedTracking); | 96 TestUnmanagedTracking); |
97 | 97 |
98 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform, | |
99 BackgroundMru); | |
100 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform, | |
101 BackgroundDiscardPersistent); | |
102 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform, | |
103 UnmanagedTracking); | |
104 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform, | |
105 DefaultAllocation); | |
ccameron
2013/01/30 21:03:19
This list is getting fairly absurdly long. There
| |
106 | |
98 typedef std::map<gpu::gles2::MemoryTracker*, GpuMemoryTrackingGroup*> | 107 typedef std::map<gpu::gles2::MemoryTracker*, GpuMemoryTrackingGroup*> |
99 TrackingGroupMap; | 108 TrackingGroupMap; |
100 | 109 |
101 typedef std::list<GpuMemoryManagerClientState*> ClientStateList; | 110 typedef std::list<GpuMemoryManagerClientState*> ClientStateList; |
102 | 111 |
103 void Manage(); | 112 void Manage(); |
104 void SetClientsHibernatedState() const; | 113 void SetClientsHibernatedState() const; |
105 uint64 GetVisibleClientAllocation() const; | 114 uint64 GetVisibleClientAllocation() const; |
106 uint64 GetCurrentNonvisibleAvailableGpuMemory() const; | 115 uint64 GetCurrentNonvisibleAvailableGpuMemory() const; |
107 void AssignSurfacesAllocationsNonuniform(); | 116 void AssignSurfacesAllocationsNonuniform(); |
(...skipping 29 matching lines...) Expand all Loading... | |
137 // The amount of video memory which is available for allocation. | 146 // The amount of video memory which is available for allocation. |
138 uint64 GetAvailableGpuMemory() const; | 147 uint64 GetAvailableGpuMemory() const; |
139 | 148 |
140 // Minimum value of available GPU memory, no matter how little the GPU | 149 // Minimum value of available GPU memory, no matter how little the GPU |
141 // reports. This is the default value. | 150 // reports. This is the default value. |
142 uint64 GetDefaultAvailableGpuMemory() const; | 151 uint64 GetDefaultAvailableGpuMemory() const; |
143 | 152 |
144 // Maximum cap on total GPU memory, no matter how much the GPU reports. | 153 // Maximum cap on total GPU memory, no matter how much the GPU reports. |
145 uint64 GetMaximumTotalGpuMemory() const; | 154 uint64 GetMaximumTotalGpuMemory() const; |
146 | 155 |
147 // The maximum and minimum amount of memory that a tab may be assigned. | 156 // The maximum and minimum amount of memory that a client may be assigned. |
148 uint64 GetMaximumClientAllocation() const; | 157 uint64 GetMaximumClientAllocation() const; |
149 uint64 GetMinimumClientAllocation() const; | 158 uint64 GetMinimumClientAllocation() const { |
159 return bytes_minimum_per_client_; | |
160 } | |
161 // The default amount of memory that a client is assigned, if it has not | |
162 // reported any memory usage stats yet. | |
163 uint64 GetDefaultClientAllocation() const { | |
164 return bytes_default_per_client_; | |
165 } | |
150 | 166 |
151 // Get a reasonable memory limit from a viewport's surface area. | 167 // Get a reasonable memory limit from a viewport's surface area. |
152 static uint64 CalcAvailableFromViewportArea(int viewport_area); | 168 static uint64 CalcAvailableFromViewportArea(int viewport_area); |
153 static uint64 CalcAvailableFromGpuTotal(uint64 total_gpu_memory); | 169 static uint64 CalcAvailableFromGpuTotal(uint64 total_gpu_memory); |
154 | 170 |
155 // Send memory usage stats to the browser process. | 171 // Send memory usage stats to the browser process. |
156 void SendUmaStatsToBrowser(); | 172 void SendUmaStatsToBrowser(); |
157 | 173 |
158 // Get the current number of bytes allocated. | 174 // Get the current number of bytes allocated. |
159 uint64 GetCurrentUsage() const { | 175 uint64 GetCurrentUsage() const { |
(...skipping 18 matching lines...) Expand all Loading... | |
178 const GpuManagedMemoryStats& stats); | 194 const GpuManagedMemoryStats& stats); |
179 void OnDestroyClientState(GpuMemoryManagerClientState* client); | 195 void OnDestroyClientState(GpuMemoryManagerClientState* client); |
180 | 196 |
181 // Add or remove a client from its clients list (visible, nonvisible, or | 197 // Add or remove a client from its clients list (visible, nonvisible, or |
182 // nonsurface). When adding the client, add it to the front of the list. | 198 // nonsurface). When adding the client, add it to the front of the list. |
183 void AddClientToList(GpuMemoryManagerClientState* client_state); | 199 void AddClientToList(GpuMemoryManagerClientState* client_state); |
184 void RemoveClientFromList(GpuMemoryManagerClientState* client_state); | 200 void RemoveClientFromList(GpuMemoryManagerClientState* client_state); |
185 ClientStateList* GetClientList(GpuMemoryManagerClientState* client_state); | 201 ClientStateList* GetClientList(GpuMemoryManagerClientState* client_state); |
186 | 202 |
187 // Interfaces for testing | 203 // Interfaces for testing |
204 void TestingSetUseNonuniformMemoryPolicy(bool use_nonuniform_memory_policy) { | |
205 use_nonuniform_memory_policy_ = use_nonuniform_memory_policy; | |
206 } | |
188 void TestingDisableScheduleManage() { disable_schedule_manage_ = true; } | 207 void TestingDisableScheduleManage() { disable_schedule_manage_ = true; } |
189 void TestingSetAvailableGpuMemory(uint64 bytes) { | 208 void TestingSetAvailableGpuMemory(uint64 bytes) { |
190 bytes_available_gpu_memory_ = bytes; | 209 bytes_available_gpu_memory_ = bytes; |
191 bytes_available_gpu_memory_overridden_ = true; | 210 bytes_available_gpu_memory_overridden_ = true; |
192 } | 211 } |
193 | 212 |
194 void TestingSetMinimumClientAllocation(uint64 bytes) { | 213 void TestingSetMinimumClientAllocation(uint64 bytes) { |
195 bytes_minimum_per_client_ = bytes; | 214 bytes_minimum_per_client_ = bytes; |
196 bytes_minimum_per_client_overridden_ = true; | 215 } |
216 | |
217 void TestingSetDefaultClientAllocation(uint64 bytes) { | |
218 bytes_default_per_client_ = bytes; | |
197 } | 219 } |
198 | 220 |
199 void TestingSetUnmanagedLimitStep(uint64 bytes) { | 221 void TestingSetUnmanagedLimitStep(uint64 bytes) { |
200 bytes_unmanaged_limit_step_ = bytes; | 222 bytes_unmanaged_limit_step_ = bytes; |
201 } | 223 } |
202 | 224 |
203 void TestingSetNonvisibleAvailableGpuMemory(uint64 bytes) { | 225 void TestingSetNonvisibleAvailableGpuMemory(uint64 bytes) { |
204 bytes_nonvisible_available_gpu_memory_ = bytes; | 226 bytes_nonvisible_available_gpu_memory_ = bytes; |
205 } | 227 } |
206 | 228 |
(...skipping 16 matching lines...) Expand all Loading... | |
223 | 245 |
224 base::CancelableClosure delayed_manage_callback_; | 246 base::CancelableClosure delayed_manage_callback_; |
225 bool manage_immediate_scheduled_; | 247 bool manage_immediate_scheduled_; |
226 | 248 |
227 uint64 max_surfaces_with_frontbuffer_soft_limit_; | 249 uint64 max_surfaces_with_frontbuffer_soft_limit_; |
228 | 250 |
229 // The maximum amount of memory that may be allocated for GPU resources | 251 // The maximum amount of memory that may be allocated for GPU resources |
230 uint64 bytes_available_gpu_memory_; | 252 uint64 bytes_available_gpu_memory_; |
231 bool bytes_available_gpu_memory_overridden_; | 253 bool bytes_available_gpu_memory_overridden_; |
232 | 254 |
233 // The minimum allocation that may be given to a single renderer. | 255 // The minimum and default allocations for a single client. |
234 uint64 bytes_minimum_per_client_; | 256 uint64 bytes_minimum_per_client_; |
235 bool bytes_minimum_per_client_overridden_; | 257 uint64 bytes_default_per_client_; |
236 | 258 |
237 // The maximum amount of memory that can be allocated for GPU resources | 259 // The maximum amount of memory that can be allocated for GPU resources |
238 // in nonvisible renderers. | 260 // in nonvisible renderers. |
239 uint64 bytes_nonvisible_available_gpu_memory_; | 261 uint64 bytes_nonvisible_available_gpu_memory_; |
240 | 262 |
241 // The current total memory usage, and historical maximum memory usage | 263 // The current total memory usage, and historical maximum memory usage |
242 uint64 bytes_allocated_managed_current_; | 264 uint64 bytes_allocated_managed_current_; |
243 uint64 bytes_allocated_managed_visible_; | 265 uint64 bytes_allocated_managed_visible_; |
244 uint64 bytes_allocated_managed_nonvisible_; | 266 uint64 bytes_allocated_managed_nonvisible_; |
245 uint64 bytes_allocated_unmanaged_current_; | 267 uint64 bytes_allocated_unmanaged_current_; |
(...skipping 15 matching lines...) Expand all Loading... | |
261 | 283 |
262 // Used to disable automatic changes to Manage() in testing. | 284 // Used to disable automatic changes to Manage() in testing. |
263 bool disable_schedule_manage_; | 285 bool disable_schedule_manage_; |
264 | 286 |
265 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); | 287 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); |
266 }; | 288 }; |
267 | 289 |
268 } // namespace content | 290 } // namespace content |
269 | 291 |
270 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | 292 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
OLD | NEW |