| 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 "base/basictypes.h" |
| 8 #include "CCPriorityCalculator.h" | 9 #include "CCPriorityCalculator.h" |
| 9 #include "CCResourceProvider.h" | 10 #include "CCResourceProvider.h" |
| 10 #include "CCTexture.h" | 11 #include "CCTexture.h" |
| 11 #include "GraphicsContext3D.h" | 12 #include "GraphicsContext3D.h" |
| 12 #include "IntRect.h" | 13 #include "IntRect.h" |
| 13 #include "IntSize.h" | 14 #include "IntSize.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| 17 class CCPrioritizedTextureManager; | 18 class CCPrioritizedTextureManager; |
| 18 | 19 |
| 19 class CCPrioritizedTexture { | 20 class CCPrioritizedTexture { |
| 20 WTF_MAKE_NONCOPYABLE(CCPrioritizedTexture); | |
| 21 public: | 21 public: |
| 22 static PassOwnPtr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager, IntSize size, GC3Denum format) | 22 static PassOwnPtr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager, IntSize size, GC3Denum format) |
| 23 { | 23 { |
| 24 return adoptPtr(new CCPrioritizedTexture(manager, size, format)); | 24 return adoptPtr(new CCPrioritizedTexture(manager, size, format)); |
| 25 } | 25 } |
| 26 static PassOwnPtr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager) | 26 static PassOwnPtr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager) |
| 27 { | 27 { |
| 28 return adoptPtr(new CCPrioritizedTexture(manager, IntSize(), 0)); | 28 return adoptPtr(new CCPrioritizedTexture(manager, IntSize(), 0)); |
| 29 } | 29 } |
| 30 ~CCPrioritizedTexture(); | 30 ~CCPrioritizedTexture(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // been allowed given its priority. | 78 // been allowed given its priority. |
| 79 void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged;
} | 79 void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged;
} |
| 80 bool isSelfManaged() { return m_isSelfManaged; } | 80 bool isSelfManaged() { return m_isSelfManaged; } |
| 81 void setToSelfManagedMemoryPlaceholder(size_t bytes); | 81 void setToSelfManagedMemoryPlaceholder(size_t bytes); |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 friend class CCPrioritizedTextureManager; | 84 friend class CCPrioritizedTextureManager; |
| 85 friend class CCPrioritizedTextureTest; | 85 friend class CCPrioritizedTextureTest; |
| 86 | 86 |
| 87 class Backing : public CCTexture { | 87 class Backing : public CCTexture { |
| 88 WTF_MAKE_NONCOPYABLE(Backing); | |
| 89 public: | 88 public: |
| 90 Backing(unsigned id, CCResourceProvider*, IntSize, GC3Denum format); | 89 Backing(unsigned id, CCResourceProvider*, IntSize, GC3Denum format); |
| 91 ~Backing(); | 90 ~Backing(); |
| 92 void updatePriority(); | 91 void updatePriority(); |
| 93 | 92 |
| 94 CCPrioritizedTexture* owner() { return m_owner; } | 93 CCPrioritizedTexture* owner() { return m_owner; } |
| 95 bool hadOwnerAtLastPriorityUpdate() const { return m_ownerExistedAtLastP
riorityUpdate; } | 94 bool hadOwnerAtLastPriorityUpdate() const { return m_ownerExistedAtLastP
riorityUpdate; } |
| 96 int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLas
tPriorityUpdate; } | 95 int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLas
tPriorityUpdate; } |
| 97 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb
ovePriorityCutoffAtLastPriorityUpdate; } | 96 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb
ovePriorityCutoffAtLastPriorityUpdate; } |
| 98 | 97 |
| 99 void deleteResource(CCResourceProvider*); | 98 void deleteResource(CCResourceProvider*); |
| 100 bool resourceHasBeenDeleted() const; | 99 bool resourceHasBeenDeleted() const; |
| 101 | 100 |
| 102 private: | 101 private: |
| 103 friend class CCPrioritizedTexture; | 102 friend class CCPrioritizedTexture; |
| 104 CCPrioritizedTexture* m_owner; | 103 CCPrioritizedTexture* m_owner; |
| 105 int m_priorityAtLastPriorityUpdate; | 104 int m_priorityAtLastPriorityUpdate; |
| 106 bool m_ownerExistedAtLastPriorityUpdate; | 105 bool m_ownerExistedAtLastPriorityUpdate; |
| 107 bool m_wasAbovePriorityCutoffAtLastPriorityUpdate; | 106 bool m_wasAbovePriorityCutoffAtLastPriorityUpdate; |
| 108 bool m_resourceHasBeenDeleted; | 107 bool m_resourceHasBeenDeleted; |
| 109 #ifndef NDEBUG | 108 #ifndef NDEBUG |
| 110 CCResourceProvider* m_resourceProvider; | 109 CCResourceProvider* m_resourceProvider; |
| 111 #endif | 110 #endif |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(Backing); |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GC3Denum format)
; | 115 CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GC3Denum format)
; |
| 115 | 116 |
| 116 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } | 117 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } |
| 117 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC
utoff = isAbovePriorityCutoff; } | 118 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC
utoff = isAbovePriorityCutoff; } |
| 118 void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager =
manager; } | 119 void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager =
manager; } |
| 119 | 120 |
| 120 Backing* backing() const { return m_backing; } | 121 Backing* backing() const { return m_backing; } |
| 121 void link(Backing*); | 122 void link(Backing*); |
| 122 void unlink(); | 123 void unlink(); |
| 123 | 124 |
| 124 IntSize m_size; | 125 IntSize m_size; |
| 125 GC3Denum m_format; | 126 GC3Denum m_format; |
| 126 size_t m_bytes; | 127 size_t m_bytes; |
| 127 | 128 |
| 128 int m_priority; | 129 int m_priority; |
| 129 bool m_isAbovePriorityCutoff; | 130 bool m_isAbovePriorityCutoff; |
| 130 bool m_isSelfManaged; | 131 bool m_isSelfManaged; |
| 131 | 132 |
| 132 Backing* m_backing; | 133 Backing* m_backing; |
| 133 CCPrioritizedTextureManager* m_manager; | 134 CCPrioritizedTextureManager* m_manager; |
| 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTexture); |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 } // namespace cc | 139 } // namespace cc |
| 137 | 140 |
| 138 #endif | 141 #endif |
| OLD | NEW |