aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_fontconfig.cpp
blob: 416173add9fba9ab8f73c44174e19d2fe2ee8e3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright 2008 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkFontConfigInterface.h"
#include "SkFontMgr.h"
#include "SkMutex.h"
#include "SkRefCnt.h"

static SkMutex gFontConfigInterfaceMutex;
static SkFontConfigInterface* gFontConfigInterface;

SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
    SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);

    return SkSafeRef(gFontConfigInterface);
}

SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* fc) {
    SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);

    SkRefCnt_SafeAssign(gFontConfigInterface, fc);
    return fc;
}

///////////////////////////////////////////////////////////////////////////////

static SkFontConfigInterface* init_FCI() {
    SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);

    if (gFontConfigInterface) {
        return SkRef(gFontConfigInterface);
    }
    gFontConfigInterface = SkRef(SkFontConfigInterface::GetSingletonDirectInterface());
    return gFontConfigInterface;
}

SkFontMgr* SkFontMgr::Factory() {
    SkFontConfigInterface* fci = init_FCI();
    return fci ? SkFontMgr_New_FCI(fci) : nullptr;
}