| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 void SetClientsHibernatedState() const; | 109 void SetClientsHibernatedState() const; |
| 110 void AssignSurfacesAllocations(); | 110 void AssignSurfacesAllocations(); |
| 111 void AssignNonSurfacesAllocations(); | 111 void AssignNonSurfacesAllocations(); |
| 112 | 112 |
| 113 // Math helper function to compute the maximum value of cap such that | 113 // Math helper function to compute the maximum value of cap such that |
| 114 // sum_i min(bytes[i], cap) <= bytes_sum_limit | 114 // sum_i min(bytes[i], cap) <= bytes_sum_limit |
| 115 static uint64 ComputeCap(std::vector<uint64> bytes, uint64 bytes_sum_limit); | 115 static uint64 ComputeCap(std::vector<uint64> bytes, uint64 bytes_sum_limit); |
| 116 | 116 |
| 117 // Compute the allocation for clients when visible and not visible. | 117 // Compute the allocation for clients when visible and not visible. |
| 118 void ComputeVisibleSurfacesAllocations(); | 118 void ComputeVisibleSurfacesAllocations(); |
| 119 void ComputeNonvisibleSurfacesAllocations(); | |
| 120 void DistributeRemainingMemoryToVisibleSurfaces(); | 119 void DistributeRemainingMemoryToVisibleSurfaces(); |
| 121 | 120 |
| 122 // Compute the budget for a client. Allow at most bytes_above_required_cap | 121 // Compute the budget for a client. Allow at most bytes_above_required_cap |
| 123 // bytes above client_state's required level. Allow at most | 122 // bytes above client_state's required level. Allow at most |
| 124 // bytes_above_minimum_cap bytes above client_state's minimum level. Allow | 123 // bytes_above_minimum_cap bytes above client_state's minimum level. Allow |
| 125 // at most bytes_overall_cap bytes total. | 124 // at most bytes_overall_cap bytes total. |
| 126 uint64 ComputeClientAllocationWhenVisible( | 125 uint64 ComputeClientAllocationWhenVisible( |
| 127 GpuMemoryManagerClientState* client_state, | 126 GpuMemoryManagerClientState* client_state, |
| 128 uint64 bytes_above_required_cap, | 127 uint64 bytes_above_required_cap, |
| 129 uint64 bytes_above_minimum_cap, | 128 uint64 bytes_above_minimum_cap, |
| 130 uint64 bytes_overall_cap); | 129 uint64 bytes_overall_cap); |
| 131 uint64 ComputeClientAllocationWhenNonvisible( | |
| 132 GpuMemoryManagerClientState* client_state); | |
| 133 | 130 |
| 134 // Update the amount of GPU memory we think we have in the system, based | 131 // Update the amount of GPU memory we think we have in the system, based |
| 135 // on what the stubs' contexts report. | 132 // on what the stubs' contexts report. |
| 136 void UpdateAvailableGpuMemory(); | 133 void UpdateAvailableGpuMemory(); |
| 137 void UpdateUnmanagedMemoryLimits(); | 134 void UpdateUnmanagedMemoryLimits(); |
| 138 | 135 |
| 139 // The amount of video memory which is available for allocation. | 136 // The amount of video memory which is available for allocation. |
| 140 uint64 GetAvailableGpuMemory() const; | 137 uint64 GetAvailableGpuMemory() const; |
| 141 | 138 |
| 142 // Minimum value of available GPU memory, no matter how little the GPU | 139 // Minimum value of available GPU memory, no matter how little the GPU |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 222 |
| 226 base::CancelableClosure delayed_manage_callback_; | 223 base::CancelableClosure delayed_manage_callback_; |
| 227 bool manage_immediate_scheduled_; | 224 bool manage_immediate_scheduled_; |
| 228 | 225 |
| 229 uint64 max_surfaces_with_frontbuffer_soft_limit_; | 226 uint64 max_surfaces_with_frontbuffer_soft_limit_; |
| 230 | 227 |
| 231 // The maximum amount of memory that may be allocated for GPU resources | 228 // The maximum amount of memory that may be allocated for GPU resources |
| 232 uint64 bytes_available_gpu_memory_; | 229 uint64 bytes_available_gpu_memory_; |
| 233 bool bytes_available_gpu_memory_overridden_; | 230 bool bytes_available_gpu_memory_overridden_; |
| 234 | 231 |
| 235 // Whether or not clients can be allocated memory when nonvisible. | |
| 236 bool allow_nonvisible_memory_; | |
| 237 | |
| 238 // The minimum and default allocations for a single client. | 232 // The minimum and default allocations for a single client. |
| 239 uint64 bytes_minimum_per_client_; | 233 uint64 bytes_minimum_per_client_; |
| 240 uint64 bytes_default_per_client_; | 234 uint64 bytes_default_per_client_; |
| 241 | 235 |
| 242 // The current total memory usage, and historical maximum memory usage | 236 // The current total memory usage, and historical maximum memory usage |
| 243 uint64 bytes_allocated_managed_current_; | 237 uint64 bytes_allocated_managed_current_; |
| 244 uint64 bytes_allocated_managed_visible_; | |
| 245 uint64 bytes_allocated_managed_nonvisible_; | |
| 246 uint64 bytes_allocated_unmanaged_current_; | 238 uint64 bytes_allocated_unmanaged_current_; |
| 247 uint64 bytes_allocated_historical_max_; | 239 uint64 bytes_allocated_historical_max_; |
| 248 | 240 |
| 249 // If bytes_allocated_unmanaged_current_ leaves the interval [low_, high_), | 241 // If bytes_allocated_unmanaged_current_ leaves the interval [low_, high_), |
| 250 // then ScheduleManage to take the change into account. | 242 // then ScheduleManage to take the change into account. |
| 251 uint64 bytes_allocated_unmanaged_high_; | 243 uint64 bytes_allocated_unmanaged_high_; |
| 252 uint64 bytes_allocated_unmanaged_low_; | 244 uint64 bytes_allocated_unmanaged_low_; |
| 253 | 245 |
| 254 // Update bytes_allocated_unmanaged_low/high_ in intervals of step_. | 246 // Update bytes_allocated_unmanaged_low/high_ in intervals of step_. |
| 255 uint64 bytes_unmanaged_limit_step_; | 247 uint64 bytes_unmanaged_limit_step_; |
| 256 | 248 |
| 257 // Used to disable automatic changes to Manage() in testing. | 249 // Used to disable automatic changes to Manage() in testing. |
| 258 bool disable_schedule_manage_; | 250 bool disable_schedule_manage_; |
| 259 | 251 |
| 260 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); | 252 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); |
| 261 }; | 253 }; |
| 262 | 254 |
| 263 } // namespace content | 255 } // namespace content |
| 264 | 256 |
| 265 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | 257 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
| OLD | NEW |