| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |