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

Side by Side Diff: cc/prioritized_resource_manager.h

Issue 11411251: Use a lock to deal with concurrent access to the m_evictedBackings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make lock mutable Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/prioritized_resource.cc ('k') | cc/prioritized_resource_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CC_PRIORITIZED_RESOURCE_MANAGER_H_ 5 #ifndef CC_PRIORITIZED_RESOURCE_MANAGER_H_
6 #define CC_PRIORITIZED_RESOURCE_MANAGER_H_ 6 #define CC_PRIORITIZED_RESOURCE_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/synchronization/lock.h"
14 #include "cc/cc_export.h" 15 #include "cc/cc_export.h"
15 #include "cc/proxy.h" 16 #include "cc/proxy.h"
16 #include "cc/prioritized_resource.h" 17 #include "cc/prioritized_resource.h"
17 #include "cc/priority_calculator.h" 18 #include "cc/priority_calculator.h"
18 #include "cc/resource.h" 19 #include "cc/resource.h"
19 #include "third_party/khronos/GLES2/gl2.h" 20 #include "third_party/khronos/GLES2/gl2.h"
20 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
21 22
22 #if defined(COMPILER_GCC) 23 #if defined(COMPILER_GCC)
23 namespace BASE_HASH_NAMESPACE { 24 namespace BASE_HASH_NAMESPACE {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 size_t memoryVisibleBytes() const; 76 size_t memoryVisibleBytes() const;
76 size_t memoryVisibleAndNearbyBytes() const; 77 size_t memoryVisibleAndNearbyBytes() const;
77 78
78 void prioritizeTextures(); 79 void prioritizeTextures();
79 void clearPriorities(); 80 void clearPriorities();
80 81
81 // Delete contents textures' backing resources until they use only bytesLimi t bytes. This may 82 // Delete contents textures' backing resources until they use only bytesLimi t bytes. This may
82 // be called on the impl thread while the main thread is running. Returns tr ue if resources are 83 // be called on the impl thread while the main thread is running. Returns tr ue if resources are
83 // indeed evicted as a result of this call. 84 // indeed evicted as a result of this call.
84 bool reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, Resourc eProvider*); 85 bool reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, Resourc eProvider*);
86
85 // Returns true if there exist any textures that are linked to backings that have had their 87 // Returns true if there exist any textures that are linked to backings that have had their
86 // resources evicted. Only when we commit a tree that has no textures linked to evicted backings 88 // resources evicted. Only when we commit a tree that has no textures linked to evicted backings
87 // may we allow drawing. 89 // may we allow drawing. After an eviction, this will not become true until
90 // unlinkAndClearEvictedBackings is called.
88 bool linkedEvictedBackingsExist() const; 91 bool linkedEvictedBackingsExist() const;
89 // Retrieve the list of all contents textures' backings that have been evict ed, to pass to the 92
90 // main thread to unlink them from their owning textures. 93 // Unlink the list of contents textures' backings from their owning textures and delete the evicted
91 void getEvictedBackings(BackingList& evictedBackings); 94 // backings' structures. This is called just before updating layers, and is only ever called on the
92 // Unlink the list of contents textures' backings from their owning textures on the main thread 95 // main thread.
93 // before updating layers. 96 void unlinkAndClearEvictedBackings();
94 void unlinkEvictedBackings(const BackingList& evictedBackings);
95 97
96 bool requestLate(PrioritizedResource*); 98 bool requestLate(PrioritizedResource*);
97 99
98 void reduceMemory(ResourceProvider*); 100 void reduceMemory(ResourceProvider*);
99 void clearAllMemory(ResourceProvider*); 101 void clearAllMemory(ResourceProvider*);
100 102
101 void acquireBackingTextureIfNeeded(PrioritizedResource*, ResourceProvider*); 103 void acquireBackingTextureIfNeeded(PrioritizedResource*, ResourceProvider*);
102 104
103 void registerTexture(PrioritizedResource*); 105 void registerTexture(PrioritizedResource*);
104 void unregisterTexture(PrioritizedResource*); 106 void unregisterTexture(PrioritizedResource*);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 154
153 PrioritizedResourceManager(int pool, const Proxy* proxy); 155 PrioritizedResourceManager(int pool, const Proxy* proxy);
154 156
155 bool evictBackingsToReduceMemory(size_t limitBytes, 157 bool evictBackingsToReduceMemory(size_t limitBytes,
156 int priorityCutoff, 158 int priorityCutoff,
157 EvictionPolicy, 159 EvictionPolicy,
158 UnlinkPolicy, 160 UnlinkPolicy,
159 ResourceProvider*); 161 ResourceProvider*);
160 PrioritizedResource::Backing* createBacking(gfx::Size, GLenum format, Resour ceProvider*); 162 PrioritizedResource::Backing* createBacking(gfx::Size, GLenum format, Resour ceProvider*);
161 void evictFirstBackingResource(ResourceProvider*); 163 void evictFirstBackingResource(ResourceProvider*);
162 void deleteAllEvictedBackings();
163 void sortBackings(); 164 void sortBackings();
164 165
165 void assertInvariants(); 166 void assertInvariants();
166 167
167 size_t m_maxMemoryLimitBytes; 168 size_t m_maxMemoryLimitBytes;
168 // The priority cutoff based on memory pressure. This is not a strict 169 // The priority cutoff based on memory pressure. This is not a strict
169 // cutoff -- requestLate allows textures with priority equal to this 170 // cutoff -- requestLate allows textures with priority equal to this
170 // cutoff to be allowed. 171 // cutoff to be allowed.
171 int m_priorityCutoff; 172 int m_priorityCutoff;
172 // The priority cutoff based on external memory policy. This is a strict 173 // The priority cutoff based on external memory policy. This is a strict
173 // cutoff -- no textures with priority equal to this cutoff will be allowed. 174 // cutoff -- no textures with priority equal to this cutoff will be allowed.
174 int m_externalPriorityCutoff; 175 int m_externalPriorityCutoff;
175 size_t m_memoryUseBytes; 176 size_t m_memoryUseBytes;
176 size_t m_memoryAboveCutoffBytes; 177 size_t m_memoryAboveCutoffBytes;
177 size_t m_memoryAvailableBytes; 178 size_t m_memoryAvailableBytes;
178 int m_pool; 179 int m_pool;
179 180
180 typedef base::hash_set<PrioritizedResource*> TextureSet; 181 typedef base::hash_set<PrioritizedResource*> TextureSet;
181 typedef std::vector<PrioritizedResource*> TextureVector; 182 typedef std::vector<PrioritizedResource*> TextureVector;
182 183
183 const Proxy* m_proxy; 184 const Proxy* m_proxy;
184 185
185 TextureSet m_textures; 186 TextureSet m_textures;
186 // This list is always sorted in eviction order, with the exception the 187 // This list is always sorted in eviction order, with the exception the
187 // newly-allocated or recycled textures at the very end of the tail that 188 // newly-allocated or recycled textures at the very end of the tail that
188 // are not sorted by priority. 189 // are not sorted by priority.
189 BackingList m_backings; 190 BackingList m_backings;
190 bool m_backingsTailNotSorted; 191 bool m_backingsTailNotSorted;
192
193 // The list of backings that have been evicted, but may still be linked
194 // to textures. This can be accessed concurrently by the main and impl
195 // threads, and may only be accessed while holding m_evictedBackingsLock.
196 mutable base::Lock m_evictedBackingsLock;
191 BackingList m_evictedBackings; 197 BackingList m_evictedBackings;
192 198
193 TextureVector m_tempTextureVector; 199 TextureVector m_tempTextureVector;
194 200
195 // Statistics about memory usage at priority cutoffs, computed at prioritize Textures. 201 // Statistics about memory usage at priority cutoffs, computed at prioritize Textures.
196 size_t m_memoryVisibleBytes; 202 size_t m_memoryVisibleBytes;
197 size_t m_memoryVisibleAndNearbyBytes; 203 size_t m_memoryVisibleAndNearbyBytes;
198 204
199 // Statistics copied at the time of pushTexturePrioritiesToBackings. 205 // Statistics copied at the time of pushTexturePrioritiesToBackings.
200 size_t m_memoryVisibleLastPushedBytes; 206 size_t m_memoryVisibleLastPushedBytes;
201 size_t m_memoryVisibleAndNearbyLastPushedBytes; 207 size_t m_memoryVisibleAndNearbyLastPushedBytes;
202 208
203 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager); 209 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager);
204 }; 210 };
205 211
206 } // namespace cc 212 } // namespace cc
207 213
208 #endif // CC_PRIORITIZED_RESOURCE_MANAGER_H_ 214 #endif // CC_PRIORITIZED_RESOURCE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/prioritized_resource.cc ('k') | cc/prioritized_resource_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698