| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 Google Inc. | 2 * Copyright 2008 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 #include "SkFontConfigInterface.h" | 8 #include "SkFontConfigInterface.h" |
| 9 #include "SkFontConfigTypeface.h" | 9 #include "SkFontConfigTypeface.h" |
| 10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 // export this to SkFontMgr_fontconfig.cpp until this file just goes away. | 53 // export this to SkFontMgr_fontconfig.cpp until this file just goes away. |
| 54 SkFontConfigInterface* SkFontHost_fontconfig_ref_global(); | 54 SkFontConfigInterface* SkFontHost_fontconfig_ref_global(); |
| 55 SkFontConfigInterface* SkFontHost_fontconfig_ref_global() { | 55 SkFontConfigInterface* SkFontHost_fontconfig_ref_global() { |
| 56 return RefFCI(); | 56 return RefFCI(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 /////////////////////////////////////////////////////////////////////////////// | 59 /////////////////////////////////////////////////////////////////////////////// |
| 60 | 60 |
| 61 static bool find_by_FontIdentity(SkTypeface* cachedTypeface, const SkFontStyle&,
void* ctx) { | 61 static bool find_by_FontIdentity(SkTypeface* cachedTypeface, void* ctx) { |
| 62 typedef SkFontConfigInterface::FontIdentity FontIdentity; | 62 typedef SkFontConfigInterface::FontIdentity FontIdentity; |
| 63 FontConfigTypeface* cachedFCTypeface = static_cast<FontConfigTypeface*>(cach
edTypeface); | 63 FontConfigTypeface* cachedFCTypeface = static_cast<FontConfigTypeface*>(cach
edTypeface); |
| 64 FontIdentity* identity = static_cast<FontIdentity*>(ctx); | 64 FontIdentity* identity = static_cast<FontIdentity*>(ctx); |
| 65 | 65 |
| 66 return cachedFCTypeface->getIdentity() == *identity; | 66 return cachedFCTypeface->getIdentity() == *identity; |
| 67 } | 67 } |
| 68 | 68 |
| 69 SK_DECLARE_STATIC_MUTEX(gSkFontHostRequestCacheMutex); | 69 SK_DECLARE_STATIC_MUTEX(gSkFontHostRequestCacheMutex); |
| 70 class SkFontHostRequestCache { | 70 class SkFontHostRequestCache { |
| 71 | 71 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 &identity, &outFamilyName, &outStyle)) | 189 &identity, &outFamilyName, &outStyle)) |
| 190 { | 190 { |
| 191 return nullptr; | 191 return nullptr; |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Check if a typeface with this FontIdentity is already in the FontIdentity
cache. | 194 // Check if a typeface with this FontIdentity is already in the FontIdentity
cache. |
| 195 face = SkTypefaceCache::FindByProcAndRef(find_by_FontIdentity, &identity); | 195 face = SkTypefaceCache::FindByProcAndRef(find_by_FontIdentity, &identity); |
| 196 if (!face) { | 196 if (!face) { |
| 197 face = FontConfigTypeface::Create(outStyle, identity, outFamilyName); | 197 face = FontConfigTypeface::Create(outStyle, identity, outFamilyName); |
| 198 // Add this FontIdentity to the FontIdentity cache. | 198 // Add this FontIdentity to the FontIdentity cache. |
| 199 SkTypefaceCache::Add(face, outStyle); | 199 SkTypefaceCache::Add(face); |
| 200 } | 200 } |
| 201 // Add this request to the request cache. | 201 // Add this request to the request cache. |
| 202 SkFontHostRequestCache::Add(face, request.release()); | 202 SkFontHostRequestCache::Add(face, request.release()); |
| 203 | 203 |
| 204 return face; | 204 return face; |
| 205 } | 205 } |
| 206 | 206 |
| 207 /////////////////////////////////////////////////////////////////////////////// | 207 /////////////////////////////////////////////////////////////////////////////// |
| 208 | 208 |
| 209 SkStreamAsset* FontConfigTypeface::onOpenStream(int* ttcIndex) const { | 209 SkStreamAsset* FontConfigTypeface::onOpenStream(int* ttcIndex) const { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 227 *familyName = fFamilyName; | 227 *familyName = fFamilyName; |
| 228 } | 228 } |
| 229 | 229 |
| 230 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 230 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 231 bool* isLocalStream) const { | 231 bool* isLocalStream) const { |
| 232 SkString name; | 232 SkString name; |
| 233 this->getFamilyName(&name); | 233 this->getFamilyName(&name); |
| 234 desc->setFamilyName(name.c_str()); | 234 desc->setFamilyName(name.c_str()); |
| 235 *isLocalStream = SkToBool(this->getLocalStream()); | 235 *isLocalStream = SkToBool(this->getLocalStream()); |
| 236 } | 236 } |
| OLD | NEW |