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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #endif | 69 #endif |
70 } | 70 } |
71 | 71 |
72 protected: | 72 protected: |
73 GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) { } | 73 GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) { } |
74 | 74 |
75 bool internalHasPendingRead() const { return SkToBool(fPendingReads); } | 75 bool internalHasPendingRead() const { return SkToBool(fPendingReads); } |
76 bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); } | 76 bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); } |
77 bool internalHasPendingIO() const { return SkToBool(fPendingWrites | fPendin
gReads); } | 77 bool internalHasPendingIO() const { return SkToBool(fPendingWrites | fPendin
gReads); } |
78 | 78 |
| 79 bool internalHasRef() const { return SkToBool(fRefCnt); } |
| 80 |
79 private: | 81 private: |
80 void addPendingRead() const { | 82 void addPendingRead() const { |
81 this->validate(); | 83 this->validate(); |
82 ++fPendingReads; | 84 ++fPendingReads; |
83 } | 85 } |
84 | 86 |
85 void completedRead() const { | 87 void completedRead() const { |
86 this->validate(); | 88 this->validate(); |
87 --fPendingReads; | 89 --fPendingReads; |
88 this->didUnref(); | 90 this->didUnref(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 167 |
166 /** | 168 /** |
167 * Retrieves the amount of GPU memory used by this resource in bytes. It is | 169 * Retrieves the amount of GPU memory used by this resource in bytes. It is |
168 * approximate since we aren't aware of additional padding or copies made | 170 * approximate since we aren't aware of additional padding or copies made |
169 * by the driver. | 171 * by the driver. |
170 * | 172 * |
171 * @return the amount of GPU memory used in bytes | 173 * @return the amount of GPU memory used in bytes |
172 */ | 174 */ |
173 virtual size_t gpuMemorySize() const = 0; | 175 virtual size_t gpuMemorySize() const = 0; |
174 | 176 |
175 bool setCacheEntry(GrResourceCacheEntry* cacheEntry); | 177 // TODO(bsalomon): Move this stuff to GrGpuResourcePriv. |
| 178 bool setContentKey(const GrResourceKey& contentKey); |
| 179 void setCacheEntry(GrResourceCacheEntry* cacheEntry); |
176 GrResourceCacheEntry* getCacheEntry() const { return fCacheEntry; } | 180 GrResourceCacheEntry* getCacheEntry() const { return fCacheEntry; } |
177 bool isScratch() const; | 181 bool isScratch() const; |
178 | |
179 /** | 182 /** |
180 * If this resource can be used as a scratch resource this returns a valid | 183 * If this resource can be used as a scratch resource this returns a valid |
181 * scratch key. Otherwise it returns a key for which isNullScratch is true. | 184 * scratch key. Otherwise it returns a key for which isNullScratch is true. |
| 185 * The resource may currently be used as content resource rather than scratc
h. |
| 186 * Check isScratch(). |
182 */ | 187 */ |
183 const GrResourceKey& getScratchKey() const { return fScratchKey; } | 188 const GrResourceKey& getScratchKey() const { return fScratchKey; } |
184 | |
185 /** | 189 /** |
186 * If this resource is currently cached by its contents then this will retur
n | 190 * If this resource is currently cached by its contents then this will retur
n |
187 * the content key. Otherwise, NULL is returned. | 191 * the content key. Otherwise, NULL is returned. |
188 */ | 192 */ |
189 const GrResourceKey* getContentKey() const; | 193 const GrResourceKey* getContentKey() const; |
190 | 194 |
191 /** | 195 /** |
192 * Gets an id that is unique for this GrGpuResource object. It is static in
that it does | 196 * Gets an id that is unique for this GrGpuResource object. It is static in
that it does |
193 * not change when the content of the GrGpuResource object changes. This wil
l never return | 197 * not change when the content of the GrGpuResource object changes. This wil
l never return |
194 * 0. | 198 * 0. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 * free it). | 255 * free it). |
252 */ | 256 */ |
253 kWrapped_FlagBit = 0x1, | 257 kWrapped_FlagBit = 0x1, |
254 }; | 258 }; |
255 | 259 |
256 uint32_t fFlags; | 260 uint32_t fFlags; |
257 | 261 |
258 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | 262 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache |
259 const uint32_t fUniqueID; | 263 const uint32_t fUniqueID; |
260 | 264 |
| 265 // TODO(bsalomon): Remove GrResourceKey and use different simpler types for
content and scratch |
| 266 // keys. |
261 GrResourceKey fScratchKey; | 267 GrResourceKey fScratchKey; |
| 268 GrResourceKey fContentKey; |
| 269 bool fContentKeySet; |
262 | 270 |
263 typedef GrIORef<GrGpuResource> INHERITED; | 271 typedef GrIORef<GrGpuResource> INHERITED; |
264 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. | 272 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. |
265 }; | 273 }; |
266 | 274 |
267 #endif | 275 #endif |
OLD | NEW |