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

Unified Diff: src/core/SkPathRef.cpp

Issue 132803005: SkOnce: add option to call another cleanup function once at exit. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add static Created 6 years, 11 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/SkData.cpp ('k') | src/core/SkScaledImageCache.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 b83a4513765d84eba44a644bf65ee0f71939c1cf..161eb804199ba2f7e96d03d4a926819bdaaf99f1 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -28,15 +28,17 @@ SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
}
//////////////////////////////////////////////////////////////////////////////
-void SkPathRef::CreateEmptyImpl(SkPathRef** empty) {
- *empty = SkNEW(SkPathRef);
- (*empty)->computeBounds(); // Preemptively avoid a race to clear fBoundsIsDirty.
+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::CreateEmpty() {
- static SkPathRef* gEmptyPathRef;
SK_DECLARE_STATIC_ONCE(once);
- SkOnce(&once, SkPathRef::CreateEmptyImpl, &gEmptyPathRef);
+ SkOnce(&once, SkPathRef::CreateEmptyImpl, 0, cleanup_gEmptyPathRef);
return SkRef(gEmptyPathRef);
}
« no previous file with comments | « src/core/SkData.cpp ('k') | src/core/SkScaledImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698