| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Make sure that the backings list is up to date and sorted before traversi
ng it. | 176 // Make sure that the backings list is up to date and sorted before traversi
ng it. |
| 177 updateBackingsPriorities(); | 177 updateBackingsPriorities(); |
| 178 | 178 |
| 179 // Find a backing below, by either recycling or allocating. | 179 // Find a backing below, by either recycling or allocating. |
| 180 CCPrioritizedTexture::Backing* backing = 0; | 180 CCPrioritizedTexture::Backing* backing = 0; |
| 181 | 181 |
| 182 // First try to recycle | 182 // First try to recycle |
| 183 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); +
+it) { | 183 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); +
+it) { |
| 184 if ((*it)->hadOwnerAtLastPriorityUpdate() && (*it)->wasAbovePriorityCuto
ffAtLastPriorityUpdate()) | 184 if ((*it)->hadOwnerAtLastPriorityUpdate() && (*it)->wasAbovePriorityCuto
ffAtLastPriorityUpdate()) |
| 185 break; | 185 break; |
| 186 if ((*it)->size() == texture->size() && (*it)->format() == texture->form
at()) { | 186 if ((*it)->size() == texture->size() && (*it)->format() == texture->form
at() && !resourceProvider->inUseByConsumer((*it)->id())) { |
| 187 backing = (*it); | 187 backing = (*it); |
| 188 break; | 188 break; |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Otherwise reduce memory and just allocate a new backing texures. | 192 // Otherwise reduce memory and just allocate a new backing texures. |
| 193 if (!backing) { | 193 if (!backing) { |
| 194 evictBackingsToReduceMemory(m_memoryAvailableBytes - texture->bytes(), R
espectManagerPriorityCutoff, resourceProvider); | 194 evictBackingsToReduceMemory(m_memoryAvailableBytes - texture->bytes(), R
espectManagerPriorityCutoff, resourceProvider); |
| 195 backing = createBacking(texture->size(), texture->format(), resourceProv
ider); | 195 backing = createBacking(texture->size(), texture->format(), resourceProv
ider); |
| 196 } | 196 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 if (reachedAboveCutoff) { | 400 if (reachedAboveCutoff) { |
| 401 ASSERT((*it)->hadOwnerAtLastPriorityUpdate() && (*it)->wasAbovePrior
ityCutoffAtLastPriorityUpdate()); | 401 ASSERT((*it)->hadOwnerAtLastPriorityUpdate() && (*it)->wasAbovePrior
ityCutoffAtLastPriorityUpdate()); |
| 402 ASSERT(reachedOwned); | 402 ASSERT(reachedOwned); |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 #endif | 406 #endif |
| 407 | 407 |
| 408 | 408 |
| 409 } // namespace cc | 409 } // namespace cc |
| OLD | NEW |