From a20681c2ac9d1a36875289b6207cbcd3a36132f7 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Mon, 14 May 2018 13:51:10 -0400 Subject: Move SkFontConfigInterface to smart pointers. This old interface may be easier to move away from if it isn't so difficult to understand. Change-Id: Ib04b00e55fd5c11aca8cc70bc6c7b0b5ba98dcae Reviewed-on: https://skia-review.googlesource.com/127969 Reviewed-by: Herb Derby Commit-Queue: Ben Wagner --- src/ports/SkFontConfigInterface.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/ports') 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 gFontConfigInterface(nullptr); -SkFontConfigInterface* SkFontConfigInterface::RefGlobal() { +sk_sp 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 fc) { + SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); + + gFontConfigInterface = std::move(fc); +} -- cgit v1.2.3