OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkRefCnt_DEFINED | 10 #ifndef SkRefCnt_DEFINED |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 SkASSERT(fRefCnt > 0); | 72 SkASSERT(fRefCnt > 0); |
73 // Release barrier (SL/S), if not provided below. | 73 // Release barrier (SL/S), if not provided below. |
74 if (sk_atomic_dec(&fRefCnt) == 1) { | 74 if (sk_atomic_dec(&fRefCnt) == 1) { |
75 // Aquire barrier (L/SL), if not provided above. | 75 // Aquire barrier (L/SL), if not provided above. |
76 // Prevents code in dispose from happening before the decrement. | 76 // Prevents code in dispose from happening before the decrement. |
77 sk_membar_aquire__after_atomic_dec(); | 77 sk_membar_aquire__after_atomic_dec(); |
78 internal_dispose(); | 78 internal_dispose(); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
| 82 #ifdef SK_DEBUG |
82 void validate() const { | 83 void validate() const { |
83 SkASSERT(fRefCnt > 0); | 84 SkASSERT(fRefCnt > 0); |
84 } | 85 } |
| 86 #endif |
85 | 87 |
86 /** | 88 /** |
87 * Alias for unref(), for compatibility with WTF::RefPtr. | 89 * Alias for unref(), for compatibility with WTF::RefPtr. |
88 */ | 90 */ |
89 void deref() { this->unref(); } | 91 void deref() { this->unref(); } |
90 | 92 |
91 protected: | 93 protected: |
92 /** | 94 /** |
93 * Allow subclasses to call this if they've overridden internal_dispose | 95 * Allow subclasses to call this if they've overridden internal_dispose |
94 * so they can reset fRefCnt before the destructor is called. Should only | 96 * so they can reset fRefCnt before the destructor is called. Should only |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 typedef T* SkRefPtr::*unspecified_bool_type; | 274 typedef T* SkRefPtr::*unspecified_bool_type; |
273 operator unspecified_bool_type() const { | 275 operator unspecified_bool_type() const { |
274 return fObj ? &SkRefPtr::fObj : NULL; | 276 return fObj ? &SkRefPtr::fObj : NULL; |
275 } | 277 } |
276 | 278 |
277 private: | 279 private: |
278 T* fObj; | 280 T* fObj; |
279 }; | 281 }; |
280 | 282 |
281 #endif | 283 #endif |
OLD | NEW |