OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ | 5 #ifndef CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ |
6 #define CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ | 6 #define CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 // Return the amount of texture memory required at particular cutoffs. | 77 // Return the amount of texture memory required at particular cutoffs. |
78 size_t MemoryVisibleBytes() const; | 78 size_t MemoryVisibleBytes() const; |
79 size_t MemoryVisibleAndNearbyBytes() const; | 79 size_t MemoryVisibleAndNearbyBytes() const; |
80 | 80 |
81 void PrioritizeTextures(); | 81 void PrioritizeTextures(); |
82 void ClearPriorities(); | 82 void ClearPriorities(); |
83 | 83 |
84 // Delete contents textures' backing resources until they use only | 84 // Delete contents textures' backing resources until they use only |
85 // bytesLimit bytes. This may be called on the impl thread while the main | 85 // limit_bytes bytes. This may be called on the impl thread while the main |
86 // thread is running. Returns true if resources are indeed evicted as a | 86 // thread is running. Returns true if resources are indeed evicted as a |
87 // result of this call. | 87 // result of this call. |
88 bool ReduceMemoryOnImplThread(size_t limit_bytes, | 88 bool ReduceMemoryOnImplThread(size_t limit_bytes, |
89 int priority_cutoff, | 89 int priority_cutoff, |
90 ResourceProvider* resource_provider); | 90 ResourceProvider* resource_provider); |
91 | 91 |
92 // Delete contents textures' backing resources that can be recycled. This | 92 // Delete contents textures' backing resources that can be recycled. This |
93 // may be called on the impl thread while the main thread is running. | 93 // may be called on the impl thread while the main thread is running. |
94 void ReduceWastedMemoryOnImplThread(ResourceProvider* resource_provider); | 94 void ReduceWastedMemoryOnImplThread(ResourceProvider* resource_provider); |
95 | 95 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 gfx::Size size, | 182 gfx::Size size, |
183 GLenum format, | 183 GLenum format, |
184 ResourceProvider* resource_provider); | 184 ResourceProvider* resource_provider); |
185 void EvictFirstBackingResource(ResourceProvider* resource_provider); | 185 void EvictFirstBackingResource(ResourceProvider* resource_provider); |
186 void SortBackings(); | 186 void SortBackings(); |
187 | 187 |
188 void AssertInvariants(); | 188 void AssertInvariants(); |
189 | 189 |
190 size_t max_memory_limit_bytes_; | 190 size_t max_memory_limit_bytes_; |
191 // The priority cutoff based on memory pressure. This is not a strict | 191 // The priority cutoff based on memory pressure. This is not a strict |
192 // cutoff -- requestLate allows textures with priority equal to this | 192 // cutoff -- RequestLate allows textures with priority equal to this |
193 // cutoff to be allowed. | 193 // cutoff to be allowed. |
194 int priority_cutoff_; | 194 int priority_cutoff_; |
195 // The priority cutoff based on external memory policy. This is a strict | 195 // The priority cutoff based on external memory policy. This is a strict |
196 // cutoff -- no textures with priority equal to this cutoff will be allowed. | 196 // cutoff -- no textures with priority equal to this cutoff will be allowed. |
197 int external_priority_cutoff_; | 197 int external_priority_cutoff_; |
198 size_t memory_use_bytes_; | 198 size_t memory_use_bytes_; |
199 size_t memory_above_cutoff_bytes_; | 199 size_t memory_above_cutoff_bytes_; |
200 size_t memory_available_bytes_; | 200 size_t memory_available_bytes_; |
201 | 201 |
202 typedef base::hash_set<PrioritizedResource*> TextureSet; | 202 typedef base::hash_set<PrioritizedResource*> TextureSet; |
(...skipping 10 matching lines...) Expand all Loading... |
213 | 213 |
214 // The list of backings that have been evicted, but may still be linked | 214 // The list of backings that have been evicted, but may still be linked |
215 // to textures. This can be accessed concurrently by the main and impl | 215 // to textures. This can be accessed concurrently by the main and impl |
216 // threads, and may only be accessed while holding evicted_backings_lock_. | 216 // threads, and may only be accessed while holding evicted_backings_lock_. |
217 mutable base::Lock evicted_backings_lock_; | 217 mutable base::Lock evicted_backings_lock_; |
218 BackingList evicted_backings_; | 218 BackingList evicted_backings_; |
219 | 219 |
220 TextureVector temp_texture_vector_; | 220 TextureVector temp_texture_vector_; |
221 | 221 |
222 // Statistics about memory usage at priority cutoffs, computed at | 222 // Statistics about memory usage at priority cutoffs, computed at |
223 // prioritizeTextures. | 223 // PrioritizeTextures. |
224 size_t memory_visible_bytes_; | 224 size_t memory_visible_bytes_; |
225 size_t memory_visible_and_nearby_bytes_; | 225 size_t memory_visible_and_nearby_bytes_; |
226 | 226 |
227 // Statistics copied at the time of pushTexturePrioritiesToBackings. | 227 // Statistics copied at the time of PushTexturePrioritiesToBackings. |
228 size_t memory_visible_last_pushed_bytes_; | 228 size_t memory_visible_last_pushed_bytes_; |
229 size_t memory_visible_and_nearby_last_pushed_bytes_; | 229 size_t memory_visible_and_nearby_last_pushed_bytes_; |
230 | 230 |
231 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager); | 231 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager); |
232 }; | 232 }; |
233 | 233 |
234 } // namespace cc | 234 } // namespace cc |
235 | 235 |
236 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ | 236 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ |
OLD | NEW |