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

Side by Side Diff: include/gpu/GrGpuObject.h

Issue 392333008: Make GrCacheable implement its own ref counting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove extra blank line 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/gpu/GrContext.h ('k') | include/gpu/GrTexture.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 2011 Google Inc. 2 * Copyright 2011 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 GrGpuObject_DEFINED 8 #ifndef GrGpuObject_DEFINED
9 #define GrGpuObject_DEFINED 9 #define GrGpuObject_DEFINED
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 /** 48 /**
49 * Retrieves the context that owns the object. Note that it is possible for 49 * Retrieves the context that owns the object. Note that it is possible for
50 * this to return NULL. When objects have been release()ed or abandon()ed 50 * this to return NULL. When objects have been release()ed or abandon()ed
51 * they no longer have an owning context. Destroying a GrContext 51 * they no longer have an owning context. Destroying a GrContext
52 * automatically releases all its resources. 52 * automatically releases all its resources.
53 */ 53 */
54 const GrContext* getContext() const; 54 const GrContext* getContext() const;
55 GrContext* getContext(); 55 GrContext* getContext();
56 56
57 void incDeferredRefCount() const {
58 SkASSERT(fDeferredRefCount >= 0);
59 ++fDeferredRefCount;
60 }
61
62 void decDeferredRefCount() const {
63 SkASSERT(fDeferredRefCount > 0);
64 --fDeferredRefCount;
65 if (0 == fDeferredRefCount && this->needsDeferredUnref()) {
66 SkASSERT(this->getRefCnt() > 1);
67 this->unref();
68 }
69 }
70
71 int getDeferredRefCount() const { return fDeferredRefCount; }
72
73 void setNeedsDeferredUnref() { fFlags |= kDeferredUnref_FlagBit; }
74
75 virtual bool isValidOnGpu() const SK_OVERRIDE { return !this->wasDestroyed() ; } 57 virtual bool isValidOnGpu() const SK_OVERRIDE { return !this->wasDestroyed() ; }
76 58
77 protected: 59 protected:
78 /** 60 /**
79 * isWrapped indicates we have wrapped a client-created backend object in a GrGpuObject. If it 61 * isWrapped indicates we have wrapped a client-created backend object in a GrGpuObject. If it
80 * is true then the client is responsible for the lifetime of the underlying backend object. 62 * is true then the client is responsible for the lifetime of the underlying backend object.
81 * Otherwise, our onRelease() should free the object. 63 * Otherwise, our onRelease() should free the object.
82 */ 64 */
83 GrGpuObject(GrGpu* gpu, bool isWrapped); 65 GrGpuObject(GrGpu* gpu, bool isWrapped);
84 virtual ~GrGpuObject(); 66 virtual ~GrGpuObject();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 * no one else wants to) but doesn't really want to keep it around. 103 * no one else wants to) but doesn't really want to keep it around.
122 */ 104 */
123 kDeferredUnref_FlagBit = 0x2, 105 kDeferredUnref_FlagBit = 0x2,
124 }; 106 };
125 uint32_t fFlags; 107 uint32_t fFlags;
126 108
127 typedef GrCacheable INHERITED; 109 typedef GrCacheable INHERITED;
128 }; 110 };
129 111
130 #endif 112 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | include/gpu/GrTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698