Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: content/common/gpu/gpu_memory_manager.h

Issue 11677008: Account for unmanaged (e.g, WebGL) use in memory manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/common/gpu/gpu_memory_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if defined(ENABLE_GPU) 8 #if defined(ENABLE_GPU)
9 9
10 #include <list> 10 #include <list>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 80 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
81 GpuMemoryAllocationCompareTests); 81 GpuMemoryAllocationCompareTests);
82 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 82 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
83 StubMemoryStatsForLastManageTests); 83 StubMemoryStatsForLastManageTests);
84 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 84 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
85 TestManagedUsageTracking); 85 TestManagedUsageTracking);
86 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 86 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
87 TestBackgroundCutoff); 87 TestBackgroundCutoff);
88 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 88 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
89 TestBackgroundMru); 89 TestBackgroundMru);
90 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
91 TestUnmanagedTracking);
90 92
91 typedef std::map<gpu::gles2::MemoryTracker*, GpuMemoryTrackingGroup*> 93 typedef std::map<gpu::gles2::MemoryTracker*, GpuMemoryTrackingGroup*>
92 TrackingGroupMap; 94 TrackingGroupMap;
93 95
94 typedef std::list<GpuMemoryManagerClientState*> ClientStateList; 96 typedef std::list<GpuMemoryManagerClientState*> ClientStateList;
95 97
96 void Manage(); 98 void Manage();
97 void SetClientsHibernatedState() const; 99 void SetClientsHibernatedState() const;
98 size_t GetVisibleClientAllocation() const; 100 size_t GetVisibleClientAllocation() const;
99 size_t GetCurrentBackgroundedAvailableGpuMemory() const; 101 size_t GetCurrentBackgroundedAvailableGpuMemory() const;
100 102
101 // Update the amount of GPU memory we think we have in the system, based 103 // Update the amount of GPU memory we think we have in the system, based
102 // on what the stubs' contexts report. 104 // on what the stubs' contexts report.
103 void UpdateAvailableGpuMemory(); 105 void UpdateAvailableGpuMemory();
106 void UpdateUnmanagedMemoryLimits();
104 void UpdateBackgroundedAvailableGpuMemory(); 107 void UpdateBackgroundedAvailableGpuMemory();
105 108
106 // The amount of video memory which is available for allocation. 109 // The amount of video memory which is available for allocation.
107 size_t GetAvailableGpuMemory() const; 110 size_t GetAvailableGpuMemory() const;
108 111
109 // Minimum value of available GPU memory, no matter how little the GPU 112 // Minimum value of available GPU memory, no matter how little the GPU
110 // reports. This is the default value. 113 // reports. This is the default value.
111 size_t GetDefaultAvailableGpuMemory() const; 114 size_t GetDefaultAvailableGpuMemory() const;
112 115
113 // Maximum cap on total GPU memory, no matter how much the GPU reports. 116 // Maximum cap on total GPU memory, no matter how much the GPU reports.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 void RemoveClientFromList(GpuMemoryManagerClientState* client_state); 155 void RemoveClientFromList(GpuMemoryManagerClientState* client_state);
153 ClientStateList* GetClientList(GpuMemoryManagerClientState* client_state); 156 ClientStateList* GetClientList(GpuMemoryManagerClientState* client_state);
154 157
155 // Interfaces for testing 158 // Interfaces for testing
156 void TestingDisableScheduleManage() { disable_schedule_manage_ = true; } 159 void TestingDisableScheduleManage() { disable_schedule_manage_ = true; }
157 void TestingSetAvailableGpuMemory(size_t bytes) { 160 void TestingSetAvailableGpuMemory(size_t bytes) {
158 bytes_available_gpu_memory_ = bytes; 161 bytes_available_gpu_memory_ = bytes;
159 bytes_available_gpu_memory_overridden_ = true; 162 bytes_available_gpu_memory_overridden_ = true;
160 } 163 }
161 164
165 void TestingSetMinimumClientAllocation(size_t bytes) {
166 bytes_minimum_per_client_ = bytes;
167 bytes_minimum_per_client_overridden_ = true;
168 }
169
170 void TestingSetUnmanagedLimitStep(size_t bytes) {
171 bytes_unmanaged_limit_step_ = bytes;
172 }
173
162 void TestingSetBackgroundedAvailableGpuMemory(size_t bytes) { 174 void TestingSetBackgroundedAvailableGpuMemory(size_t bytes) {
163 bytes_backgrounded_available_gpu_memory_ = bytes; 175 bytes_backgrounded_available_gpu_memory_ = bytes;
164 } 176 }
165 177
166 GpuChannelManager* channel_manager_; 178 GpuChannelManager* channel_manager_;
167 179
168 // A list of all visible and nonvisible clients, in most-recently-used 180 // A list of all visible and nonvisible clients, in most-recently-used
169 // order (most recently used is first). 181 // order (most recently used is first).
170 ClientStateList clients_visible_mru_; 182 ClientStateList clients_visible_mru_;
171 ClientStateList clients_nonvisible_mru_; 183 ClientStateList clients_nonvisible_mru_;
172 184
173 // A list of all clients that don't have a surface. 185 // A list of all clients that don't have a surface.
174 ClientStateList clients_nonsurface_; 186 ClientStateList clients_nonsurface_;
175 187
176 // All context groups' tracking structures 188 // All context groups' tracking structures
177 TrackingGroupMap tracking_groups_; 189 TrackingGroupMap tracking_groups_;
178 190
179 base::CancelableClosure delayed_manage_callback_; 191 base::CancelableClosure delayed_manage_callback_;
180 bool manage_immediate_scheduled_; 192 bool manage_immediate_scheduled_;
181 193
182 size_t max_surfaces_with_frontbuffer_soft_limit_; 194 size_t max_surfaces_with_frontbuffer_soft_limit_;
183 195
184 // The maximum amount of memory that may be allocated for GPU resources 196 // The maximum amount of memory that may be allocated for GPU resources
185 size_t bytes_available_gpu_memory_; 197 size_t bytes_available_gpu_memory_;
186 bool bytes_available_gpu_memory_overridden_; 198 bool bytes_available_gpu_memory_overridden_;
187 199
200 // The minimum allocation that may be given to a single renderer.
201 size_t bytes_minimum_per_client_;
202 bool bytes_minimum_per_client_overridden_;
203
188 // The maximum amount of memory that can be allocated for GPU resources 204 // The maximum amount of memory that can be allocated for GPU resources
189 // in backgrounded renderers. 205 // in backgrounded renderers.
190 size_t bytes_backgrounded_available_gpu_memory_; 206 size_t bytes_backgrounded_available_gpu_memory_;
191 207
192 // The current total memory usage, and historical maximum memory usage 208 // The current total memory usage, and historical maximum memory usage
193 size_t bytes_allocated_managed_current_; 209 size_t bytes_allocated_managed_current_;
194 size_t bytes_allocated_managed_visible_; 210 size_t bytes_allocated_managed_visible_;
195 size_t bytes_allocated_managed_backgrounded_; 211 size_t bytes_allocated_managed_backgrounded_;
196 size_t bytes_allocated_unmanaged_current_; 212 size_t bytes_allocated_unmanaged_current_;
197 size_t bytes_allocated_historical_max_; 213 size_t bytes_allocated_historical_max_;
198 214
215 // If bytes_allocated_unmanaged_current_ leaves the interval [low_, high_),
216 // then ScheduleManage to take the change into account.
217 size_t bytes_allocated_unmanaged_high_;
218 size_t bytes_allocated_unmanaged_low_;
219
220 // Update bytes_allocated_unmanaged_low/high_ in intervals of step_.
221 size_t bytes_unmanaged_limit_step_;
222
199 // The number of browser windows that exist. If we ever receive a 223 // The number of browser windows that exist. If we ever receive a
200 // GpuMsg_SetVideoMemoryWindowCount, then we use this to compute memory 224 // GpuMsg_SetVideoMemoryWindowCount, then we use this to compute memory
201 // budgets, instead of doing more complicated stub-based calculations. 225 // budgets, instead of doing more complicated stub-based calculations.
202 bool window_count_has_been_received_; 226 bool window_count_has_been_received_;
203 uint32 window_count_; 227 uint32 window_count_;
204 228
205 // Used to disable automatic changes to Manage() in testing. 229 // Used to disable automatic changes to Manage() in testing.
206 bool disable_schedule_manage_; 230 bool disable_schedule_manage_;
207 231
208 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); 232 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager);
209 }; 233 };
210 234
211 } // namespace content 235 } // namespace content
212 236
213 #endif 237 #endif
214 238
215 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ 239 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/gpu_memory_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698