Chromium Code Reviews| 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 CCPrioritizedTextureManager_h | 5 #ifndef CCPrioritizedTextureManager_h |
| 6 #define CCPrioritizedTextureManager_h | 6 #define CCPrioritizedTextureManager_h |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "CCPrioritizedTexture.h" | 11 #include "CCPrioritizedTexture.h" |
| 12 #include "CCPriorityCalculator.h" | 12 #include "CCPriorityCalculator.h" |
| 13 #include "CCTexture.h" | 13 #include "CCTexture.h" |
| 14 #include "GraphicsContext3D.h" | 14 #include "GraphicsContext3D.h" |
| 15 #include "IntRect.h" | 15 #include "IntRect.h" |
| 16 #include "IntSize.h" | 16 #include "IntSize.h" |
| 17 #include <wtf/ListHashSet.h> | |
| 18 #include <wtf/Vector.h> | 17 #include <wtf/Vector.h> |
| 18 #include <list> | |
| 19 | 19 |
| 20 #if defined(COMPILER_GCC) | 20 #if defined(COMPILER_GCC) |
| 21 namespace BASE_HASH_NAMESPACE { | 21 namespace BASE_HASH_NAMESPACE { |
| 22 template<> | 22 template<> |
| 23 struct hash<cc::CCPrioritizedTexture*> { | 23 struct hash<cc::CCPrioritizedTexture*> { |
| 24 size_t operator()(cc::CCPrioritizedTexture* ptr) const { | 24 size_t operator()(cc::CCPrioritizedTexture* ptr) const { |
| 25 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | 25 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
| 26 } | 26 } |
| 27 }; | 27 }; |
| 28 } // namespace BASE_HASH_NAMESPACE | 28 } // namespace BASE_HASH_NAMESPACE |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 // Finally sort by being in the impl tree versus being completely unrefe renced | 129 // Finally sort by being in the impl tree versus being completely unrefe renced |
| 130 if (a->inDrawingImplTree() != b->inDrawingImplTree()) | 130 if (a->inDrawingImplTree() != b->inDrawingImplTree()) |
| 131 return (a->inDrawingImplTree() < b->inDrawingImplTree()); | 131 return (a->inDrawingImplTree() < b->inDrawingImplTree()); |
| 132 return a < b; | 132 return a < b; |
| 133 } | 133 } |
| 134 | 134 |
| 135 CCPrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, int pool); | 135 CCPrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, int pool); |
| 136 | 136 |
| 137 void evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy, CCResourceProvider*); | 137 void evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy, CCResourceProvider*); |
| 138 CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, CCRes ourceProvider*); | 138 CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, CCRes ourceProvider*); |
| 139 void evictBackingResource(CCPrioritizedTexture::Backing*, CCResourceProvider *); | 139 void evictFirstBackingResource(CCPrioritizedTexture::Backing*, CCResourcePro vider*); |
| 140 void deleteUnlinkedEvictedBackings(); | 140 void deleteUnlinkedEvictedBackings(); |
| 141 void sortBackings(); | 141 void sortBackings(); |
| 142 | 142 |
| 143 #if !ASSERT_DISABLED | |
| 144 void assertInvariants(); | 143 void assertInvariants(); |
| 145 #endif | |
| 146 | 144 |
| 147 size_t m_maxMemoryLimitBytes; | 145 size_t m_maxMemoryLimitBytes; |
| 148 unsigned m_priorityCutoff; | 146 unsigned m_priorityCutoff; |
| 149 size_t m_memoryUseBytes; | 147 size_t m_memoryUseBytes; |
| 150 size_t m_memoryAboveCutoffBytes; | 148 size_t m_memoryAboveCutoffBytes; |
| 151 size_t m_memoryAvailableBytes; | 149 size_t m_memoryAvailableBytes; |
| 152 int m_pool; | 150 int m_pool; |
| 153 | 151 |
| 154 typedef base::hash_set<CCPrioritizedTexture*> TextureSet; | 152 typedef base::hash_set<CCPrioritizedTexture*> TextureSet; |
| 155 typedef ListHashSet<CCPrioritizedTexture::Backing*> BackingSet; | 153 typedef std::list<CCPrioritizedTexture::Backing*> BackingList; |
| 156 typedef Vector<CCPrioritizedTexture*> TextureVector; | 154 typedef Vector<CCPrioritizedTexture*> TextureVector; |
| 157 | 155 |
| 158 TextureSet m_textures; | 156 TextureSet m_textures; |
| 159 BackingSet m_backings; | 157 // This list is always sorted in eviction order, with the exception the |
| 158 // newly-allocated textures at the very end of the tail that are not | |
| 159 // sorted by priority. | |
| 160 BackingList m_backings; | |
| 160 BackingVector m_evictedBackings; | 161 BackingVector m_evictedBackings; |
|
jamesr
2012/10/17 01:31:11
Does the m_evictedBackings need O(1) access or cou
ccameron
2012/10/17 02:13:58
Nah, it can be a list too. Updated.
| |
| 161 | 162 |
| 162 TextureVector m_tempTextureVector; | 163 TextureVector m_tempTextureVector; |
| 163 BackingVector m_tempBackingVector; | |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTextureManager); | 165 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTextureManager); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 } // namespace cc | 168 } // namespace cc |
| 169 | 169 |
| 170 #endif | 170 #endif |
| OLD | NEW |