| 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 "CCPrioritizedTexture.h" | 9 #include "CCPrioritizedTexture.h" |
| 10 #include "CCPriorityCalculator.h" | 10 #include "CCPriorityCalculator.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 void reduceMemory(CCResourceProvider*); | 70 void reduceMemory(CCResourceProvider*); |
| 71 void clearAllMemory(CCResourceProvider*); | 71 void clearAllMemory(CCResourceProvider*); |
| 72 | 72 |
| 73 void acquireBackingTextureIfNeeded(CCPrioritizedTexture*, CCResourceProvider
*); | 73 void acquireBackingTextureIfNeeded(CCPrioritizedTexture*, CCResourceProvider
*); |
| 74 | 74 |
| 75 void registerTexture(CCPrioritizedTexture*); | 75 void registerTexture(CCPrioritizedTexture*); |
| 76 void unregisterTexture(CCPrioritizedTexture*); | 76 void unregisterTexture(CCPrioritizedTexture*); |
| 77 void returnBackingTexture(CCPrioritizedTexture*); | 77 void returnBackingTexture(CCPrioritizedTexture*); |
| 78 | 78 |
| 79 void updateBackingsPriorities(); |
| 80 |
| 79 private: | 81 private: |
| 80 friend class CCPrioritizedTextureTest; | 82 friend class CCPrioritizedTextureTest; |
| 81 | 83 |
| 82 enum EvictionPriorityPolicy { | 84 enum EvictionPriorityPolicy { |
| 83 RespectManagerPriorityCutoff, | 85 RespectManagerPriorityCutoff, |
| 84 DoNotRespectManagerPriorityCutoff, | 86 DoNotRespectManagerPriorityCutoff, |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 // Compare textures. Highest priority first. | 89 // Compare textures. Highest priority first. |
| 88 static inline bool compareTextures(CCPrioritizedTexture* a, CCPrioritizedTex
ture* b) | 90 static inline bool compareTextures(CCPrioritizedTexture* a, CCPrioritizedTex
ture* b) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 102 bool aboveCutoffB = b->wasAbovePriorityCutoffAtLastPriorityUpdate(); | 104 bool aboveCutoffB = b->wasAbovePriorityCutoffAtLastPriorityUpdate(); |
| 103 if (!aboveCutoffA && aboveCutoffB) | 105 if (!aboveCutoffA && aboveCutoffB) |
| 104 return true; | 106 return true; |
| 105 if (aboveCutoffA && !aboveCutoffB) | 107 if (aboveCutoffA && !aboveCutoffB) |
| 106 return false; | 108 return false; |
| 107 return a < b; | 109 return a < b; |
| 108 } | 110 } |
| 109 | 111 |
| 110 CCPrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize,
int pool); | 112 CCPrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize,
int pool); |
| 111 | 113 |
| 112 void updateBackingsPriorities(); | |
| 113 void evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy,
CCResourceProvider*); | 114 void evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy,
CCResourceProvider*); |
| 114 CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, CCRes
ourceProvider*); | 115 CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, CCRes
ourceProvider*); |
| 115 void evictBackingResource(CCPrioritizedTexture::Backing*, CCResourceProvider
*); | 116 void evictBackingResource(CCPrioritizedTexture::Backing*, CCResourceProvider
*); |
| 116 | 117 |
| 117 #if !ASSERT_DISABLED | 118 #if !ASSERT_DISABLED |
| 118 void assertInvariants(); | 119 void assertInvariants(); |
| 119 #endif | 120 #endif |
| 120 | 121 |
| 121 size_t m_maxMemoryLimitBytes; | 122 size_t m_maxMemoryLimitBytes; |
| 122 unsigned m_priorityCutoff; | 123 unsigned m_priorityCutoff; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 139 // Set by the main thread when it adjust priorities in such a way that | 140 // Set by the main thread when it adjust priorities in such a way that |
| 140 // the m_backings array's view of priorities is now out of date. | 141 // the m_backings array's view of priorities is now out of date. |
| 141 bool m_needsUpdateBackingsPrioritites; | 142 bool m_needsUpdateBackingsPrioritites; |
| 142 | 143 |
| 143 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTextureManager); | 144 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTextureManager); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 } // namespace cc | 147 } // namespace cc |
| 147 | 148 |
| 148 #endif | 149 #endif |
| OLD | NEW |