diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-01 19:38:19 +0000 |
---|---|---|
committer | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-01 19:38:19 +0000 |
commit | e70f798ebca1a66f0b568fa46065ebbad9a13b2f (patch) | |
tree | c251586a80f9dbd07fc7cef0d16dce670ebd549e /include/core | |
parent | c3b80ba50a494efdf6505585dc32dbe7422d5555 (diff) |
Serialize support for GDI.
http://codereview.appspot.com/6263046/
git-svn-id: http://skia.googlecode.com/svn/trunk@4126 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkRefCnt.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h index 384b3be2eb..d6277fdd83 100644 --- a/include/core/SkRefCnt.h +++ b/include/core/SkRefCnt.h @@ -141,7 +141,25 @@ public: return obj; } - T* operator->() { return fObj; } + /** + * BlockRef<T> is a type which inherits from T, cannot be created, + * and makes ref and unref private. + */ + template<typename T> class BlockRef : public T { + private: + BlockRef(); + void ref() const; + void unref() const; + }; + /** + * SkAutoTUnref assumes ownership of the ref. As a result, it is an error + * for the user to ref or unref through SkAutoTUnref. Therefore + * SkAutoTUnref::operator-> returns BlockRef<T>*. This prevents use of + * skAutoTUnrefInstance->ref() and skAutoTUnrefInstance->unref(). + */ + BlockRef<T> *operator->() const { + return static_cast<BlockRef<T>*>(fObj); + } operator T*() { return fObj; } private: |