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 "CCPrioritizedTexture.h" | 9 #include "CCPrioritizedTexture.h" |
10 #include "CCPriorityCalculator.h" | 10 #include "CCPriorityCalculator.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 evictBackingsToReduceMemory(0, DoNotRespectManagerPriorityCutoff, resourcePr
ovider); | 258 evictBackingsToReduceMemory(0, DoNotRespectManagerPriorityCutoff, resourcePr
ovider); |
259 deleteEvictedBackings(); | 259 deleteEvictedBackings(); |
260 } | 260 } |
261 | 261 |
262 void CCPrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, CC
ResourceProvider* resourceProvider) | 262 void CCPrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, CC
ResourceProvider* resourceProvider) |
263 { | 263 { |
264 ASSERT(CCProxy::isImplThread()); | 264 ASSERT(CCProxy::isImplThread()); |
265 ASSERT(resourceProvider); | 265 ASSERT(resourceProvider); |
266 | 266 |
267 evictBackingsToReduceMemory(limitBytes, DoNotRespectManagerPriorityCutoff, r
esourceProvider); | 267 evictBackingsToReduceMemory(limitBytes, DoNotRespectManagerPriorityCutoff, r
esourceProvider); |
268 | |
269 // Deleting just some (not all) resources is not supported yet because we do
not clear | |
270 // only the deleted resources from the texture upload queues (rather, we cle
ar all uploads). | |
271 // Make sure that if we evict all resources. | |
272 ASSERT(m_backings.isEmpty()); | |
273 } | 268 } |
274 | 269 |
275 void CCPrioritizedTextureManager::getEvictedBackings(BackingVector& evictedBacki
ngs) | 270 void CCPrioritizedTextureManager::getEvictedBackings(BackingVector& evictedBacki
ngs) |
276 { | 271 { |
277 ASSERT(CCProxy::isImplThread()); | 272 ASSERT(CCProxy::isImplThread()); |
278 evictedBackings.clear(); | 273 evictedBackings.clear(); |
279 evictedBackings.append(m_evictedBackings); | 274 evictedBackings.append(m_evictedBackings); |
280 } | 275 } |
281 | 276 |
282 void CCPrioritizedTextureManager::unlinkEvictedBackings(const BackingVector& evi
ctedBackings) | 277 void CCPrioritizedTextureManager::unlinkEvictedBackings(const BackingVector& evi
ctedBackings) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 texture->unlink(); | 332 texture->unlink(); |
338 m_needsUpdateBackingsPrioritites = true; | 333 m_needsUpdateBackingsPrioritites = true; |
339 } | 334 } |
340 } | 335 } |
341 | 336 |
342 CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz
e size, GC3Denum format, CCResourceProvider* resourceProvider) | 337 CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz
e size, GC3Denum format, CCResourceProvider* resourceProvider) |
343 { | 338 { |
344 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 339 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
345 ASSERT(resourceProvider); | 340 ASSERT(resourceProvider); |
346 CCResourceProvider::ResourceId resourceId = resourceProvider->createResource
(m_pool, size, format, CCResourceProvider::TextureUsageAny); | 341 CCResourceProvider::ResourceId resourceId = resourceProvider->createResource
(m_pool, size, format, CCResourceProvider::TextureUsageAny); |
347 CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(r
esourceId, size, format); | 342 CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(r
esourceId, resourceProvider, size, format); |
348 m_memoryUseBytes += backing->bytes(); | 343 m_memoryUseBytes += backing->bytes(); |
349 // Put backing texture at the front for eviction, since it isn't in use yet. | 344 // Put backing texture at the front for eviction, since it isn't in use yet. |
350 m_backings.insertBefore(m_backings.begin(), backing); | 345 m_backings.insertBefore(m_backings.begin(), backing); |
351 return backing; | 346 return backing; |
352 } | 347 } |
353 | 348 |
354 void CCPrioritizedTextureManager::evictBackingResource(CCPrioritizedTexture::Bac
king* backing, CCResourceProvider* resourceProvider) | 349 void CCPrioritizedTextureManager::evictBackingResource(CCPrioritizedTexture::Bac
king* backing, CCResourceProvider* resourceProvider) |
355 { | 350 { |
356 ASSERT(CCProxy::isImplThread()); | 351 ASSERT(CCProxy::isImplThread()); |
357 ASSERT(backing); | 352 ASSERT(backing); |
358 ASSERT(resourceProvider); | 353 ASSERT(resourceProvider); |
359 ASSERT(m_backings.find(backing) != m_backings.end()); | 354 ASSERT(m_backings.find(backing) != m_backings.end()); |
360 | 355 |
361 resourceProvider->deleteResource(backing->id()); | 356 backing->deleteResource(resourceProvider); |
362 backing->setId(0); | |
363 m_memoryUseBytes -= backing->bytes(); | 357 m_memoryUseBytes -= backing->bytes(); |
364 m_backings.remove(backing); | 358 m_backings.remove(backing); |
365 m_evictedBackings.append(backing); | 359 m_evictedBackings.append(backing); |
366 } | 360 } |
367 | 361 |
368 #if !ASSERT_DISABLED | 362 #if !ASSERT_DISABLED |
369 void CCPrioritizedTextureManager::assertInvariants() | 363 void CCPrioritizedTextureManager::assertInvariants() |
370 { | 364 { |
371 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 365 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
372 | 366 |
(...skipping 30 matching lines...) Expand all Loading... |
403 if (reachedAboveCutoff) { | 397 if (reachedAboveCutoff) { |
404 ASSERT((*it)->hadOwnerAtLastPriorityUpdate() && (*it)->wasAbovePrior
ityCutoffAtLastPriorityUpdate()); | 398 ASSERT((*it)->hadOwnerAtLastPriorityUpdate() && (*it)->wasAbovePrior
ityCutoffAtLastPriorityUpdate()); |
405 ASSERT(reachedOwned); | 399 ASSERT(reachedOwned); |
406 } | 400 } |
407 } | 401 } |
408 } | 402 } |
409 #endif | 403 #endif |
410 | 404 |
411 | 405 |
412 } // namespace cc | 406 } // namespace cc |
OLD | NEW |