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 28 matching lines...) Expand all Loading... |
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 /** | 44 /** |
45 * Gets an id that is unique for this GrCacheable object. It is static in th
at it does | 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 | 46 * not change when the content of the GrCacheable object changes. This will
never return |
47 * 0. | 47 * 0. |
48 */ | 48 */ |
49 uint64_t getInstanceID() const { return fInstanceID; } | 49 uint32_t getGenerationID() const; |
50 | 50 |
51 protected: | 51 protected: |
52 GrCacheable() | 52 GrCacheable() |
53 : fCacheEntry(NULL) | 53 : fCacheEntry(NULL) |
54 , fInstanceID(CreateInstanceID()) {} | 54 , fGenID(0) {} |
55 | 55 |
56 bool isInCache() const { return NULL != fCacheEntry; } | 56 bool isInCache() const { return NULL != fCacheEntry; } |
57 | 57 |
58 /** | 58 /** |
59 * This entry point should be called whenever gpuMemorySize() begins | 59 * This entry point should be called whenever gpuMemorySize() begins |
60 * 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 |
61 * gpuMemorySize() immediately and pass the new size on to the resource | 61 * gpuMemorySize() immediately and pass the new size on to the resource |
62 * cache. | 62 * cache. |
63 */ | 63 */ |
64 void didChangeGpuMemorySize() const; | 64 void didChangeGpuMemorySize() const; |
65 | 65 |
66 private: | 66 private: |
67 static uint64_t CreateInstanceID(); | |
68 | |
69 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | 67 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache |
70 mutable uint64_t fInstanceID; | 68 mutable uint32_t fGenID; |
71 | 69 |
72 typedef SkRefCnt INHERITED; | 70 typedef SkRefCnt INHERITED; |
73 }; | 71 }; |
74 | 72 |
75 #endif | 73 #endif |
OLD | NEW |