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 GrCacheable_DEFINED | 8 #ifndef GrCacheable_DEFINED |
9 #define GrCacheable_DEFINED | 9 #define GrCacheable_DEFINED |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 * should no longer count against the GrResourceCache budget. | 34 * should no longer count against the GrResourceCache budget. |
35 * | 35 * |
36 * @return true if this resource is still holding GPU memory | 36 * @return true if this resource is still holding GPU memory |
37 * false otherwise. | 37 * false otherwise. |
38 */ | 38 */ |
39 virtual bool isValidOnGpu() const = 0; | 39 virtual bool isValidOnGpu() const = 0; |
40 | 40 |
41 void setCacheEntry(GrResourceCacheEntry* cacheEntry) { fCacheEntry = cacheEn
try; } | 41 void setCacheEntry(GrResourceCacheEntry* cacheEntry) { fCacheEntry = cacheEn
try; } |
42 GrResourceCacheEntry* getCacheEntry() { return fCacheEntry; } | 42 GrResourceCacheEntry* getCacheEntry() { return fCacheEntry; } |
43 | 43 |
| 44 /** |
| 45 * Gets an id that is unique for this GrCacheable object. It is static in th
at it does |
| 46 * not change when the content of the GrCacheable object changes. This will
never return |
| 47 * 0. |
| 48 */ |
| 49 uint32_t getGenerationID() const; |
| 50 |
44 protected: | 51 protected: |
45 GrCacheable() : fCacheEntry(NULL) {} | 52 GrCacheable() |
| 53 : fCacheEntry(NULL) |
| 54 , fGenID(0) {} |
46 | 55 |
47 bool isInCache() const { return NULL != fCacheEntry; } | 56 bool isInCache() const { return NULL != fCacheEntry; } |
48 | 57 |
49 /** | 58 /** |
50 * This entry point should be called whenever gpuMemorySize() begins | 59 * This entry point should be called whenever gpuMemorySize() begins |
51 * reporting a different size. If the object is in the cache, it will call | 60 * reporting a different size. If the object is in the cache, it will call |
52 * gpuMemorySize() immediately and pass the new size on to the resource | 61 * gpuMemorySize() immediately and pass the new size on to the resource |
53 * cache. | 62 * cache. |
54 */ | 63 */ |
55 void didChangeGpuMemorySize() const; | 64 void didChangeGpuMemorySize() const; |
56 | 65 |
57 private: | 66 private: |
58 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | 67 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache |
| 68 mutable uint32_t fGenID; |
59 | 69 |
60 typedef SkRefCnt INHERITED; | 70 typedef SkRefCnt INHERITED; |
61 }; | 71 }; |
62 | 72 |
63 #endif | 73 #endif |
OLD | NEW |