Index: src/core/SkPathRef.cpp |
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp |
index 2fc2de935c149031342cdcdc538535bf50dcb49b..b18055136f54ce2cc1ed95ed7fb569c298ec0c4d 100644 |
--- a/src/core/SkPathRef.cpp |
+++ b/src/core/SkPathRef.cpp |
@@ -6,7 +6,7 @@ |
*/ |
#include "SkBuffer.h" |
-#include "SkOnce.h" |
+#include "SkOncePtr.h" |
#include "SkPath.h" |
#include "SkPathRef.h" |
#include <limits> |
@@ -45,15 +45,13 @@ |
SkDEBUGCODE(fEditorsAttached = 0x7777777;) |
} |
-static SkPathRef* gEmpty = nullptr; |
- |
+SK_DECLARE_STATIC_ONCE_PTR(SkPathRef, empty); |
SkPathRef* SkPathRef::CreateEmpty() { |
- static SkOnce once; |
- once([]{ |
- gEmpty = new SkPathRef; |
- gEmpty->computeBounds(); // Avoids races later to be the first to do this. |
- }); |
- return SkRef(gEmpty); |
+ 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, |
@@ -471,7 +469,7 @@ |
} |
void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) { |
- if (nullptr == listener || this == gEmpty) { |
+ if (nullptr == listener || this == (SkPathRef*)empty) { |
delete listener; |
return; |
} |