diff options
author | 2011-04-10 00:35:29 +0000 | |
---|---|---|
committer | 2011-04-10 00:35:29 +0000 | |
commit | 2c8fc5a7038cdfbb28a8364fd0057f3c21f90bfd (patch) | |
tree | 1a30cdd8b60797d7ab5185801dbd20cd83608bfa /include/core/SkTLazy.h | |
parent | d11f0e0173b349bfac3c98f6d32c10dc7e1ba1fa (diff) |
add init() to SkTLazy to create a default instance
use SkLazyPaint in internalDrawBitmap
git-svn-id: http://skia.googlecode.com/svn/trunk@1093 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkTLazy.h')
-rw-r--r-- | include/core/SkTLazy.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/core/SkTLazy.h b/include/core/SkTLazy.h index 94e64150e1..fecc975a35 100644 --- a/include/core/SkTLazy.h +++ b/include/core/SkTLazy.h @@ -48,6 +48,20 @@ public: } /** + * Return a pointer to a default-initialized instance of the class. If a + * previous instance had been initialzied (either from init() or set()) it + * will first be destroyed, so that a freshly initialized instance is + * always returned. + */ + T* init() { + if (fPtr) { + fPtr->~T(); + } + fPtr = new (fStorage) T; + return fPtr; + } + + /** * Copy src into this, and return a pointer to a copy of it. Note this * will always return the same pointer, so if it is called on a lazy that * has already been initialized, then this will copy over the previous |