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

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

Issue 382523002: Revert "Remove ability for Release code to call getRefCnt() or getWeakRefCnt()." (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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/SkRefCnt.h ('k') | src/core/SkImageFilter.cpp » ('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 2012 Google Inc. 2 * Copyright 2012 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 SkWeakRefCnt_DEFINED 8 #ifndef SkWeakRefCnt_DEFINED
9 #define SkWeakRefCnt_DEFINED 9 #define SkWeakRefCnt_DEFINED
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 public: 53 public:
54 SK_DECLARE_INST_COUNT(SkWeakRefCnt) 54 SK_DECLARE_INST_COUNT(SkWeakRefCnt)
55 55
56 /** Default construct, initializing the reference counts to 1. 56 /** Default construct, initializing the reference counts to 1.
57 The strong references collectively hold one weak reference. When the 57 The strong references collectively hold one weak reference. When the
58 strong reference count goes to zero, the collectively held weak 58 strong reference count goes to zero, the collectively held weak
59 reference is released. 59 reference is released.
60 */ 60 */
61 SkWeakRefCnt() : SkRefCnt(), fWeakCnt(1) {} 61 SkWeakRefCnt() : SkRefCnt(), fWeakCnt(1) {}
62 62
63 #ifdef SK_DEBUG
64 /** Destruct, asserting that the weak reference count is 1. 63 /** Destruct, asserting that the weak reference count is 1.
65 */ 64 */
66 virtual ~SkWeakRefCnt() { 65 virtual ~SkWeakRefCnt() {
66 #ifdef SK_DEBUG
67 SkASSERT(fWeakCnt == 1); 67 SkASSERT(fWeakCnt == 1);
68 fWeakCnt = 0; 68 fWeakCnt = 0;
69 #endif
69 } 70 }
70 71
71 /** Return the weak reference count. 72 /** Return the weak reference count.
72 */ 73 */
73 int32_t getWeakCnt() const { return fWeakCnt; } 74 int32_t getWeakCnt() const { return fWeakCnt; }
74 75
76 #ifdef SK_DEBUG
75 void validate() const { 77 void validate() const {
76 this->INHERITED::validate(); 78 this->INHERITED::validate();
77 SkASSERT(fWeakCnt > 0); 79 SkASSERT(fWeakCnt > 0);
78 } 80 }
79 #endif 81 #endif
80 82
81 /** Creates a strong reference from a weak reference, if possible. The 83 /** Creates a strong reference from a weak reference, if possible. The
82 caller must already be an owner. If try_ref() returns true the owner 84 caller must already be an owner. If try_ref() returns true the owner
83 is in posession of an additional strong reference. Both the original 85 is in posession of an additional strong reference. Both the original
84 reference and new reference must be properly unreferenced. If try_ref() 86 reference and new reference must be properly unreferenced. If try_ref()
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 collectively by the strong references. 148 collectively by the strong references.
147 */ 149 */
148 virtual void internal_dispose() const SK_OVERRIDE { 150 virtual void internal_dispose() const SK_OVERRIDE {
149 weak_dispose(); 151 weak_dispose();
150 weak_unref(); 152 weak_unref();
151 } 153 }
152 154
153 /* Invariant: fWeakCnt = #weak + (fRefCnt > 0 ? 1 : 0) */ 155 /* Invariant: fWeakCnt = #weak + (fRefCnt > 0 ? 1 : 0) */
154 mutable int32_t fWeakCnt; 156 mutable int32_t fWeakCnt;
155 157
156 // Used by tests.
157 friend bool WeakRefCntIs(const SkWeakRefCnt&, int32_t);
158
159 typedef SkRefCnt INHERITED; 158 typedef SkRefCnt INHERITED;
160 }; 159 };
161 160
162 #endif 161 #endif
OLDNEW
« no previous file with comments | « include/core/SkRefCnt.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698