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