Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: cc/prioritized_texture_manager.h

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address code review comments and fix all cc_unittests Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
11 #include "IntRect.h" 11 #include "IntRect.h"
12 #include "IntSize.h" 12 #include "IntSize.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/hash_tables.h" 14 #include "base/hash_tables.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "cc/proxy.h"
16 #include "cc/prioritized_texture.h" 17 #include "cc/prioritized_texture.h"
17 #include "cc/priority_calculator.h" 18 #include "cc/priority_calculator.h"
18 #include "cc/texture.h" 19 #include "cc/texture.h"
19 #include "third_party/khronos/GLES2/gl2.h" 20 #include "third_party/khronos/GLES2/gl2.h"
20 21
21 #if defined(COMPILER_GCC) 22 #if defined(COMPILER_GCC)
22 namespace BASE_HASH_NAMESPACE { 23 namespace BASE_HASH_NAMESPACE {
23 template<> 24 template<>
24 struct hash<cc::PrioritizedTexture*> { 25 struct hash<cc::PrioritizedTexture*> {
25 size_t operator()(cc::PrioritizedTexture* ptr) const { 26 size_t operator()(cc::PrioritizedTexture* ptr) const {
26 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); 27 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
27 } 28 }
28 }; 29 };
29 } // namespace BASE_HASH_NAMESPACE 30 } // namespace BASE_HASH_NAMESPACE
30 #endif // COMPILER 31 #endif // COMPILER
31 32
32 namespace cc { 33 namespace cc {
33 34
34 class PriorityCalculator; 35 class PriorityCalculator;
36 class Proxy;
35 37
36 class PrioritizedTextureManager { 38 class PrioritizedTextureManager {
37 public: 39 public:
38 static scoped_ptr<PrioritizedTextureManager> create(size_t maxMemoryLimitByt es, int maxTextureSize, int pool) 40 static scoped_ptr<PrioritizedTextureManager> create(size_t maxMemoryLimitByt es, int maxTextureSize, int pool, const Proxy* proxy)
39 { 41 {
40 return make_scoped_ptr(new PrioritizedTextureManager(maxMemoryLimitBytes , maxTextureSize, pool)); 42 return make_scoped_ptr(new PrioritizedTextureManager(maxMemoryLimitBytes , maxTextureSize, pool, proxy));
41 } 43 }
42 scoped_ptr<PrioritizedTexture> createTexture(IntSize size, GLenum format) 44 scoped_ptr<PrioritizedTexture> createTexture(IntSize size, GLenum format)
43 { 45 {
44 return make_scoped_ptr(new PrioritizedTexture(this, size, format)); 46 return make_scoped_ptr(new PrioritizedTexture(this, size, format));
45 } 47 }
46 ~PrioritizedTextureManager(); 48 ~PrioritizedTextureManager();
47 49
48 typedef std::list<PrioritizedTexture::Backing*> BackingList; 50 typedef std::list<PrioritizedTexture::Backing*> BackingList;
49 51
50 // FIXME (http://crbug.com/137094): This 64MB default is a straggler from th e 52 // FIXME (http://crbug.com/137094): This 64MB default is a straggler from th e
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Then sort by priority (note that backings that no longer have owners will 133 // Then sort by priority (note that backings that no longer have owners will
132 // always have the lowest priority) 134 // always have the lowest priority)
133 if (a->requestPriorityAtLastPriorityUpdate() != b->requestPriorityAtLast PriorityUpdate()) 135 if (a->requestPriorityAtLastPriorityUpdate() != b->requestPriorityAtLast PriorityUpdate())
134 return PriorityCalculator::priorityIsLower(a->requestPriorityAtLastP riorityUpdate(), b->requestPriorityAtLastPriorityUpdate()); 136 return PriorityCalculator::priorityIsLower(a->requestPriorityAtLastP riorityUpdate(), b->requestPriorityAtLastPriorityUpdate());
135 // Finally sort by being in the impl tree versus being completely unrefe renced 137 // Finally sort by being in the impl tree versus being completely unrefe renced
136 if (a->inDrawingImplTree() != b->inDrawingImplTree()) 138 if (a->inDrawingImplTree() != b->inDrawingImplTree())
137 return (a->inDrawingImplTree() < b->inDrawingImplTree()); 139 return (a->inDrawingImplTree() < b->inDrawingImplTree());
138 return a < b; 140 return a < b;
139 } 141 }
140 142
141 PrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, in t pool); 143 PrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, in t pool, const Proxy* proxy);
142 144
143 bool evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, Evic tionPolicy, ResourceProvider*); 145 bool evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, Evic tionPolicy, ResourceProvider*);
144 PrioritizedTexture::Backing* createBacking(IntSize, GLenum format, ResourceP rovider*); 146 PrioritizedTexture::Backing* createBacking(IntSize, GLenum format, ResourceP rovider*);
145 void evictFirstBackingResource(ResourceProvider*); 147 void evictFirstBackingResource(ResourceProvider*);
146 void deleteUnlinkedEvictedBackings(); 148 void deleteUnlinkedEvictedBackings();
147 void sortBackings(); 149 void sortBackings();
148 150
149 void assertInvariants(); 151 void assertInvariants();
150 152
151 size_t m_maxMemoryLimitBytes; 153 size_t m_maxMemoryLimitBytes;
152 // The priority cutoff based on memory pressure. This is not a strict 154 // The priority cutoff based on memory pressure. This is not a strict
153 // cutoff -- requestLate allows textures with priority equal to this 155 // cutoff -- requestLate allows textures with priority equal to this
154 // cutoff to be allowed. 156 // cutoff to be allowed.
155 int m_priorityCutoff; 157 int m_priorityCutoff;
156 // The priority cutoff based on external memory policy. This is a strict 158 // The priority cutoff based on external memory policy. This is a strict
157 // cutoff -- no textures with priority equal to this cutoff will be allowed. 159 // cutoff -- no textures with priority equal to this cutoff will be allowed.
158 int m_externalPriorityCutoff; 160 int m_externalPriorityCutoff;
159 size_t m_memoryUseBytes; 161 size_t m_memoryUseBytes;
160 size_t m_memoryAboveCutoffBytes; 162 size_t m_memoryAboveCutoffBytes;
161 size_t m_memoryAvailableBytes; 163 size_t m_memoryAvailableBytes;
162 int m_pool; 164 int m_pool;
163 165
164 typedef base::hash_set<PrioritizedTexture*> TextureSet; 166 typedef base::hash_set<PrioritizedTexture*> TextureSet;
165 typedef std::vector<PrioritizedTexture*> TextureVector; 167 typedef std::vector<PrioritizedTexture*> TextureVector;
166 168
169 const Proxy* m_proxy;
170
167 TextureSet m_textures; 171 TextureSet m_textures;
168 // This list is always sorted in eviction order, with the exception the 172 // This list is always sorted in eviction order, with the exception the
169 // newly-allocated or recycled textures at the very end of the tail that 173 // newly-allocated or recycled textures at the very end of the tail that
170 // are not sorted by priority. 174 // are not sorted by priority.
171 BackingList m_backings; 175 BackingList m_backings;
172 bool m_backingsTailNotSorted; 176 bool m_backingsTailNotSorted;
173 BackingList m_evictedBackings; 177 BackingList m_evictedBackings;
174 178
175 TextureVector m_tempTextureVector; 179 TextureVector m_tempTextureVector;
176 180
177 DISALLOW_COPY_AND_ASSIGN(PrioritizedTextureManager); 181 DISALLOW_COPY_AND_ASSIGN(PrioritizedTextureManager);
178 }; 182 };
179 183
180 } // namespace cc 184 } // namespace cc
181 185
182 #endif 186 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698