OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009-2015 Google Inc. | 2 * Copyright 2009-2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ | 8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ |
9 | 9 |
10 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include <unistd.h> | 25 #include <unistd.h> |
26 | 26 |
27 #ifdef SK_DEBUG | 27 #ifdef SK_DEBUG |
28 # include "SkTLS.h" | 28 # include "SkTLS.h" |
29 #endif | 29 #endif |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // Fontconfig is not threadsafe before 2.10.91. Before that, we lock with a glob
al mutex. | 33 // Fontconfig is not threadsafe before 2.10.91. Before that, we lock with a glob
al mutex. |
34 // See https://bug.skia.org/1497 for background. | 34 // See https://bug.skia.org/1497 for background. |
35 SK_DECLARE_STATIC_MUTEX(gFCMutex); | 35 static SkMutex gFCMutex; |
36 | 36 |
37 #ifdef SK_DEBUG | 37 #ifdef SK_DEBUG |
38 void* CreateThreadFcLocked() { return new bool(false); } | 38 void* CreateThreadFcLocked() { return new bool(false); } |
39 void DeleteThreadFcLocked(void* v) { delete static_cast<bool*>(v); } | 39 void DeleteThreadFcLocked(void* v) { delete static_cast<bool*>(v); } |
40 # define THREAD_FC_LOCKED \ | 40 # define THREAD_FC_LOCKED \ |
41 static_cast<bool*>(SkTLS::Get(CreateThreadFcLocked, DeleteThreadFcLocked
)) | 41 static_cast<bool*>(SkTLS::Get(CreateThreadFcLocked, DeleteThreadFcLocked
)) |
42 #endif | 42 #endif |
43 | 43 |
44 struct FCLocker { | 44 struct FCLocker { |
45 // Assume FcGetVersion() has always been thread safe. | 45 // Assume FcGetVersion() has always been thread safe. |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 const char* famName = get_name(match, FC_FAMILY); | 726 const char* famName = get_name(match, FC_FAMILY); |
727 if (famName && !find_name(names, famName)) { | 727 if (famName && !find_name(names, famName)) { |
728 *names.append() = famName; | 728 *names.append() = famName; |
729 *sizes.append() = strlen(famName) + 1; | 729 *sizes.append() = strlen(famName) + 1; |
730 } | 730 } |
731 } | 731 } |
732 | 732 |
733 return SkDataTable::NewCopyArrays((const void*const*)names.begin(), | 733 return SkDataTable::NewCopyArrays((const void*const*)names.begin(), |
734 sizes.begin(), names.count()); | 734 sizes.begin(), names.count()); |
735 } | 735 } |
OLD | NEW |