| 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_PRIORITIZED_RESOURCE_MANAGER_H_ | 5 #ifndef CC_PRIORITIZED_RESOURCE_MANAGER_H_ |
| 6 #define CC_PRIORITIZED_RESOURCE_MANAGER_H_ | 6 #define CC_PRIORITIZED_RESOURCE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } // namespace BASE_HASH_NAMESPACE | 31 } // namespace BASE_HASH_NAMESPACE |
| 32 #endif // COMPILER | 32 #endif // COMPILER |
| 33 | 33 |
| 34 namespace cc { | 34 namespace cc { |
| 35 | 35 |
| 36 class PriorityCalculator; | 36 class PriorityCalculator; |
| 37 class Proxy; | 37 class Proxy; |
| 38 | 38 |
| 39 class CC_EXPORT PrioritizedResourceManager { | 39 class CC_EXPORT PrioritizedResourceManager { |
| 40 public: | 40 public: |
| 41 static scoped_ptr<PrioritizedResourceManager> create(int pool, const Proxy*
proxy) | 41 static scoped_ptr<PrioritizedResourceManager> create(const Proxy* proxy) |
| 42 { | 42 { |
| 43 return make_scoped_ptr(new PrioritizedResourceManager(pool, proxy)); | 43 return make_scoped_ptr(new PrioritizedResourceManager(proxy)); |
| 44 } | 44 } |
| 45 scoped_ptr<PrioritizedResource> createTexture(gfx::Size size, GLenum format) | 45 scoped_ptr<PrioritizedResource> createTexture(gfx::Size size, GLenum format) |
| 46 { | 46 { |
| 47 return make_scoped_ptr(new PrioritizedResource(this, size, format)); | 47 return make_scoped_ptr(new PrioritizedResource(this, size, format)); |
| 48 } | 48 } |
| 49 ~PrioritizedResourceManager(); | 49 ~PrioritizedResourceManager(); |
| 50 | 50 |
| 51 typedef std::list<PrioritizedResource::Backing*> BackingList; | 51 typedef std::list<PrioritizedResource::Backing*> BackingList; |
| 52 | 52 |
| 53 // FIXME (http://crbug.com/137094): This 64MB default is a straggler from th
e | 53 // FIXME (http://crbug.com/137094): This 64MB default is a straggler from th
e |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Then sort by priority (note that backings that no longer have owners
will | 145 // Then sort by priority (note that backings that no longer have owners
will |
| 146 // always have the lowest priority) | 146 // always have the lowest priority) |
| 147 if (a->requestPriorityAtLastPriorityUpdate() != b->requestPriorityAtLast
PriorityUpdate()) | 147 if (a->requestPriorityAtLastPriorityUpdate() != b->requestPriorityAtLast
PriorityUpdate()) |
| 148 return PriorityCalculator::priorityIsLower(a->requestPriorityAtLastP
riorityUpdate(), b->requestPriorityAtLastPriorityUpdate()); | 148 return PriorityCalculator::priorityIsLower(a->requestPriorityAtLastP
riorityUpdate(), b->requestPriorityAtLastPriorityUpdate()); |
| 149 // Finally sort by being in the impl tree versus being completely unrefe
renced | 149 // Finally sort by being in the impl tree versus being completely unrefe
renced |
| 150 if (a->inDrawingImplTree() != b->inDrawingImplTree()) | 150 if (a->inDrawingImplTree() != b->inDrawingImplTree()) |
| 151 return (a->inDrawingImplTree() < b->inDrawingImplTree()); | 151 return (a->inDrawingImplTree() < b->inDrawingImplTree()); |
| 152 return a < b; | 152 return a < b; |
| 153 } | 153 } |
| 154 | 154 |
| 155 PrioritizedResourceManager(int pool, const Proxy* proxy); | 155 PrioritizedResourceManager(const Proxy* proxy); |
| 156 | 156 |
| 157 bool evictBackingsToReduceMemory(size_t limitBytes, | 157 bool evictBackingsToReduceMemory(size_t limitBytes, |
| 158 int priorityCutoff, | 158 int priorityCutoff, |
| 159 EvictionPolicy, | 159 EvictionPolicy, |
| 160 UnlinkPolicy, | 160 UnlinkPolicy, |
| 161 ResourceProvider*); | 161 ResourceProvider*); |
| 162 PrioritizedResource::Backing* createBacking(gfx::Size, GLenum format, Resour
ceProvider*); | 162 PrioritizedResource::Backing* createBacking(gfx::Size, GLenum format, Resour
ceProvider*); |
| 163 void evictFirstBackingResource(ResourceProvider*); | 163 void evictFirstBackingResource(ResourceProvider*); |
| 164 void sortBackings(); | 164 void sortBackings(); |
| 165 | 165 |
| 166 void assertInvariants(); | 166 void assertInvariants(); |
| 167 | 167 |
| 168 size_t m_maxMemoryLimitBytes; | 168 size_t m_maxMemoryLimitBytes; |
| 169 // The priority cutoff based on memory pressure. This is not a strict | 169 // The priority cutoff based on memory pressure. This is not a strict |
| 170 // cutoff -- requestLate allows textures with priority equal to this | 170 // cutoff -- requestLate allows textures with priority equal to this |
| 171 // cutoff to be allowed. | 171 // cutoff to be allowed. |
| 172 int m_priorityCutoff; | 172 int m_priorityCutoff; |
| 173 // The priority cutoff based on external memory policy. This is a strict | 173 // The priority cutoff based on external memory policy. This is a strict |
| 174 // cutoff -- no textures with priority equal to this cutoff will be allowed. | 174 // cutoff -- no textures with priority equal to this cutoff will be allowed. |
| 175 int m_externalPriorityCutoff; | 175 int m_externalPriorityCutoff; |
| 176 size_t m_memoryUseBytes; | 176 size_t m_memoryUseBytes; |
| 177 size_t m_memoryAboveCutoffBytes; | 177 size_t m_memoryAboveCutoffBytes; |
| 178 size_t m_memoryAvailableBytes; | 178 size_t m_memoryAvailableBytes; |
| 179 int m_pool; | |
| 180 | 179 |
| 181 typedef base::hash_set<PrioritizedResource*> TextureSet; | 180 typedef base::hash_set<PrioritizedResource*> TextureSet; |
| 182 typedef std::vector<PrioritizedResource*> TextureVector; | 181 typedef std::vector<PrioritizedResource*> TextureVector; |
| 183 | 182 |
| 184 const Proxy* m_proxy; | 183 const Proxy* m_proxy; |
| 185 | 184 |
| 186 TextureSet m_textures; | 185 TextureSet m_textures; |
| 187 // This list is always sorted in eviction order, with the exception the | 186 // This list is always sorted in eviction order, with the exception the |
| 188 // newly-allocated or recycled textures at the very end of the tail that | 187 // newly-allocated or recycled textures at the very end of the tail that |
| 189 // are not sorted by priority. | 188 // are not sorted by priority. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 205 // Statistics copied at the time of pushTexturePrioritiesToBackings. | 204 // Statistics copied at the time of pushTexturePrioritiesToBackings. |
| 206 size_t m_memoryVisibleLastPushedBytes; | 205 size_t m_memoryVisibleLastPushedBytes; |
| 207 size_t m_memoryVisibleAndNearbyLastPushedBytes; | 206 size_t m_memoryVisibleAndNearbyLastPushedBytes; |
| 208 | 207 |
| 209 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager); | 208 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager); |
| 210 }; | 209 }; |
| 211 | 210 |
| 212 } // namespace cc | 211 } // namespace cc |
| 213 | 212 |
| 214 #endif // CC_PRIORITIZED_RESOURCE_MANAGER_H_ | 213 #endif // CC_PRIORITIZED_RESOURCE_MANAGER_H_ |
| OLD | NEW |