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 CCPrioritizedTexture_h | 5 #ifndef CCPrioritizedTexture_h |
| 6 #define CCPrioritizedTexture_h | 6 #define CCPrioritizedTexture_h |
| 7 | 7 |
| 8 #include "CCPriorityCalculator.h" | 8 #include "CCPriorityCalculator.h" |
| 9 #include "CCResourceProvider.h" | 9 #include "CCResourceProvider.h" |
| 10 #include "CCTexture.h" | 10 #include "CCTexture.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 // After CCPrioritizedTexture::prioritizeTextures() is called, this returns | 45 // After CCPrioritizedTexture::prioritizeTextures() is called, this returns |
| 46 // if the the request succeeded and this texture can be acquired for use. | 46 // if the the request succeeded and this texture can be acquired for use. |
| 47 bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; } | 47 bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; } |
| 48 | 48 |
| 49 // This returns whether we still have a backing texture. This can continue | 49 // This returns whether we still have a backing texture. This can continue |
| 50 // to be true even after canAcquireBackingTexture() becomes false. In this | 50 // to be true even after canAcquireBackingTexture() becomes false. In this |
| 51 // case the texture can be used but shouldn't be updated since it will get | 51 // case the texture can be used but shouldn't be updated since it will get |
| 52 // taken away "soon". | 52 // taken away "soon". |
| 53 bool haveBackingTexture() const { return !!backing(); } | 53 bool haveBackingTexture() const { return !!backing(); } |
| 54 | 54 |
| 55 bool backingResourceWasEvicted() const { return m_backing ? m_backing->resou rceHasBeenDeleted() : false; } | |
|
jamesr
2012/09/19 18:56:37
a ternary is about the place where I'd prefer putt
ccameron
2012/09/19 20:52:02
Fixed
| |
| 56 | |
| 55 // If canAcquireBackingTexture() is true acquireBackingTexture() will acquir e | 57 // If canAcquireBackingTexture() is true acquireBackingTexture() will acquir e |
| 56 // a backing texture for use. Call this whenever the texture is actually nee ded. | 58 // a backing texture for use. Call this whenever the texture is actually nee ded. |
| 57 void acquireBackingTexture(CCResourceProvider*); | 59 void acquireBackingTexture(CCResourceProvider*); |
| 58 | 60 |
| 59 // FIXME: Request late is really a hack for when we are totally out of memor y | 61 // FIXME: Request late is really a hack for when we are totally out of memor y |
| 60 // (all textures are visible) but we can still squeeze into the limit | 62 // (all textures are visible) but we can still squeeze into the limit |
| 61 // by not painting occluded textures. In this case the manager | 63 // by not painting occluded textures. In this case the manager |
| 62 // refuses all visible textures and requestLate() will enable | 64 // refuses all visible textures and requestLate() will enable |
| 63 // canAcquireBackingTexture() on a call-order basis. We might want to | 65 // canAcquireBackingTexture() on a call-order basis. We might want to |
| 64 // just remove this in the future (carefully) and just make sure we d on't | 66 // just remove this in the future (carefully) and just make sure we d on't |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 87 public: | 89 public: |
| 88 Backing(unsigned id, IntSize, GC3Denum format); | 90 Backing(unsigned id, IntSize, GC3Denum format); |
| 89 ~Backing(); | 91 ~Backing(); |
| 90 void updatePriority(); | 92 void updatePriority(); |
| 91 | 93 |
| 92 CCPrioritizedTexture* owner() { return m_owner; } | 94 CCPrioritizedTexture* owner() { return m_owner; } |
| 93 bool hadOwnerAtLastPriorityUpdate() const { return m_ownerExistedAtLastP riorityUpdate; } | 95 bool hadOwnerAtLastPriorityUpdate() const { return m_ownerExistedAtLastP riorityUpdate; } |
| 94 bool requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLa stPriorityUpdate; } | 96 bool requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLa stPriorityUpdate; } |
| 95 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb ovePriorityCutoffAtLastPriorityUpdate; } | 97 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb ovePriorityCutoffAtLastPriorityUpdate; } |
| 96 | 98 |
| 99 void deleteResource(CCResourceProvider*); | |
| 100 bool resourceHasBeenDeleted() const; | |
| 101 | |
| 97 private: | 102 private: |
| 98 friend class CCPrioritizedTexture; | 103 friend class CCPrioritizedTexture; |
| 99 CCPrioritizedTexture* m_owner; | 104 CCPrioritizedTexture* m_owner; |
| 100 int m_priorityAtLastPriorityUpdate; | 105 int m_priorityAtLastPriorityUpdate; |
| 101 bool m_ownerExistedAtLastPriorityUpdate; | 106 bool m_ownerExistedAtLastPriorityUpdate; |
| 102 bool m_wasAbovePriorityCutoffAtLastPriorityUpdate; | 107 bool m_wasAbovePriorityCutoffAtLastPriorityUpdate; |
| 108 bool m_resourceHasBeenDeleted; | |
| 103 }; | 109 }; |
| 104 | 110 |
| 105 CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GC3Denum format) ; | 111 CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GC3Denum format) ; |
| 106 | 112 |
| 107 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } | 113 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } |
| 108 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC utoff = isAbovePriorityCutoff; } | 114 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC utoff = isAbovePriorityCutoff; } |
| 109 void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager = manager; } | 115 void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager = manager; } |
| 110 | 116 |
| 111 Backing* backing() const { return m_backing; } | 117 Backing* backing() const { return m_backing; } |
| 112 void link(Backing*); | 118 void link(Backing*); |
| 113 void unlink(); | 119 void unlink(); |
| 114 | 120 |
| 115 IntSize m_size; | 121 IntSize m_size; |
| 116 GC3Denum m_format; | 122 GC3Denum m_format; |
| 117 size_t m_bytes; | 123 size_t m_bytes; |
| 118 | 124 |
| 119 int m_priority; | 125 int m_priority; |
| 120 bool m_isAbovePriorityCutoff; | 126 bool m_isAbovePriorityCutoff; |
| 121 bool m_isSelfManaged; | 127 bool m_isSelfManaged; |
| 122 | 128 |
| 123 Backing* m_backing; | 129 Backing* m_backing; |
| 124 CCPrioritizedTextureManager* m_manager; | 130 CCPrioritizedTextureManager* m_manager; |
| 125 }; | 131 }; |
| 126 | 132 |
| 127 } // namespace cc | 133 } // namespace cc |
| 128 | 134 |
| 129 #endif | 135 #endif |
| OLD | NEW |