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 "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "CCPrioritizedTexture.h" | 11 #include "CCPrioritizedTexture.h" |
12 #include "CCPriorityCalculator.h" | 12 #include "CCPriorityCalculator.h" |
13 #include "CCTexture.h" | 13 #include "CCTexture.h" |
14 #include "GraphicsContext3D.h" | |
15 #include "IntRect.h" | 14 #include "IntRect.h" |
16 #include "IntSize.h" | 15 #include "IntSize.h" |
17 #include <wtf/ListHashSet.h> | 16 #include <wtf/ListHashSet.h> |
18 #include <wtf/Vector.h> | 17 #include <wtf/Vector.h> |
19 | 18 |
20 #if defined(COMPILER_GCC) | 19 #if defined(COMPILER_GCC) |
21 namespace BASE_HASH_NAMESPACE { | 20 namespace BASE_HASH_NAMESPACE { |
22 template<> | 21 template<> |
23 struct hash<cc::CCPrioritizedTexture*> { | 22 struct hash<cc::CCPrioritizedTexture*> { |
24 size_t operator()(cc::CCPrioritizedTexture* ptr) const { | 23 size_t operator()(cc::CCPrioritizedTexture* ptr) const { |
25 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | 24 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
26 } | 25 } |
27 }; | 26 }; |
28 } // namespace BASE_HASH_NAMESPACE | 27 } // namespace BASE_HASH_NAMESPACE |
29 #endif // COMPILER | 28 #endif // COMPILER |
30 | 29 |
31 namespace cc { | 30 namespace cc { |
32 | 31 |
33 class CCPriorityCalculator; | 32 class CCPriorityCalculator; |
34 | 33 |
35 class CCPrioritizedTextureManager { | 34 class CCPrioritizedTextureManager { |
36 public: | 35 public: |
37 static scoped_ptr<CCPrioritizedTextureManager> create(size_t maxMemoryLimitB
ytes, int maxTextureSize, int pool) | 36 static scoped_ptr<CCPrioritizedTextureManager> create(size_t maxMemoryLimitB
ytes, int maxTextureSize, int pool) |
38 { | 37 { |
39 return make_scoped_ptr(new CCPrioritizedTextureManager(maxMemoryLimitByt
es, maxTextureSize, pool)); | 38 return make_scoped_ptr(new CCPrioritizedTextureManager(maxMemoryLimitByt
es, maxTextureSize, pool)); |
40 } | 39 } |
41 scoped_ptr<CCPrioritizedTexture> createTexture(IntSize size, GC3Denum format
) | 40 scoped_ptr<CCPrioritizedTexture> createTexture(IntSize size, GLenum format) |
42 { | 41 { |
43 return make_scoped_ptr(new CCPrioritizedTexture(this, size, format)); | 42 return make_scoped_ptr(new CCPrioritizedTexture(this, size, format)); |
44 } | 43 } |
45 ~CCPrioritizedTextureManager(); | 44 ~CCPrioritizedTextureManager(); |
46 | 45 |
47 typedef Vector<CCPrioritizedTexture::Backing*> BackingVector; | 46 typedef Vector<CCPrioritizedTexture::Backing*> BackingVector; |
48 | 47 |
49 // FIXME (http://crbug.com/137094): This 64MB default is a straggler from th
e | 48 // FIXME (http://crbug.com/137094): This 64MB default is a straggler from th
e |
50 // old texture manager and is just to give us a default memory allocation be
fore | 49 // old texture manager and is just to give us a default memory allocation be
fore |
51 // we get a callback from the GPU memory manager. We should probaby either: | 50 // we get a callback from the GPU memory manager. We should probaby either: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return CCPriorityCalculator::priorityIsLower(a->requestPriorityAtLas
tPriorityUpdate(), b->requestPriorityAtLastPriorityUpdate()); | 127 return CCPriorityCalculator::priorityIsLower(a->requestPriorityAtLas
tPriorityUpdate(), b->requestPriorityAtLastPriorityUpdate()); |
129 // Finally sort by being in the impl tree versus being completely unrefe
renced | 128 // Finally sort by being in the impl tree versus being completely unrefe
renced |
130 if (a->inDrawingImplTree() != b->inDrawingImplTree()) | 129 if (a->inDrawingImplTree() != b->inDrawingImplTree()) |
131 return (a->inDrawingImplTree() < b->inDrawingImplTree()); | 130 return (a->inDrawingImplTree() < b->inDrawingImplTree()); |
132 return a < b; | 131 return a < b; |
133 } | 132 } |
134 | 133 |
135 CCPrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize,
int pool); | 134 CCPrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize,
int pool); |
136 | 135 |
137 void evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy,
CCResourceProvider*); | 136 void evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy,
CCResourceProvider*); |
138 CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, CCRes
ourceProvider*); | 137 CCPrioritizedTexture::Backing* createBacking(IntSize, GLenum format, CCResou
rceProvider*); |
139 void evictBackingResource(CCPrioritizedTexture::Backing*, CCResourceProvider
*); | 138 void evictBackingResource(CCPrioritizedTexture::Backing*, CCResourceProvider
*); |
140 void deleteUnlinkedEvictedBackings(); | 139 void deleteUnlinkedEvictedBackings(); |
141 void sortBackings(); | 140 void sortBackings(); |
142 | 141 |
143 #if !ASSERT_DISABLED | 142 #if !ASSERT_DISABLED |
144 void assertInvariants(); | 143 void assertInvariants(); |
145 #endif | 144 #endif |
146 | 145 |
147 size_t m_maxMemoryLimitBytes; | 146 size_t m_maxMemoryLimitBytes; |
148 unsigned m_priorityCutoff; | 147 unsigned m_priorityCutoff; |
(...skipping 12 matching lines...) Expand all Loading... |
161 | 160 |
162 TextureVector m_tempTextureVector; | 161 TextureVector m_tempTextureVector; |
163 BackingVector m_tempBackingVector; | 162 BackingVector m_tempBackingVector; |
164 | 163 |
165 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTextureManager); | 164 DISALLOW_COPY_AND_ASSIGN(CCPrioritizedTextureManager); |
166 }; | 165 }; |
167 | 166 |
168 } // namespace cc | 167 } // namespace cc |
169 | 168 |
170 #endif | 169 #endif |
OLD | NEW |