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 |
11 #include "SkInstCnt.h" | 11 #include "SkInstCnt.h" |
12 #include "SkTInternalLList.h" | 12 #include "SkTInternalLList.h" |
13 | 13 |
14 class GrResourceCacheEntry; | 14 class GrResourceCacheEntry; |
| 15 class GrResourceCache2; |
15 class GrGpu; | 16 class GrGpu; |
16 class GrContext; | 17 class GrContext; |
17 | 18 |
18 /** | 19 /** |
19 * Base class for objects that can be kept in the GrResourceCache. | 20 * Base class for objects that can be kept in the GrResourceCache. |
20 */ | 21 */ |
21 class GrGpuResource : public SkNoncopyable { | 22 class GrGpuResource : public SkNoncopyable { |
22 public: | 23 public: |
23 SK_DECLARE_INST_COUNT_ROOT(GrGpuResource) | 24 SK_DECLARE_INST_COUNT_ROOT(GrGpuResource) |
24 | 25 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 */ | 112 */ |
112 void didChangeGpuMemorySize() const; | 113 void didChangeGpuMemorySize() const; |
113 | 114 |
114 private: | 115 private: |
115 #ifdef SK_DEBUG | 116 #ifdef SK_DEBUG |
116 friend class GrGpu; // for assert in GrGpu to access getGpu | 117 friend class GrGpu; // for assert in GrGpu to access getGpu |
117 #endif | 118 #endif |
118 | 119 |
119 static uint32_t CreateUniqueID(); | 120 static uint32_t CreateUniqueID(); |
120 | 121 |
121 // We're in an internal doubly linked list | 122 // We're in an internal doubly linked list owned by GrResourceCache2 |
122 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrGpuResource); | 123 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrGpuResource); |
123 | 124 |
124 GrGpu* fGpu; // not reffed. The GrGpu can be dele
ted while there | 125 // This is not ref'ed but abandon() or release() will be called before the G
rGpu object |
125 // are still live GrGpuResources. It
will call | 126 // is destroyed. Those calls set will this to NULL. |
126 // release() on all such objects in
its destructor. | 127 GrGpu* fGpu; |
| 128 |
127 enum Flags { | 129 enum Flags { |
128 /** | 130 /** |
129 * This object wraps a GPU object given to us by the user. | 131 * This object wraps a GPU object given to us by the user. |
130 * Lifetime management is left up to the user (i.e., we will not | 132 * Lifetime management is left up to the user (i.e., we will not |
131 * free it). | 133 * free it). |
132 */ | 134 */ |
133 kWrapped_FlagBit = 0x1, | 135 kWrapped_FlagBit = 0x1, |
134 }; | 136 }; |
135 | 137 |
136 uint32_t fFlags; | 138 uint32_t fFlags; |
137 | 139 |
138 mutable int32_t fRefCnt; | 140 mutable int32_t fRefCnt; |
139 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | 141 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache |
140 const uint32_t fUniqueID; | 142 const uint32_t fUniqueID; |
141 | 143 |
142 typedef SkNoncopyable INHERITED; | 144 typedef SkNoncopyable INHERITED; |
143 }; | 145 }; |
144 | 146 |
145 #endif | 147 #endif |
OLD | NEW |