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

Side by Side Diff: include/gpu/GrGpuResource.h

Issue 2301523003: Have GrSurfaceProxys and GrGpuResources draw from the same pool of unique ids (Closed)
Patch Set: update to ToT Created 4 years, 3 months 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
« no previous file with comments | « no previous file | include/private/GrSurfaceProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGpuResource_DEFINED 8 #ifndef GrGpuResource_DEFINED
9 #define GrGpuResource_DEFINED 9 #define GrGpuResource_DEFINED
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 SkASSERT(kInvalidGpuMemorySize != fGpuMemorySize); 173 SkASSERT(kInvalidGpuMemorySize != fGpuMemorySize);
174 } 174 }
175 return fGpuMemorySize; 175 return fGpuMemorySize;
176 } 176 }
177 177
178 /** 178 /**
179 * Gets an id that is unique for this GrGpuResource object. It is static in that it does 179 * Gets an id that is unique for this GrGpuResource object. It is static in that it does
180 * not change when the content of the GrGpuResource object changes. This wil l never return 180 * not change when the content of the GrGpuResource object changes. This wil l never return
181 * 0. 181 * 0.
182 */ 182 */
183 uint32_t getUniqueID() const { return fUniqueID; } 183 uint32_t uniqueID() const { return fUniqueID; }
184 184
185 /** Returns the current unique key for the resource. It will be invalid if t he resource has no 185 /** Returns the current unique key for the resource. It will be invalid if t he resource has no
186 associated unique key. */ 186 associated unique key. */
187 const GrUniqueKey& getUniqueKey() const { return fUniqueKey; } 187 const GrUniqueKey& getUniqueKey() const { return fUniqueKey; }
188 188
189 /** 189 /**
190 * Internal-only helper class used for manipulations of the resource by the cache. 190 * Internal-only helper class used for manipulations of the resource by the cache.
191 */ 191 */
192 class CacheAccess; 192 class CacheAccess;
193 inline CacheAccess cacheAccess(); 193 inline CacheAccess cacheAccess();
(...skipping 16 matching lines...) Expand all
210 */ 210 */
211 void abandon(); 211 void abandon();
212 212
213 /** 213 /**
214 * Dumps memory usage information for this GrGpuResource to traceMemoryDump. 214 * Dumps memory usage information for this GrGpuResource to traceMemoryDump.
215 * Typically, subclasses should not need to override this, and should only 215 * Typically, subclasses should not need to override this, and should only
216 * need to override setMemoryBacking. 216 * need to override setMemoryBacking.
217 **/ 217 **/
218 virtual void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const; 218 virtual void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
219 219
220 static uint32_t CreateUniqueID();
221
220 protected: 222 protected:
221 // This must be called by every non-wrapped GrGpuObject. It should be called once the object is 223 // This must be called by every non-wrapped GrGpuObject. It should be called once the object is
222 // fully initialized (i.e. only from the constructors of the final class). 224 // fully initialized (i.e. only from the constructors of the final class).
223 void registerWithCache(SkBudgeted); 225 void registerWithCache(SkBudgeted);
224 226
225 // This must be called by every GrGpuObject that references any wrapped back end objects. It 227 // This must be called by every GrGpuObject that references any wrapped back end objects. It
226 // should be called once the object is fully initialized (i.e. only from the constructors of the 228 // should be called once the object is fully initialized (i.e. only from the constructors of the
227 // final class). 229 // final class).
228 void registerWithCacheWrapped(); 230 void registerWithCacheWrapped();
229 231
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void removeUniqueKey(); 274 void removeUniqueKey();
273 void notifyAllCntsAreZero(CntType) const; 275 void notifyAllCntsAreZero(CntType) const;
274 bool notifyRefCountIsZero() const; 276 bool notifyRefCountIsZero() const;
275 void removeScratchKey(); 277 void removeScratchKey();
276 void makeBudgeted(); 278 void makeBudgeted();
277 void makeUnbudgeted(); 279 void makeUnbudgeted();
278 280
279 #ifdef SK_DEBUG 281 #ifdef SK_DEBUG
280 friend class GrGpu; // for assert in GrGpu to access getGpu 282 friend class GrGpu; // for assert in GrGpu to access getGpu
281 #endif 283 #endif
282
283 static uint32_t CreateUniqueID();
284
285 // An index into a heap when this resource is purgeable or an array when not . This is maintained 284 // An index into a heap when this resource is purgeable or an array when not . This is maintained
286 // by the cache. 285 // by the cache.
287 int fCacheArrayIndex; 286 int fCacheArrayIndex;
288 // This value reflects how recently this resource was accessed in the cache. This is maintained 287 // This value reflects how recently this resource was accessed in the cache. This is maintained
289 // by the cache. 288 // by the cache.
290 uint32_t fTimestamp; 289 uint32_t fTimestamp;
291 290
292 static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); 291 static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0);
293 GrScratchKey fScratchKey; 292 GrScratchKey fScratchKey;
294 GrUniqueKey fUniqueKey; 293 GrUniqueKey fUniqueKey;
295 294
296 // This is not ref'ed but abandon() or release() will be called before the G rGpu object 295 // This is not ref'ed but abandon() or release() will be called before the G rGpu object
297 // is destroyed. Those calls set will this to NULL. 296 // is destroyed. Those calls set will this to NULL.
298 GrGpu* fGpu; 297 GrGpu* fGpu;
299 mutable size_t fGpuMemorySize; 298 mutable size_t fGpuMemorySize;
300 299
301 SkBudgeted fBudgeted; 300 SkBudgeted fBudgeted;
302 bool fRefsWrappedObjects; 301 bool fRefsWrappedObjects;
303 const uint32_t fUniqueID; 302 const uint32_t fUniqueID;
304 303
305 typedef GrIORef<GrGpuResource> INHERITED; 304 typedef GrIORef<GrGpuResource> INHERITED;
306 friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and n otifyRefCntIsZero. 305 friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and n otifyRefCntIsZero.
307 }; 306 };
308 307
309 #endif 308 #endif
OLDNEW
« no previous file with comments | « no previous file | include/private/GrSurfaceProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698