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 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCPrioritizedTextureManager.h" | 7 #include "CCPrioritizedTextureManager.h" |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "CCPrioritizedTexture.h" | 10 #include "CCPrioritizedTexture.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 | 28 |
29 CCPrioritizedTextureManager::~CCPrioritizedTextureManager() | 29 CCPrioritizedTextureManager::~CCPrioritizedTextureManager() |
30 { | 30 { |
31 while (m_textures.size() > 0) | 31 while (m_textures.size() > 0) |
32 unregisterTexture(*m_textures.begin()); | 32 unregisterTexture(*m_textures.begin()); |
33 | 33 |
34 deleteUnlinkedEvictedBackings(); | 34 deleteUnlinkedEvictedBackings(); |
35 ASSERT(m_evictedBackings.isEmpty()); | 35 ASSERT(m_evictedBackings.isEmpty()); |
36 | 36 |
37 // Each remaining backing is a leaked opengl texture. There should be none. | 37 // Each remaining backing is a leaked opengl texture. There should be none. |
38 ASSERT(m_backings.isEmpty()); | 38 ASSERT(m_backings.empty()); |
39 } | 39 } |
40 | 40 |
41 void CCPrioritizedTextureManager::prioritizeTextures() | 41 void CCPrioritizedTextureManager::prioritizeTextures() |
42 { | 42 { |
43 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::prioritizeTextures"); | 43 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::prioritizeTextures"); |
44 ASSERT(CCProxy::isMainThread()); | 44 ASSERT(CCProxy::isMainThread()); |
45 | 45 |
46 // Sorting textures in this function could be replaced by a slightly | 46 // Sorting textures in this function could be replaced by a slightly |
47 // modified O(n) quick-select to partition textures rather than | 47 // modified O(n) quick-select to partition textures rather than |
48 // sort them (if performance of the sort becomes an issue). | 48 // sort them (if performance of the sort becomes an issue). |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 96 |
97 ASSERT(m_memoryAboveCutoffBytes <= m_memoryAvailableBytes); | 97 ASSERT(m_memoryAboveCutoffBytes <= m_memoryAvailableBytes); |
98 ASSERT(memoryAboveCutoffBytes() <= maxMemoryLimitBytes()); | 98 ASSERT(memoryAboveCutoffBytes() <= maxMemoryLimitBytes()); |
99 } | 99 } |
100 | 100 |
101 void CCPrioritizedTextureManager::pushTexturePrioritiesToBackings() | 101 void CCPrioritizedTextureManager::pushTexturePrioritiesToBackings() |
102 { | 102 { |
103 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::pushTexturePrioritiesToBack ings"); | 103 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::pushTexturePrioritiesToBack ings"); |
104 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 104 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
105 | 105 |
106 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it) | 106 assertInvariants(); |
107 for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) | |
107 (*it)->updatePriority(); | 108 (*it)->updatePriority(); |
108 | |
109 sortBackings(); | 109 sortBackings(); |
110 assertInvariants(); | |
110 } | 111 } |
111 | 112 |
112 void CCPrioritizedTextureManager::updateBackingsInDrawingImplTree() | 113 void CCPrioritizedTextureManager::updateBackingsInDrawingImplTree() |
113 { | 114 { |
114 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::updateBackingsInDrawingImpl Tree"); | 115 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::updateBackingsInDrawingImpl Tree"); |
115 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 116 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
116 | 117 |
117 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it) { | 118 assertInvariants(); |
119 for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { | |
118 CCPrioritizedTexture::Backing* backing = (*it); | 120 CCPrioritizedTexture::Backing* backing = (*it); |
119 backing->updateInDrawingImplTree(); | 121 backing->updateInDrawingImplTree(); |
120 } | 122 } |
121 | |
122 sortBackings(); | 123 sortBackings(); |
124 assertInvariants(); | |
123 } | 125 } |
124 | 126 |
125 void CCPrioritizedTextureManager::sortBackings() | 127 void CCPrioritizedTextureManager::sortBackings() |
126 { | 128 { |
127 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::updateBackingsPriorities"); | 129 TRACE_EVENT0("cc", "CCPrioritizedTextureManager::sortBackings"); |
128 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 130 ASSERT(CCProxy::isImplThread()); |
129 | 131 |
130 // Update backings' priorities and put backings in eviction/recycling order. | 132 // Put backings in eviction/recycling order. |
131 BackingVector& sortedBackings = m_tempBackingVector; | 133 m_backings.sort(compareBackings); |
jamesr
2012/10/17 01:31:11
can we get rid of the m_tempBackingVector member c
ccameron
2012/10/17 02:13:58
Yeah, it's gone now.
|
jamesr
2012/10/17 01:31:11
cool, I didn't know std::list had a O(n log(n)) so
ccameron
2012/10/17 02:13:58
I didn't know it before today. I'd guess it uses s
|
132 sortedBackings.clear(); | |
133 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it) | |
134 sortedBackings.append(*it); | |
135 std::sort(sortedBackings.begin(), sortedBackings.end(), compareBackings); | |
136 | |
137 for (BackingVector::iterator it = sortedBackings.begin(); it != sortedBackin gs.end(); ++it) { | |
138 m_backings.remove(*it); | |
139 m_backings.add(*it); | |
140 } | |
141 sortedBackings.clear(); | |
142 | |
143 #if !ASSERT_DISABLED | |
144 assertInvariants(); | |
145 #endif | |
146 } | 134 } |
147 | 135 |
148 void CCPrioritizedTextureManager::clearPriorities() | 136 void CCPrioritizedTextureManager::clearPriorities() |
149 { | 137 { |
150 ASSERT(CCProxy::isMainThread()); | 138 ASSERT(CCProxy::isMainThread()); |
151 for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); + +it) { | 139 for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); + +it) { |
152 // FIXME: We should remove this and just set all priorities to | 140 // FIXME: We should remove this and just set all priorities to |
153 // CCPriorityCalculator::lowestPriority() once we have priorities | 141 // CCPriorityCalculator::lowestPriority() once we have priorities |
154 // for all textures (we can't currently calculate distances for | 142 // for all textures (we can't currently calculate distances for |
155 // off-screen textures). | 143 // off-screen textures). |
(...skipping 26 matching lines...) Expand all Loading... | |
182 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 170 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
183 ASSERT(!texture->isSelfManaged()); | 171 ASSERT(!texture->isSelfManaged()); |
184 ASSERT(texture->isAbovePriorityCutoff()); | 172 ASSERT(texture->isAbovePriorityCutoff()); |
185 if (texture->backing() || !texture->isAbovePriorityCutoff()) | 173 if (texture->backing() || !texture->isAbovePriorityCutoff()) |
186 return; | 174 return; |
187 | 175 |
188 // Find a backing below, by either recycling or allocating. | 176 // Find a backing below, by either recycling or allocating. |
189 CCPrioritizedTexture::Backing* backing = 0; | 177 CCPrioritizedTexture::Backing* backing = 0; |
190 | 178 |
191 // First try to recycle | 179 // First try to recycle |
192 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it) { | 180 for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { |
193 if (!(*it)->canBeRecycled()) | 181 if (!(*it)->canBeRecycled()) |
194 break; | 182 break; |
195 if ((*it)->size() == texture->size() && (*it)->format() == texture->form at()) { | 183 if ((*it)->size() == texture->size() && (*it)->format() == texture->form at()) { |
196 backing = (*it); | 184 backing = (*it); |
185 m_backings.erase(it); | |
197 break; | 186 break; |
198 } | 187 } |
199 } | 188 } |
200 | 189 |
201 // Otherwise reduce memory and just allocate a new backing texures. | 190 // Otherwise reduce memory and just allocate a new backing texures. |
202 if (!backing) { | 191 if (!backing) { |
203 evictBackingsToReduceMemory(m_memoryAvailableBytes - texture->bytes(), R espectManagerPriorityCutoff, resourceProvider); | 192 evictBackingsToReduceMemory(m_memoryAvailableBytes - texture->bytes(), R espectManagerPriorityCutoff, resourceProvider); |
204 backing = createBacking(texture->size(), texture->format(), resourceProv ider); | 193 backing = createBacking(texture->size(), texture->format(), resourceProv ider); |
194 ASSERT(backing == m_backings.front()); | |
195 m_backings.pop_front(); | |
205 } | 196 } |
206 | 197 |
207 // Move the used backing texture to the end of the eviction list. | 198 // Move the used backing texture to the end of the eviction list. |
208 if (backing->owner()) | 199 if (backing->owner()) |
209 backing->owner()->unlink(); | 200 backing->owner()->unlink(); |
210 texture->link(backing); | 201 texture->link(backing); |
211 m_backings.remove(backing); | 202 m_backings.push_back(backing); |
212 m_backings.add(backing); | |
213 | 203 |
214 // Update the backing's priority from its new owner. | 204 // Update the backing's priority from its new owner. |
215 backing->updatePriority(); | 205 backing->updatePriority(); |
216 } | 206 } |
217 | 207 |
218 void CCPrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy evictionPolicy, CCResourceProvider* resourceProvider) | 208 void CCPrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy evictionPolicy, CCResourceProvider* resourceProvider) |
219 { | 209 { |
220 ASSERT(CCProxy::isImplThread()); | 210 ASSERT(CCProxy::isImplThread()); |
221 if (memoryUseBytes() <= limitBytes) | 211 if (memoryUseBytes() <= limitBytes) |
222 return; | 212 return; |
223 | 213 |
224 // Destroy backings until we are below the limit, | 214 // Destroy backings until we are below the limit, |
225 // or until all backings remaining are above the cutoff. | 215 // or until all backings remaining are above the cutoff. |
226 while (memoryUseBytes() > limitBytes && m_backings.size() > 0) { | 216 while (memoryUseBytes() > limitBytes && m_backings.size() > 0) { |
227 CCPrioritizedTexture::Backing* backing = *m_backings.begin(); | 217 CCPrioritizedTexture::Backing* backing = m_backings.front(); |
228 if (evictionPolicy == RespectManagerPriorityCutoff) | 218 if (evictionPolicy == RespectManagerPriorityCutoff) |
229 if (backing->wasAbovePriorityCutoffAtLastPriorityUpdate()) | 219 if (backing->wasAbovePriorityCutoffAtLastPriorityUpdate()) |
230 break; | 220 break; |
231 evictBackingResource(backing, resourceProvider); | 221 evictFirstBackingResource(backing, resourceProvider); |
232 } | 222 } |
233 } | 223 } |
234 | 224 |
235 void CCPrioritizedTextureManager::reduceMemory(CCResourceProvider* resourceProvi der) | 225 void CCPrioritizedTextureManager::reduceMemory(CCResourceProvider* resourceProvi der) |
236 { | 226 { |
237 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 227 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
238 | 228 |
239 evictBackingsToReduceMemory(m_memoryAvailableBytes, RespectManagerPriorityCu toff, resourceProvider); | 229 evictBackingsToReduceMemory(m_memoryAvailableBytes, RespectManagerPriorityCu toff, resourceProvider); |
240 ASSERT(memoryUseBytes() <= maxMemoryLimitBytes()); | 230 ASSERT(memoryUseBytes() <= maxMemoryLimitBytes()); |
241 | 231 |
242 // We currently collect backings from deleted textures for later recycling. | 232 // We currently collect backings from deleted textures for later recycling. |
243 // However, if we do that forever we will always use the max limit even if | 233 // However, if we do that forever we will always use the max limit even if |
244 // we really need very little memory. This should probably be solved by redu cing the | 234 // we really need very little memory. This should probably be solved by redu cing the |
245 // limit externally, but until then this just does some "clean up" of unused | 235 // limit externally, but until then this just does some "clean up" of unused |
246 // backing textures (any more than 10%). | 236 // backing textures (any more than 10%). |
247 size_t wastedMemory = 0; | 237 size_t wastedMemory = 0; |
248 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it) { | 238 for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { |
249 if ((*it)->owner()) | 239 if ((*it)->owner()) |
250 break; | 240 break; |
251 wastedMemory += (*it)->bytes(); | 241 wastedMemory += (*it)->bytes(); |
252 } | 242 } |
253 size_t tenPercentOfMemory = m_memoryAvailableBytes / 10; | 243 size_t tenPercentOfMemory = m_memoryAvailableBytes / 10; |
254 if (wastedMemory > tenPercentOfMemory) | 244 if (wastedMemory > tenPercentOfMemory) |
255 evictBackingsToReduceMemory(memoryUseBytes() - (wastedMemory - tenPercen tOfMemory), RespectManagerPriorityCutoff, resourceProvider); | 245 evictBackingsToReduceMemory(memoryUseBytes() - (wastedMemory - tenPercen tOfMemory), RespectManagerPriorityCutoff, resourceProvider); |
256 | 246 |
257 // Unlink all evicted backings | 247 // Unlink all evicted backings |
258 for (BackingVector::const_iterator it = m_evictedBackings.begin(); it != m_e victedBackings.end(); ++it) { | 248 for (BackingVector::const_iterator it = m_evictedBackings.begin(); it != m_e victedBackings.end(); ++it) { |
259 if ((*it)->owner()) | 249 if ((*it)->owner()) |
260 (*it)->owner()->unlink(); | 250 (*it)->owner()->unlink(); |
261 } | 251 } |
262 | 252 |
263 // And clear the list of evicted backings | 253 // And clear the list of evicted backings |
264 deleteUnlinkedEvictedBackings(); | 254 deleteUnlinkedEvictedBackings(); |
265 } | 255 } |
266 | 256 |
267 void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourcePro vider) | 257 void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourcePro vider) |
268 { | 258 { |
269 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 259 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
270 ASSERT(resourceProvider); | 260 ASSERT(resourceProvider); |
271 evictBackingsToReduceMemory(0, DoNotRespectManagerPriorityCutoff, resourcePr ovider); | 261 evictBackingsToReduceMemory(0, DoNotRespectManagerPriorityCutoff, resourcePr ovider); |
272 } | 262 } |
273 | 263 |
274 void CCPrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, CC ResourceProvider* resourceProvider) | 264 void CCPrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, CC ResourceProvider* resourceProvider) |
275 { | 265 { |
276 ASSERT(CCProxy::isImplThread()); | 266 ASSERT(CCProxy::isImplThread()); |
277 ASSERT(resourceProvider); | 267 ASSERT(resourceProvider); |
268 // If we are in the process of uploading a new frame then the backings at th e very end of | |
269 // the list are not sorted by priority. Sort them before doing the eviction. | |
270 sortBackings(); | |
278 evictBackingsToReduceMemory(limitBytes, DoNotRespectManagerPriorityCutoff, r esourceProvider); | 271 evictBackingsToReduceMemory(limitBytes, DoNotRespectManagerPriorityCutoff, r esourceProvider); |
279 } | 272 } |
280 | 273 |
281 void CCPrioritizedTextureManager::getEvictedBackings(BackingVector& evictedBacki ngs) | 274 void CCPrioritizedTextureManager::getEvictedBackings(BackingVector& evictedBacki ngs) |
282 { | 275 { |
283 ASSERT(CCProxy::isImplThread()); | 276 ASSERT(CCProxy::isImplThread()); |
284 evictedBackings.clear(); | 277 evictedBackings.clear(); |
285 evictedBackings.append(m_evictedBackings); | 278 evictedBackings.append(m_evictedBackings); |
286 } | 279 } |
287 | 280 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 texture->unlink(); | 343 texture->unlink(); |
351 } | 344 } |
352 | 345 |
353 CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz e size, GC3Denum format, CCResourceProvider* resourceProvider) | 346 CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz e size, GC3Denum format, CCResourceProvider* resourceProvider) |
354 { | 347 { |
355 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 348 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
356 ASSERT(resourceProvider); | 349 ASSERT(resourceProvider); |
357 CCResourceProvider::ResourceId resourceId = resourceProvider->createResource (m_pool, size, format, CCResourceProvider::TextureUsageAny); | 350 CCResourceProvider::ResourceId resourceId = resourceProvider->createResource (m_pool, size, format, CCResourceProvider::TextureUsageAny); |
358 CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(r esourceId, resourceProvider, size, format); | 351 CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(r esourceId, resourceProvider, size, format); |
359 m_memoryUseBytes += backing->bytes(); | 352 m_memoryUseBytes += backing->bytes(); |
360 // Put backing texture at the front for eviction, since it isn't in use yet. | 353 m_backings.push_front(backing); |
ccameron
2012/10/17 01:10:52
There was some controversy about doing this "add t
jamesr
2012/10/17 01:31:11
Writing code now because we will need it later isn
ccameron
2012/10/17 02:13:58
Removed.
| |
361 m_backings.insertBefore(m_backings.begin(), backing); | |
362 return backing; | 354 return backing; |
363 } | 355 } |
364 | 356 |
365 void CCPrioritizedTextureManager::evictBackingResource(CCPrioritizedTexture::Bac king* backing, CCResourceProvider* resourceProvider) | 357 void CCPrioritizedTextureManager::evictFirstBackingResource(CCPrioritizedTexture ::Backing* backing, CCResourceProvider* resourceProvider) |
jamesr
2012/10/17 01:31:11
why does this take a backing* if it's only operati
ccameron
2012/10/17 02:13:58
Yeah, this just made me feel warm and fuzzy. Dele
| |
366 { | 358 { |
367 ASSERT(CCProxy::isImplThread()); | 359 ASSERT(CCProxy::isImplThread()); |
368 ASSERT(backing); | 360 ASSERT(backing); |
369 ASSERT(resourceProvider); | 361 ASSERT(resourceProvider); |
370 ASSERT(m_backings.find(backing) != m_backings.end()); | 362 ASSERT(m_backings.front() == backing); |
371 | 363 |
372 // Note that we create a backing and its resource at the same time, but we | 364 // Note that we create a backing and its resource at the same time, but we |
373 // delete the backing structure and its resource in two steps. This is becau se | 365 // delete the backing structure and its resource in two steps. This is becau se |
374 // we can delete the resource while the main thread is running, but we canno t | 366 // we can delete the resource while the main thread is running, but we canno t |
375 // unlink backings while the main thread is running. | 367 // unlink backings while the main thread is running. |
376 backing->deleteResource(resourceProvider); | 368 backing->deleteResource(resourceProvider); |
377 m_memoryUseBytes -= backing->bytes(); | 369 m_memoryUseBytes -= backing->bytes(); |
378 m_backings.remove(backing); | 370 m_backings.pop_front(); |
379 m_evictedBackings.append(backing); | 371 m_evictedBackings.append(backing); |
380 } | 372 } |
381 | 373 |
382 #if !ASSERT_DISABLED | |
383 void CCPrioritizedTextureManager::assertInvariants() | 374 void CCPrioritizedTextureManager::assertInvariants() |
384 { | 375 { |
376 #if !ASSERT_DISABLED | |
385 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 377 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
386 | 378 |
387 // If we hit any of these asserts, there is a bug in this class. To see | 379 // If we hit any of these asserts, there is a bug in this class. To see |
388 // where the bug is, call this function at the beginning and end of | 380 // where the bug is, call this function at the beginning and end of |
389 // every public function. | 381 // every public function. |
390 | 382 |
391 // Backings/textures must be doubly-linked and only to other backings/textur es in this manager. | 383 // Backings/textures must be doubly-linked and only to other backings/textur es in this manager. |
392 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it) { | 384 for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { |
393 if ((*it)->owner()) { | 385 if ((*it)->owner()) { |
394 ASSERT(ContainsKey(m_textures, (*it)->owner())); | 386 ASSERT(ContainsKey(m_textures, (*it)->owner())); |
395 ASSERT((*it)->owner()->backing() == (*it)); | 387 ASSERT((*it)->owner()->backing() == (*it)); |
396 } | 388 } |
397 } | 389 } |
398 for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); + +it) { | 390 for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); + +it) { |
399 CCPrioritizedTexture* texture = (*it); | 391 CCPrioritizedTexture* texture = (*it); |
400 CCPrioritizedTexture::Backing* backing = texture->backing(); | 392 CCPrioritizedTexture::Backing* backing = texture->backing(); |
401 if (backing) { | 393 if (backing) { |
402 if (backing->resourceHasBeenDeleted()) { | 394 if (backing->resourceHasBeenDeleted()) { |
403 ASSERT(m_backings.find(backing) == m_backings.end()); | 395 ASSERT(std::find(m_backings.begin(), m_backings.end(), backing) == m_backings.end()); |
404 ASSERT(m_evictedBackings.contains(backing)); | 396 ASSERT(m_evictedBackings.contains(backing)); |
405 } else { | 397 } else { |
406 ASSERT(m_backings.find(backing) != m_backings.end()); | 398 ASSERT(std::find(m_backings.begin(), m_backings.end(), backing) != m_backings.end()); |
407 ASSERT(!m_evictedBackings.contains(backing)); | 399 ASSERT(!m_evictedBackings.contains(backing)); |
408 } | 400 } |
409 ASSERT(backing->owner() == texture); | 401 ASSERT(backing->owner() == texture); |
410 } | 402 } |
411 } | 403 } |
412 | 404 |
413 // At all times, backings that can be evicted must always come before | 405 // At all times, backings that can be evicted must always come before |
414 // backings that can't be evicted in the backing texture list (otherwise | 406 // backings that can't be evicted in the backing texture list (otherwise |
415 // reduceMemory will not find all textures available for eviction/recycling) . | 407 // reduceMemory will not find all textures available for eviction/recycling) . |
416 bool reachedUnrecyclable = false; | 408 bool reachedUnrecyclable = false; |
417 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it) { | 409 for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { |
418 if (!(*it)->canBeRecycled()) | 410 if (!(*it)->canBeRecycled()) |
419 reachedUnrecyclable = true; | 411 reachedUnrecyclable = true; |
420 if (reachedUnrecyclable) | 412 if (reachedUnrecyclable) |
421 ASSERT(!(*it)->canBeRecycled()); | 413 ASSERT(!(*it)->canBeRecycled()); |
422 else | 414 else |
423 ASSERT((*it)->canBeRecycled()); | 415 ASSERT((*it)->canBeRecycled()); |
424 } | 416 } |
417 #endif | |
425 } | 418 } |
426 #endif | |
427 | |
428 | 419 |
429 } // namespace cc | 420 } // namespace cc |
OLD | NEW |