Index: src/utils/SkEventTracer.cpp |
diff --git a/src/utils/SkEventTracer.cpp b/src/utils/SkEventTracer.cpp |
index 0a748d1464d70f9d30ac9d66f5909ad798cb2a2d..32a0207c23ebaa0f3d0ac9edd7a29688a67c0e23 100644 |
--- a/src/utils/SkEventTracer.cpp |
+++ b/src/utils/SkEventTracer.cpp |
@@ -7,7 +7,7 @@ |
#include "SkAtomics.h" |
#include "SkEventTracer.h" |
-#include "SkOnce.h" |
+#include "SkOncePtr.h" |
#include <stdlib.h> |
@@ -39,8 +39,9 @@ |
} |
}; |
-// We prefer gUserTracer if it's been set, otherwise we fall back on a default tracer; |
+// We prefer gUserTracer if it's been set, otherwise we fall back on gDefaultTracer. |
static SkEventTracer* gUserTracer = nullptr; |
+SK_DECLARE_STATIC_ONCE_PTR(SkDefaultEventTracer, gDefaultTracer); |
void SkEventTracer::SetInstance(SkEventTracer* tracer) { |
SkASSERT(nullptr == sk_atomic_load(&gUserTracer, sk_memory_order_acquire)); |
@@ -53,8 +54,5 @@ |
if (SkEventTracer* tracer = sk_atomic_load(&gUserTracer, sk_memory_order_acquire)) { |
return tracer; |
} |
- static SkOnce once; |
- static SkDefaultEventTracer* defaultTracer; |
- once([] { defaultTracer = new SkDefaultEventTracer; }); |
- return defaultTracer; |
+ return gDefaultTracer.get([]{ return new SkDefaultEventTracer; }); |
} |