#include <SkRefCnt.h>
Inherited by SkBounder, SkCanvas, SkColorTable, SkDevice, SkDrawFilter, SkFlattenable, SkPicture, SkPixelRef, SkPtrRecorder, SkStream, and SkTypeface.
Public Member Functions | |
SkRefCnt () | |
virtual | ~SkRefCnt () |
int32_t | getRefCnt () const |
void | ref () const |
void | unref () const |
void | safeRef () const |
void | safeUnref () const |
SkRefCnt is the base class for objects that may be shared by multiple objects. When a new owner wants a reference, it calls ref(). When an owner wants to release its reference, it calls unref(). When the shared object's reference count goes to zero as the result of an unref() call, its (virtual) destructor is called. It is an error for the destructor to be called explicitly (or via the object going out of scope on the stack or calling delete) if getRefCnt() > 1.
Definition at line 32 of file SkRefCnt.h.
SkRefCnt::SkRefCnt | ( | ) | [inline] |
Default construct, initializing the reference count to 1.
Definition at line 36 of file SkRefCnt.h.
virtual SkRefCnt::~SkRefCnt | ( | ) | [inline, virtual] |
Destruct, asserting that the reference count is 1.
Definition at line 40 of file SkRefCnt.h.
int32_t SkRefCnt::getRefCnt | ( | ) | const [inline] |
Return the reference count.
Definition at line 44 of file SkRefCnt.h.
void SkRefCnt::ref | ( | ) | const [inline] |
Increment the reference count. Must be balanced by a call to unref().
Definition at line 48 of file SkRefCnt.h.
void SkRefCnt::safeRef | ( | ) | const [inline] |
Helper version of ref(), that first checks to see if this is not null. If this is null, then do nothing.
Definition at line 69 of file SkRefCnt.h.
void SkRefCnt::safeUnref | ( | ) | const [inline] |
Helper version of unref(), that first checks to see if this is not null. If this is null, then do nothing.
Definition at line 78 of file SkRefCnt.h.
void SkRefCnt::unref | ( | ) | const [inline] |
Decrement the reference count. If the reference count is 1 before the decrement, then call delete on the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.
Definition at line 58 of file SkRefCnt.h.