Index: include/core/SkRefCnt.h |
=================================================================== |
--- include/core/SkRefCnt.h (revision 10200) |
+++ include/core/SkRefCnt.h (working copy) |
@@ -41,10 +41,22 @@ |
#endif |
} |
- /** Return the reference count. |
- */ |
+ /** Return the reference count. Use only for debugging. */ |
int32_t getRefCnt() const { return fRefCnt; } |
+ /** Returns true if the caller is the only owner. |
+ * Ensures that all previous owner's actions are complete. |
+ */ |
+ bool unique() const { |
+ bool const unique = (1 == fRefCnt); |
+ if (unique) { |
+ // Aquire barrier (L/SL), if not provided by load of fRefCnt. |
+ // Prevents user's 'unique' code from happening before decrements. |
+ //TODO: issue the barrier. |
+ } |
+ return unique; |
+ } |
+ |
/** Increment the reference count. Must be balanced by a call to unref(). |
*/ |
void ref() const { |
@@ -72,16 +84,6 @@ |
} |
/** |
- * Alias for ref(), for compatibility with scoped_refptr. |
- */ |
- void AddRef() { this->ref(); } |
- |
- /** |
- * Alias for unref(), for compatibility with scoped_refptr. |
- */ |
- void Release() { this->unref(); } |
- |
- /** |
* Alias for unref(), for compatibility with WTF::RefPtr. |
*/ |
void deref() { this->unref(); } |
@@ -109,9 +111,10 @@ |
SkDELETE(this); |
} |
+ // The following friends are those which override internal_dispose() |
+ // and conditionally call SkRefCnt::internal_dispose(). |
+ friend class GrTexture; |
friend class SkWeakRefCnt; |
- friend class GrTexture; // to allow GrTexture's internal_dispose to |
- // call SkRefCnt's & directly set fRefCnt (to 1) |
mutable int32_t fRefCnt; |