| OLD | NEW |
| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 void setScratchKey(const GrScratchKey& scratchKey); | 262 void setScratchKey(const GrScratchKey& scratchKey); |
| 263 | 263 |
| 264 private: | 264 private: |
| 265 /** | 265 /** |
| 266 * Frees the object in the underlying 3D API. Called by CacheAccess. | 266 * Frees the object in the underlying 3D API. Called by CacheAccess. |
| 267 */ | 267 */ |
| 268 void release(); | 268 void release(); |
| 269 | 269 |
| 270 virtual size_t onGpuMemorySize() const = 0; | 270 virtual size_t onGpuMemorySize() const = 0; |
| 271 | 271 |
| 272 // See comments in CacheAccess. | 272 // See comments in CacheAccess and ResourcePriv. |
| 273 bool setContentKey(const GrContentKey& contentKey); | 273 bool setContentKey(const GrContentKey& contentKey); |
| 274 void removeContentKey(); | 274 void removeContentKey(); |
| 275 void notifyIsPurgeable() const; | 275 void notifyIsPurgeable() const; |
| 276 void removeScratchKey(); | 276 void removeScratchKey(); |
| 277 void makeBudgeted(); | 277 void makeBudgeted(); |
| 278 void makeUnbudgeted(); | 278 void makeUnbudgeted(); |
| 279 | 279 |
| 280 #ifdef SK_DEBUG | 280 #ifdef SK_DEBUG |
| 281 friend class GrGpu; // for assert in GrGpu to access getGpu | 281 friend class GrGpu; // for assert in GrGpu to access getGpu |
| 282 #endif | 282 #endif |
| 283 | 283 |
| 284 static uint32_t CreateUniqueID(); | 284 static uint32_t CreateUniqueID(); |
| 285 | 285 |
| 286 // We're in an internal doubly linked list owned by GrResourceCache | 286 // We're in an internal doubly linked list owned by GrResourceCache. TODO: R
eplace this with an |
| 287 // array of unpurgeable resources in the cache. |
| 287 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrGpuResource); | 288 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrGpuResource); |
| 288 | 289 |
| 290 // An index into a heap when this resource is purgeable. This is maintained
by the cache. |
| 291 int fCacheArrayIndex; |
| 292 // This value reflects how recently this resource was accessed in the cache.
This is maintained |
| 293 // by the cache. |
| 294 uint32_t fTimestamp; |
| 289 | 295 |
| 290 static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); | 296 static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); |
| 291 GrScratchKey fScratchKey; | 297 GrScratchKey fScratchKey; |
| 292 GrContentKey fContentKey; | 298 GrContentKey fContentKey; |
| 293 | 299 |
| 294 // This is not ref'ed but abandon() or release() will be called before the G
rGpu object | 300 // This is not ref'ed but abandon() or release() will be called before the G
rGpu object |
| 295 // is destroyed. Those calls set will this to NULL. | 301 // is destroyed. Those calls set will this to NULL. |
| 296 GrGpu* fGpu; | 302 GrGpu* fGpu; |
| 297 mutable size_t fGpuMemorySize; | 303 mutable size_t fGpuMemorySize; |
| 298 | 304 |
| 299 LifeCycle fLifeCycle; | 305 LifeCycle fLifeCycle; |
| 300 const uint32_t fUniqueID; | 306 const uint32_t fUniqueID; |
| 301 | 307 |
| 302 SkAutoTUnref<const SkData> fData; | 308 SkAutoTUnref<const SkData> fData; |
| 303 | 309 |
| 304 typedef GrIORef<GrGpuResource> INHERITED; | 310 typedef GrIORef<GrGpuResource> INHERITED; |
| 305 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgeable. | 311 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgeable. |
| 306 }; | 312 }; |
| 307 | 313 |
| 308 #endif | 314 #endif |
| OLD | NEW |