aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkTLazy.h
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-10 19:10:17 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-10 19:10:17 +0000
commit45a15f551b5b3c6c747d8eaf6466b7d3b76a8fae (patch)
tree49c9fd68caf3a90c7ed5a1ac89f418d6ce7b4afb /include/core/SkTLazy.h
parent6f9286202831dd807daf9b1e39271da8f390210e (diff)
Modifications to GrPatherRenderer(Chain) interfaces to support clip mask manager.
R=robertphillips@google.com Review URL: https://codereview.appspot.com/6904069 git-svn-id: http://skia.googlecode.com/svn/trunk@6741 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkTLazy.h')
-rw-r--r--include/core/SkTLazy.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/core/SkTLazy.h b/include/core/SkTLazy.h
index cd1e8f2b9c..315bd95101 100644
--- a/include/core/SkTLazy.h
+++ b/include/core/SkTLazy.h
@@ -116,10 +116,21 @@ class SkTCopyOnFirstWrite {
public:
SkTCopyOnFirstWrite(const T& initial) : fObj(&initial) {}
+ // Constructor for delayed initialization.
+ SkTCopyOnFirstWrite() : fObj(NULL) {}
+
+ // Should only be called once, and only if the default constructor was used.
+ void init(const T& initial) {
+ SkASSERT(NULL == fObj);
+ SkASSERT(!fLazy.isValid());
+ fObj = &initial;
+ }
+
/**
* Returns a writable T*. The first time this is called the initial object is cloned.
*/
T* writable() {
+ SkASSERT(NULL != fObj);
if (!fLazy.isValid()) {
fLazy.set(*fObj);
fObj = fLazy.get();