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" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/logging.h" | |
11 #include "CCPriorityCalculator.h" | 8 #include "CCPriorityCalculator.h" |
12 #include "CCResourceProvider.h" | 9 #include "CCResourceProvider.h" |
13 #include "CCTexture.h" | 10 #include "CCTexture.h" |
14 #include "GraphicsContext3D.h" | |
15 #include "IntRect.h" | 11 #include "IntRect.h" |
16 #include "IntSize.h" | 12 #include "IntSize.h" |
| 13 #include "base/basictypes.h" |
| 14 #include "base/basictypes.h" |
| 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "third_party/khronos/GLES2/gl2.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 class CCPrioritizedTextureManager; | 20 class CCPrioritizedTextureManager; |
21 | 21 |
22 class CCPrioritizedTexture { | 22 class CCPrioritizedTexture { |
23 public: | 23 public: |
24 static scoped_ptr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager, IntSize size, GC3Denum format) | 24 static scoped_ptr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager, IntSize size, GLenum format) |
25 { | 25 { |
26 return make_scoped_ptr(new CCPrioritizedTexture(manager, size, format)); | 26 return make_scoped_ptr(new CCPrioritizedTexture(manager, size, format)); |
27 } | 27 } |
28 static scoped_ptr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager) | 28 static scoped_ptr<CCPrioritizedTexture> create(CCPrioritizedTextureManager*
manager) |
29 { | 29 { |
30 return make_scoped_ptr(new CCPrioritizedTexture(manager, IntSize(), 0)); | 30 return make_scoped_ptr(new CCPrioritizedTexture(manager, IntSize(), 0)); |
31 } | 31 } |
32 ~CCPrioritizedTexture(); | 32 ~CCPrioritizedTexture(); |
33 | 33 |
34 // Texture properties. Changing these causes the backing texture to be lost. | 34 // Texture properties. Changing these causes the backing texture to be lost. |
35 // Setting these to the same value is a no-op. | 35 // Setting these to the same value is a no-op. |
36 void setTextureManager(CCPrioritizedTextureManager*); | 36 void setTextureManager(CCPrioritizedTextureManager*); |
37 CCPrioritizedTextureManager* textureManager() { return m_manager; } | 37 CCPrioritizedTextureManager* textureManager() { return m_manager; } |
38 void setDimensions(IntSize, GC3Denum format); | 38 void setDimensions(IntSize, GLenum format); |
39 GC3Denum format() const { return m_format; } | 39 GLenum format() const { return m_format; } |
40 IntSize size() const { return m_size; } | 40 IntSize size() const { return m_size; } |
41 size_t bytes() const { return m_bytes; } | 41 size_t bytes() const { return m_bytes; } |
42 | 42 |
43 // Set priority for the requested texture. | 43 // Set priority for the requested texture. |
44 void setRequestPriority(int priority) { m_priority = priority; } | 44 void setRequestPriority(int priority) { m_priority = priority; } |
45 int requestPriority() const { return m_priority; } | 45 int requestPriority() const { return m_priority; } |
46 | 46 |
47 // After CCPrioritizedTexture::prioritizeTextures() is called, this returns | 47 // After CCPrioritizedTexture::prioritizeTextures() is called, this returns |
48 // if the the request succeeded and this texture can be acquired for use. | 48 // if the the request succeeded and this texture can be acquired for use. |
49 bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; } | 49 bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged;
} | 81 void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged;
} |
82 bool isSelfManaged() { return m_isSelfManaged; } | 82 bool isSelfManaged() { return m_isSelfManaged; } |
83 void setToSelfManagedMemoryPlaceholder(size_t bytes); | 83 void setToSelfManagedMemoryPlaceholder(size_t bytes); |
84 | 84 |
85 private: | 85 private: |
86 friend class CCPrioritizedTextureManager; | 86 friend class CCPrioritizedTextureManager; |
87 friend class CCPrioritizedTextureTest; | 87 friend class CCPrioritizedTextureTest; |
88 | 88 |
89 class Backing : public CCTexture { | 89 class Backing : public CCTexture { |
90 public: | 90 public: |
91 Backing(unsigned id, CCResourceProvider*, IntSize, GC3Denum format); | 91 Backing(unsigned id, CCResourceProvider*, IntSize, GLenum format); |
92 ~Backing(); | 92 ~Backing(); |
93 void updatePriority(); | 93 void updatePriority(); |
94 void updateInDrawingImplTree(); | 94 void updateInDrawingImplTree(); |
95 | 95 |
96 CCPrioritizedTexture* owner() { return m_owner; } | 96 CCPrioritizedTexture* owner() { return m_owner; } |
97 bool canBeRecycled() const; | 97 bool canBeRecycled() const; |
98 int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLas
tPriorityUpdate; } | 98 int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLas
tPriorityUpdate; } |
99 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb
ovePriorityCutoffAtLastPriorityUpdate; } | 99 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb
ovePriorityCutoffAtLastPriorityUpdate; } |
100 bool inDrawingImplTree() const { return m_inDrawingImplTree; } | 100 bool inDrawingImplTree() const { return m_inDrawingImplTree; } |
101 | 101 |
(...skipping 10 matching lines...) Expand all Loading... |
112 bool m_inDrawingImplTree; | 112 bool m_inDrawingImplTree; |
113 | 113 |
114 bool m_resourceHasBeenDeleted; | 114 bool m_resourceHasBeenDeleted; |
115 #ifndef NDEBUG | 115 #ifndef NDEBUG |
116 CCResourceProvider* m_resourceProvider; | 116 CCResourceProvider* m_resourceProvider; |
117 #endif | 117 #endif |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(Backing); | 119 DISALLOW_COPY_AND_ASSIGN(Backing); |
120 }; | 120 }; |
121 | 121 |
122 CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GC3Denum format)
; | 122 CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GLenum format); |
123 | 123 |
124 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } | 124 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } |
125 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC
utoff = isAbovePriorityCutoff; } | 125 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC
utoff = isAbovePriorityCutoff; } |
126 void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager =
manager; } | 126 void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager =
manager; } |
127 | 127 |
128 Backing* backing() const { return m_backing; } | 128 Backing* backing() const { return m_backing; } |
129 void link(Backing*); | 129 void link(Backing*); |
130 void unlink(); | 130 void unlink(); |
131 | 131 |
132 IntSize m_size; | 132 IntSize m_size; |
133 GC3Denum m_format; | 133 GLenum m_format; |
134 size_t m_bytes; | 134 size_t m_bytes; |
135 | 135 |
136 int m_priority; | 136 int m_priority; |
137 bool m_isAbovePriorityCutoff; | 137 bool m_isAbovePriorityCutoff; |
138 bool m_isSelfManaged; | 138 bool m_isSelfManaged; |
139 | 139 |
140 Backing* m_backing; | 140 Backing* m_backing; |
141 CCPrioritizedTextureManager* m_manager; | 141 CCPrioritizedTextureManager* m_manager; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTexture); | 143 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTexture); |
144 }; | 144 }; |
145 | 145 |
146 } // namespace cc | 146 } // namespace cc |
147 | 147 |
148 #endif | 148 #endif |
OLD | NEW |