aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontConfigInterface.cpp
blob: a30bd2dac2e75b27c05ad1f181c79f832aa9504a (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
/*
 * Copyright 2016 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"

SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
static sk_sp<SkFontConfigInterface> gFontConfigInterface(nullptr);

sk_sp<SkFontConfigInterface> SkFontConfigInterface::RefGlobal() {
    SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);

    if (gFontConfigInterface) {
        return gFontConfigInterface;
    }
    return sk_ref_sp(SkFontConfigInterface::GetSingletonDirectInterface());
}

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

    gFontConfigInterface = sk_ref_sp(fc);
    return fc;
}

void SkFontConfigInterface::SetGlobal(sk_sp<SkFontConfigInterface> fc) {
    SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);

    gFontConfigInterface = std::move(fc);
}