Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: src/core/SkPathRef.cpp

Issue 1322933005: Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: name Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkMiniRecorder.cpp ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPathRef.cpp
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index be7c66cc4bb8263fd2ed2b490ab20d708b0c6ba9..119711381f6f1028ed47136138770a023ee7c6c0 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;
}
« no previous file with comments | « src/core/SkMiniRecorder.cpp ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698