| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void completedWrite() const { | 96 void completedWrite() const { |
| 97 this->validate(); | 97 this->validate(); |
| 98 --fPendingWrites; | 98 --fPendingWrites; |
| 99 this->didUnref(); | 99 this->didUnref(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 void didUnref() const { | 103 void didUnref() const { |
| 104 if (0 == fPendingReads && 0 == fPendingWrites) { | 104 if (0 == fPendingReads && 0 == fPendingWrites) { |
| 105 if (0 == fRefCnt) { | 105 if (0 == fRefCnt) { |
| 106 SkDELETE(this); | 106 // Must call derived destructor since this is not a virtual clas
s. |
| 107 SkDELETE(static_cast<const DERIVED*>(this)); |
| 107 } else if (1 == fRefCnt) { | 108 } else if (1 == fRefCnt) { |
| 108 // The one ref is the cache's | 109 // The one ref is the cache's |
| 109 static_cast<const DERIVED*>(this)->notifyIsPurgable(); | 110 static_cast<const DERIVED*>(this)->notifyIsPurgable(); |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 | 114 |
| 114 mutable int32_t fRefCnt; | 115 mutable int32_t fRefCnt; |
| 115 mutable int32_t fPendingReads; | 116 mutable int32_t fPendingReads; |
| 116 mutable int32_t fPendingWrites; | 117 mutable int32_t fPendingWrites; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | 260 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache |
| 260 const uint32_t fUniqueID; | 261 const uint32_t fUniqueID; |
| 261 | 262 |
| 262 GrResourceKey fScratchKey; | 263 GrResourceKey fScratchKey; |
| 263 | 264 |
| 264 typedef GrIORef<GrGpuResource> INHERITED; | 265 typedef GrIORef<GrGpuResource> INHERITED; |
| 265 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. | 266 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. |
| 266 }; | 267 }; |
| 267 | 268 |
| 268 #endif | 269 #endif |
| OLD | NEW |