blob: 5b8731c3d07cc9d8abd0fe94376954424b03cd2b [file] [log] [blame]
bungeman1ae0e012016-09-19 12:13:16 -07001/*
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
13SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
14static SkFontConfigInterface* gFontConfigInterface;
15
16SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
17 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
18
19 if (gFontConfigInterface) {
20 return SkRef(gFontConfigInterface);
21 }
22 return SkSafeRef(SkFontConfigInterface::GetSingletonDirectInterface());
23}
24
25SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* fc) {
26 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
27
28 SkRefCnt_SafeAssign(gFontConfigInterface, fc);
29 return fc;
30}