• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "SkFontConfigInterface.h"
9 #include "SkFontMgr.h"
10 #include "SkMutex.h"
11 #include "SkRefCnt.h"
12 
13 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
14 static SkFontConfigInterface* gFontConfigInterface;
15 
RefGlobal()16 sk_sp<SkFontConfigInterface> SkFontConfigInterface::RefGlobal() {
17     SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
18 
19     if (gFontConfigInterface) {
20         return sk_ref_sp(gFontConfigInterface);
21     }
22     return sk_ref_sp(SkFontConfigInterface::GetSingletonDirectInterface());
23 }
24 
SetGlobal(sk_sp<SkFontConfigInterface> fc)25 void SkFontConfigInterface::SetGlobal(sk_sp<SkFontConfigInterface> fc) {
26     SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
27 
28     SkSafeUnref(gFontConfigInterface);
29     gFontConfigInterface = fc.release();
30 }
31