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

Unified Diff: src/core/SkPathRef.cpp

Issue 304383005: Port most uses of SkOnce to SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add mutex Created 6 years, 7 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/SkMessageBus.h ('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 161eb804199ba2f7e96d03d4a926819bdaaf99f1..de7a8f56ae07a8939f56a05b26f6b034a2ae5f5c 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -6,7 +6,7 @@
*/
#include "SkBuffer.h"
-#include "SkOnce.h"
+#include "SkLazyPtr.h"
#include "SkPath.h"
#include "SkPathRef.h"
@@ -28,18 +28,16 @@ SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
}
//////////////////////////////////////////////////////////////////////////////
-static SkPathRef* gEmptyPathRef = NULL;
-static void cleanup_gEmptyPathRef() { gEmptyPathRef->unref(); }
-void SkPathRef::CreateEmptyImpl(int) {
- gEmptyPathRef = SkNEW(SkPathRef);
- gEmptyPathRef->computeBounds(); // Preemptively avoid a race to clear fBoundsIsDirty.
+SkPathRef* SkPathRef::CreateEmptyImpl() {
+ SkPathRef* p = SkNEW(SkPathRef);
+ p->computeBounds(); // Preemptively avoid a race to clear fBoundsIsDirty.
+ return p;
}
SkPathRef* SkPathRef::CreateEmpty() {
- SK_DECLARE_STATIC_ONCE(once);
- SkOnce(&once, SkPathRef::CreateEmptyImpl, 0, cleanup_gEmptyPathRef);
- return SkRef(gEmptyPathRef);
+ SK_DECLARE_STATIC_LAZY_PTR(SkPathRef, empty, CreateEmptyImpl);
+ return SkRef(empty.get());
}
void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
« no previous file with comments | « src/core/SkMessageBus.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698