aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPathRef.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-09-09 09:09:53 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-09 09:09:53 -0700
commit6c59d80858f453a426df9b07fdf3a8cc01e0b906 (patch)
tree1fc4c3c03062744c4382a40e608bdb147bebad09 /src/core/SkPathRef.cpp
parent336cda3fc0e01cd80212e0ac133d65b60824868e (diff)
Port uses of SkLazyPtr to SkOncePtr.
This gives SkOncePtr a non-trivial destructor that uses std::default_delete by default. This is overrideable, as seen in SkColorTable. SK_DECLARE_STATIC_ONCE_PTR still just leaves its pointers hanging at EOP. BUG=skia: No public API changes. TBR=reed@google.com Committed: https://skia.googlesource.com/skia/+/a1254acdb344174e761f5061c820559dab64a74c Review URL: https://codereview.chromium.org/1322933005
Diffstat (limited to 'src/core/SkPathRef.cpp')
-rw-r--r--src/core/SkPathRef.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index be7c66cc4b..119711381f 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -6,7 +6,7 @@
*/
#include "SkBuffer.h"
-#include "SkLazyPtr.h"
+#include "SkOncePtr.h"
#include "SkPath.h"
#include "SkPathRef.h"
@@ -44,17 +44,13 @@ SkPathRef::~SkPathRef() {
SkDEBUGCODE(fEditorsAttached = 0x7777777;)
}
-// As a template argument, this must have external linkage.
-SkPathRef* sk_create_empty_pathref() {
- SkPathRef* empty = new SkPathRef;
- empty->computeBounds(); // Avoids races later to be the first to do this.
- return empty;
-}
-
-SK_DECLARE_STATIC_LAZY_PTR(SkPathRef, empty, sk_create_empty_pathref);
-
+SK_DECLARE_STATIC_ONCE_PTR(SkPathRef, empty);
SkPathRef* SkPathRef::CreateEmpty() {
- return SkRef(empty.get());
+ return SkRef(empty.get([]{
+ SkPathRef* pr = new SkPathRef;
+ pr->computeBounds(); // Avoids races later to be the first to do this.
+ return pr;
+ }));
}
void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
@@ -443,7 +439,7 @@ uint32_t SkPathRef::genID() const {
}
void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) {
- if (nullptr == listener || this == empty.get()) {
+ if (nullptr == listener || this == (SkPathRef*)empty) {
delete listener;
return;
}