aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontConfigInterface.cpp
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-09-19 12:13:16 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-19 12:13:16 -0700
commit1ae0e01accbca4b96a10b8a8c21917dd7bf27dc3 (patch)
tree61601c7afe04b356d2117fd2b00fd25faa01917b /src/ports/SkFontConfigInterface.cpp
parent0262b5c1a0ab704e42d367b070a09bb83188d983 (diff)
Split SkFontConfigInterface globals and factory.
Chromium needs to be able to set up their build such that the globals continue existing but the SkFontMgr::Factory can be defined separately. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2346333002 CQ_INCLUDE_TRYBOTS=master.client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot Review-Url: https://codereview.chromium.org/2346333002
Diffstat (limited to 'src/ports/SkFontConfigInterface.cpp')
-rw-r--r--src/ports/SkFontConfigInterface.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ports/SkFontConfigInterface.cpp b/src/ports/SkFontConfigInterface.cpp
new file mode 100644
index 0000000000..5b8731c3d0
--- /dev/null
+++ b/src/ports/SkFontConfigInterface.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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 SkFontConfigInterface* gFontConfigInterface;
+
+SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
+ SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
+
+ if (gFontConfigInterface) {
+ return SkRef(gFontConfigInterface);
+ }
+ return SkSafeRef(SkFontConfigInterface::GetSingletonDirectInterface());
+}
+
+SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* fc) {
+ SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
+
+ SkRefCnt_SafeAssign(gFontConfigInterface, fc);
+ return fc;
+}