| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkDataTable.h" | 8 #include "SkDataTable.h" |
| 9 #include "SkFixed.h" | 9 #include "SkFixed.h" |
| 10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 *sizes.append() = strlen(familyName) + 1; | 557 *sizes.append() = strlen(familyName) + 1; |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 } | 561 } |
| 562 | 562 |
| 563 return SkDataTable::NewCopyArrays((void const *const *)names.begin(), | 563 return SkDataTable::NewCopyArrays((void const *const *)names.begin(), |
| 564 sizes.begin(), names.count()); | 564 sizes.begin(), names.count()); |
| 565 } | 565 } |
| 566 | 566 |
| 567 static bool FindByFcPattern(SkTypeface* cached, const SkFontStyle&, void* ct
x) { | 567 static bool FindByFcPattern(SkTypeface* cached, void* ctx) { |
| 568 SkTypeface_fontconfig* cshFace = static_cast<SkTypeface_fontconfig*>(cac
hed); | 568 SkTypeface_fontconfig* cshFace = static_cast<SkTypeface_fontconfig*>(cac
hed); |
| 569 FcPattern* ctxPattern = static_cast<FcPattern*>(ctx); | 569 FcPattern* ctxPattern = static_cast<FcPattern*>(ctx); |
| 570 return FcTrue == FcPatternEqual(cshFace->fPattern, ctxPattern); | 570 return FcTrue == FcPatternEqual(cshFace->fPattern, ctxPattern); |
| 571 } | 571 } |
| 572 | 572 |
| 573 mutable SkMutex fTFCacheMutex; | 573 mutable SkMutex fTFCacheMutex; |
| 574 mutable SkTypefaceCache fTFCache; | 574 mutable SkTypefaceCache fTFCache; |
| 575 /** Creates a typeface using a typeface cache. | 575 /** Creates a typeface using a typeface cache. |
| 576 * @param pattern a complete pattern from FcFontRenderPrepare. | 576 * @param pattern a complete pattern from FcFontRenderPrepare. |
| 577 */ | 577 */ |
| 578 SkTypeface* createTypefaceFromFcPattern(FcPattern* pattern) const { | 578 SkTypeface* createTypefaceFromFcPattern(FcPattern* pattern) const { |
| 579 FCLocker::AssertHeld(); | 579 FCLocker::AssertHeld(); |
| 580 SkAutoMutexAcquire ama(fTFCacheMutex); | 580 SkAutoMutexAcquire ama(fTFCacheMutex); |
| 581 SkTypeface* face = fTFCache.findByProcAndRef(FindByFcPattern, pattern); | 581 SkTypeface* face = fTFCache.findByProcAndRef(FindByFcPattern, pattern); |
| 582 if (nullptr == face) { | 582 if (nullptr == face) { |
| 583 FcPatternReference(pattern); | 583 FcPatternReference(pattern); |
| 584 face = SkTypeface_fontconfig::Create(pattern); | 584 face = SkTypeface_fontconfig::Create(pattern); |
| 585 if (face) { | 585 if (face) { |
| 586 fTFCache.add(face, SkFontStyle()); | 586 fTFCache.add(face); |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 return face; | 589 return face; |
| 590 } | 590 } |
| 591 | 591 |
| 592 public: | 592 public: |
| 593 /** Takes control of the reference to 'config'. */ | 593 /** Takes control of the reference to 'config'. */ |
| 594 explicit SkFontMgr_fontconfig(FcConfig* config) | 594 explicit SkFontMgr_fontconfig(FcConfig* config) |
| 595 : fFC(config ? config : FcInitLoadConfigAndFonts()) | 595 : fFC(config ? config : FcInitLoadConfigAndFonts()) |
| 596 , fFamilyNames(GetFamilyNames(fFC)) { } | 596 , fFamilyNames(GetFamilyNames(fFC)) { } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 return typeface.release(); | 880 return typeface.release(); |
| 881 } | 881 } |
| 882 | 882 |
| 883 return this->matchFamilyStyle(nullptr, style); | 883 return this->matchFamilyStyle(nullptr, style); |
| 884 } | 884 } |
| 885 }; | 885 }; |
| 886 | 886 |
| 887 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { | 887 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { |
| 888 return new SkFontMgr_fontconfig(fc); | 888 return new SkFontMgr_fontconfig(fc); |
| 889 } | 889 } |
| OLD | NEW |