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

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

Issue 2213333002: SkLite* (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: annoying... Created 4 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 | « include/core/SkCanvas.h ('k') | src/core/SkLiteDL.h » ('j') | 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (1 == fRefCnt.fetch_add(-1, std::memory_order_acq_rel)) { 94 if (1 == fRefCnt.fetch_add(-1, std::memory_order_acq_rel)) {
95 // Like unique(), the acquire is only needed on success, to make sur e 95 // Like unique(), the acquire is only needed on success, to make sur e
96 // code in internal_dispose() doesn't happen before the decrement. 96 // code in internal_dispose() doesn't happen before the decrement.
97 this->internal_dispose(); 97 this->internal_dispose();
98 } 98 }
99 } 99 }
100 100
101 protected: 101 protected:
102 /** 102 /**
103 * Allow subclasses to call this if they've overridden internal_dispose 103 * Allow subclasses to call this if they've overridden internal_dispose
104 * so they can reset fRefCnt before the destructor is called. Should only 104 * so they can reset fRefCnt before the destructor is called or if they
105 * be called right before calling through to inherited internal_dispose() 105 * choose not to call the destructor (e.g. using a free list).
106 * or before calling the destructor.
107 */ 106 */
108 void internal_dispose_restore_refcnt_to_1() const { 107 void internal_dispose_restore_refcnt_to_1() const {
109 #ifdef SK_DEBUG
110 SkASSERT(0 == getRefCnt()); 108 SkASSERT(0 == getRefCnt());
111 fRefCnt.store(1, std::memory_order_relaxed); 109 fRefCnt.store(1, std::memory_order_relaxed);
112 #endif
113 } 110 }
114 111
115 private: 112 private:
116 /** 113 /**
117 * Called when the ref count goes to 0. 114 * Called when the ref count goes to 0.
118 */ 115 */
119 virtual void internal_dispose() const { 116 virtual void internal_dispose() const {
120 this->internal_dispose_restore_refcnt_to_1(); 117 this->internal_dispose_restore_refcnt_to_1();
121 delete this; 118 delete this;
122 } 119 }
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 * 457 *
461 * This function may be helpful while we convert callers from ptr-based to sk_s p-based parameters. 458 * This function may be helpful while we convert callers from ptr-based to sk_s p-based parameters.
462 */ 459 */
463 template <typename T> sk_sp<T> sk_ref_sp(T* obj) { 460 template <typename T> sk_sp<T> sk_ref_sp(T* obj) {
464 return sk_sp<T>(SkSafeRef(obj)); 461 return sk_sp<T>(SkSafeRef(obj));
465 } 462 }
466 463
467 #endif 464 #endif
468 465
469 #endif 466 #endif
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/core/SkLiteDL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698