| 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 "GrResourceKey.h" | 11 #include "GrResourceKey.h" |
| 12 #include "GrTypesPriv.h" | 12 #include "GrTypesPriv.h" |
| 13 #include "SkData.h" | |
| 14 | 13 |
| 15 class GrContext; | 14 class GrContext; |
| 16 class GrGpu; | 15 class GrGpu; |
| 17 class GrResourceCache; | 16 class GrResourceCache; |
| 18 class SkTraceMemoryDump; | 17 class SkTraceMemoryDump; |
| 19 | 18 |
| 20 /** | 19 /** |
| 21 * Base class for GrGpuResource. Handles the various types of refs we need. Sepa
rated out as a base | 20 * Base class for GrGpuResource. Handles the various types of refs we need. Sepa
rated out as a base |
| 22 * class to isolate the ref-cnting behavior and provide friendship without expos
ing all of | 21 * class to isolate the ref-cnting behavior and provide friendship without expos
ing all of |
| 23 * GrGpuResource. | 22 * GrGpuResource. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 * not change when the content of the GrGpuResource object changes. This wil
l never return | 180 * not change when the content of the GrGpuResource object changes. This wil
l never return |
| 182 * 0. | 181 * 0. |
| 183 */ | 182 */ |
| 184 uint32_t getUniqueID() const { return fUniqueID; } | 183 uint32_t getUniqueID() const { return fUniqueID; } |
| 185 | 184 |
| 186 /** Returns the current unique key for the resource. It will be invalid if t
he resource has no | 185 /** Returns the current unique key for the resource. It will be invalid if t
he resource has no |
| 187 associated unique key. */ | 186 associated unique key. */ |
| 188 const GrUniqueKey& getUniqueKey() const { return fUniqueKey; } | 187 const GrUniqueKey& getUniqueKey() const { return fUniqueKey; } |
| 189 | 188 |
| 190 /** | 189 /** |
| 191 * Attach a custom data object to this resource. The data will remain attach
ed | |
| 192 * for the lifetime of this resource (until it is abandoned or released). | |
| 193 * Takes a ref on data. Previously attached data, if any, is unrefed. | |
| 194 * Returns the data argument, for convenience. | |
| 195 */ | |
| 196 const SkData* setCustomData(const SkData* data); | |
| 197 | |
| 198 /** | |
| 199 * Returns the custom data object that was attached to this resource by | |
| 200 * calling setCustomData. | |
| 201 */ | |
| 202 const SkData* getCustomData() const { return fData.get(); } | |
| 203 | |
| 204 /** | |
| 205 * Internal-only helper class used for manipulations of the resource by the
cache. | 190 * Internal-only helper class used for manipulations of the resource by the
cache. |
| 206 */ | 191 */ |
| 207 class CacheAccess; | 192 class CacheAccess; |
| 208 inline CacheAccess cacheAccess(); | 193 inline CacheAccess cacheAccess(); |
| 209 inline const CacheAccess cacheAccess() const; | 194 inline const CacheAccess cacheAccess() const; |
| 210 | 195 |
| 211 /** | 196 /** |
| 212 * Internal-only helper class used for manipulations of the resource by inte
rnal code. | 197 * Internal-only helper class used for manipulations of the resource by inte
rnal code. |
| 213 */ | 198 */ |
| 214 class ResourcePriv; | 199 class ResourcePriv; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 295 |
| 311 // This is not ref'ed but abandon() or release() will be called before the G
rGpu object | 296 // This is not ref'ed but abandon() or release() will be called before the G
rGpu object |
| 312 // is destroyed. Those calls set will this to NULL. | 297 // is destroyed. Those calls set will this to NULL. |
| 313 GrGpu* fGpu; | 298 GrGpu* fGpu; |
| 314 mutable size_t fGpuMemorySize; | 299 mutable size_t fGpuMemorySize; |
| 315 | 300 |
| 316 SkBudgeted fBudgeted; | 301 SkBudgeted fBudgeted; |
| 317 bool fRefsWrappedObjects; | 302 bool fRefsWrappedObjects; |
| 318 const uint32_t fUniqueID; | 303 const uint32_t fUniqueID; |
| 319 | 304 |
| 320 SkAutoTUnref<const SkData> fData; | |
| 321 | |
| 322 typedef GrIORef<GrGpuResource> INHERITED; | 305 typedef GrIORef<GrGpuResource> INHERITED; |
| 323 friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and n
otifyRefCntIsZero. | 306 friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and n
otifyRefCntIsZero. |
| 324 }; | 307 }; |
| 325 | 308 |
| 326 #endif | 309 #endif |
| OLD | NEW |