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

Side by Side Diff: src/gpu/GrNonAtomicRef.h

Issue 2251573002: Implement difference clip rects with window rectangles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: return type 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 GrNonAtomicRef_DEFINED 8 #ifndef GrNonAtomicRef_DEFINED
9 #define GrNonAtomicRef_DEFINED 9 #define GrNonAtomicRef_DEFINED
10 10
(...skipping 10 matching lines...) Expand all
21 21
22 #ifdef SK_DEBUG 22 #ifdef SK_DEBUG
23 ~GrNonAtomicRef() { 23 ~GrNonAtomicRef() {
24 // fRefCnt can be one when a subclass is created statically 24 // fRefCnt can be one when a subclass is created statically
25 SkASSERT((0 == fRefCnt || 1 == fRefCnt)); 25 SkASSERT((0 == fRefCnt || 1 == fRefCnt));
26 // Set to invalid values. 26 // Set to invalid values.
27 fRefCnt = -10; 27 fRefCnt = -10;
28 } 28 }
29 #endif 29 #endif
30 30
31 bool unique() const { return 1 == fRefCnt; }
32
31 void ref() const { 33 void ref() const {
32 // Once the ref cnt reaches zero it should never be ref'ed again. 34 // Once the ref cnt reaches zero it should never be ref'ed again.
33 SkASSERT(fRefCnt > 0); 35 SkASSERT(fRefCnt > 0);
34 ++fRefCnt; 36 ++fRefCnt;
35 } 37 }
36 38
37 void unref() const { 39 void unref() const {
38 SkASSERT(fRefCnt > 0); 40 SkASSERT(fRefCnt > 0);
39 --fRefCnt; 41 --fRefCnt;
40 if (0 == fRefCnt) { 42 if (0 == fRefCnt) {
41 GrTDeleteNonAtomicRef(static_cast<const TSubclass*>(this)); 43 GrTDeleteNonAtomicRef(static_cast<const TSubclass*>(this));
42 return; 44 return;
43 } 45 }
44 } 46 }
45 47
46 private: 48 private:
47 mutable int32_t fRefCnt; 49 mutable int32_t fRefCnt;
48 50
49 typedef SkNoncopyable INHERITED; 51 typedef SkNoncopyable INHERITED;
50 }; 52 };
51 53
52 template<typename T> inline void GrTDeleteNonAtomicRef(const T* ref) { 54 template<typename T> inline void GrTDeleteNonAtomicRef(const T* ref) {
53 delete ref; 55 delete ref;
54 } 56 }
55 57
56 #endif 58 #endif
OLDNEW
« src/gpu/GrCaps.cpp ('K') | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrPipeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698