| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 Google Inc. | 2 * Copyright 2008 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkFontConfigInterface.h" | 8 #include "SkFontConfigInterface.h" |
| 9 #include "SkFontMgr.h" | 9 #include "SkFontMgr.h" |
| 10 #include "SkMutex.h" | 10 #include "SkFontMgr_FontConfigInterface.h" |
| 11 #include "SkRefCnt.h" | |
| 12 | 11 |
| 13 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex); | 12 #ifdef SK_ADDING_src_ports_SkFontConfigInterface_cpp |
| 14 static SkFontConfigInterface* gFontConfigInterface; | 13 // The code previously here is moving to SkFontConfigInterface.cpp |
| 15 | 14 #include "SkFontConfigInterface.cpp" |
| 16 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() { | 15 #endif |
| 17 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); | |
| 18 | |
| 19 return SkSafeRef(gFontConfigInterface); | |
| 20 } | |
| 21 | |
| 22 SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* f
c) { | |
| 23 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); | |
| 24 | |
| 25 SkRefCnt_SafeAssign(gFontConfigInterface, fc); | |
| 26 return fc; | |
| 27 } | |
| 28 | |
| 29 /////////////////////////////////////////////////////////////////////////////// | |
| 30 | |
| 31 static SkFontConfigInterface* init_FCI() { | |
| 32 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); | |
| 33 | |
| 34 if (gFontConfigInterface) { | |
| 35 return SkRef(gFontConfigInterface); | |
| 36 } | |
| 37 gFontConfigInterface = SkRef(SkFontConfigInterface::GetSingletonDirectInterf
ace()); | |
| 38 return gFontConfigInterface; | |
| 39 } | |
| 40 | 16 |
| 41 SkFontMgr* SkFontMgr::Factory() { | 17 SkFontMgr* SkFontMgr::Factory() { |
| 42 SkFontConfigInterface* fci = init_FCI(); | 18 sk_sp<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal()); |
| 43 return fci ? SkFontMgr_New_FCI(fci) : nullptr; | 19 if (!fci) { |
| 20 return nullptr; |
| 21 } |
| 22 return SkFontMgr_New_FCI(std::move(fci)); |
| 44 } | 23 } |
| OLD | NEW |