Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: include/core/SkRefCnt.h

Issue 1297093004: Enable debug builds in the Android framework (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add more comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkRefCnt_DEFINED 8 #ifndef SkRefCnt_DEFINED
9 #define SkRefCnt_DEFINED 9 #define SkRefCnt_DEFINED
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // prevents code conditioned on the result of unique() from running 50 // prevents code conditioned on the result of unique() from running
51 // until previous owners are all totally done calling unref(). 51 // until previous owners are all totally done calling unref().
52 return true; 52 return true;
53 } 53 }
54 return false; 54 return false;
55 } 55 }
56 56
57 /** Increment the reference count. Must be balanced by a call to unref(). 57 /** Increment the reference count. Must be balanced by a call to unref().
58 */ 58 */
59 void ref() const { 59 void ref() const {
60 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
61 // Android employs some special subclasses that enable the fRefCnt to
62 // go to zero, but not below, prior to reusing the object. This breaks
63 // the use of unique() on such objects and as such should be removed
64 // once the Android code is fixed.
65 SkASSERT(fRefCnt >= 0);
66 #else
60 SkASSERT(fRefCnt > 0); 67 SkASSERT(fRefCnt > 0);
68 #endif
61 (void)sk_atomic_fetch_add(&fRefCnt, +1, sk_memory_order_relaxed); // No barrier required. 69 (void)sk_atomic_fetch_add(&fRefCnt, +1, sk_memory_order_relaxed); // No barrier required.
62 } 70 }
63 71
64 /** Decrement the reference count. If the reference count is 1 before the 72 /** Decrement the reference count. If the reference count is 1 before the
65 decrement, then delete the object. Note that if this is the case, then 73 decrement, then delete the object. Note that if this is the case, then
66 the object needs to have been allocated via new, and not on the stack. 74 the object needs to have been allocated via new, and not on the stack.
67 */ 75 */
68 void unref() const { 76 void unref() const {
69 SkASSERT(fRefCnt > 0); 77 SkASSERT(fRefCnt > 0);
70 // A release here acts in place of all releases we "should" have been do ing in ref(). 78 // A release here acts in place of all releases we "should" have been do ing in ref().
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 SkDELETE((const Derived*)this); 246 SkDELETE((const Derived*)this);
239 } 247 }
240 } 248 }
241 void deref() const { this->unref(); } 249 void deref() const { this->unref(); }
242 250
243 private: 251 private:
244 mutable int32_t fRefCnt; 252 mutable int32_t fRefCnt;
245 }; 253 };
246 254
247 #endif 255 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698