aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/ports/SkFontConfigInterface.h7
-rw-r--r--src/ports/SkFontConfigInterface.cpp16
2 files changed, 14 insertions, 9 deletions
diff --git a/include/ports/SkFontConfigInterface.h b/include/ports/SkFontConfigInterface.h
index c6b7b78628..bb7eebe5d5 100644
--- a/include/ports/SkFontConfigInterface.h
+++ b/include/ports/SkFontConfigInterface.h
@@ -29,13 +29,12 @@ public:
* unref(). The default SkFontConfigInterface is the result of calling
* GetSingletonDirectInterface.
*/
- static SkFontConfigInterface* RefGlobal();
+ static sk_sp<SkFontConfigInterface> RefGlobal();
/**
- * Replace the current global instance with the specified one, safely
- * ref'ing the new instance, and unref'ing the previous. Returns its
- * parameter (the new global instance).
+ * Replace the current global instance with the specified one.
*/
+ static void SetGlobal(sk_sp<SkFontConfigInterface> fc);
static SkFontConfigInterface* SetGlobal(SkFontConfigInterface*);
/**
diff --git a/src/ports/SkFontConfigInterface.cpp b/src/ports/SkFontConfigInterface.cpp
index 5b8731c3d0..a30bd2dac2 100644
--- a/src/ports/SkFontConfigInterface.cpp
+++ b/src/ports/SkFontConfigInterface.cpp
@@ -11,20 +11,26 @@
#include "SkRefCnt.h"
SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
-static SkFontConfigInterface* gFontConfigInterface;
+static sk_sp<SkFontConfigInterface> gFontConfigInterface(nullptr);
-SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
+sk_sp<SkFontConfigInterface> SkFontConfigInterface::RefGlobal() {
SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
if (gFontConfigInterface) {
- return SkRef(gFontConfigInterface);
+ return gFontConfigInterface;
}
- return SkSafeRef(SkFontConfigInterface::GetSingletonDirectInterface());
+ return sk_ref_sp(SkFontConfigInterface::GetSingletonDirectInterface());
}
SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* fc) {
SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
- SkRefCnt_SafeAssign(gFontConfigInterface, fc);
+ gFontConfigInterface = sk_ref_sp(fc);
return fc;
}
+
+void SkFontConfigInterface::SetGlobal(sk_sp<SkFontConfigInterface> fc) {
+ SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
+
+ gFontConfigInterface = std::move(fc);
+}