diff options
author | Greg Daniel <egdaniel@google.com> | 2018-05-09 15:35:54 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-09 15:36:06 +0000 |
commit | 97c1108607584b6050a6880d6ce22846e4913a92 (patch) | |
tree | e6cb5bfa22fdd2fba53c9cd49d3beed28fff686b /src/ports/SkFontHost_mac.cpp | |
parent | 2ed5f69da6f101e60a3cf49c0767212b563552f3 (diff) |
Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode"
This reverts commit 1c2bcd8b14e029a70e88b1e81acd29553cab0d1c.
Reason for revert: breaking chrome roll
Original change's description:
> SkAdvancedTypefaceMetrics: factor out GlyphToUnicode
>
> Change-Id: Iedce8c1ea2c405d5ab64ccac353970d5cd2b9d63
> Reviewed-on: https://skia-review.googlesource.com/126507
> Commit-Queue: Hal Canary <halcanary@google.com>
> Reviewed-by: Ben Wagner <bungeman@google.com>
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: Ib1ff8484ffd09cdb88d461ac00745aa32c191124
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/127000
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/ports/SkFontHost_mac.cpp')
-rw-r--r-- | src/ports/SkFontHost_mac.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index 3cc51d43f6..8047c4352f 100644 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -719,7 +719,6 @@ protected: const SkDescriptor*) const override; void onFilterRec(SkScalerContextRec*) const override; void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; - void getGlyphToUnicodeMap(SkUnichar*) const override; std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], int glyphCount) const override; @@ -1606,7 +1605,9 @@ static sk_sp<SkTypeface> create_from_dataProvider(UniqueCFRef<CGDataProviderRef> // Iterate through the font in this case. The existing caller caches the result, // so the performance impact isn't too bad. static void populate_glyph_to_unicode_slow(CTFontRef ctFont, CFIndex glyphCount, - SkUnichar* out) { + SkTDArray<SkUnichar>* glyphToUnicode) { + glyphToUnicode->setCount(SkToInt(glyphCount)); + SkUnichar* out = glyphToUnicode->begin(); sk_bzero(out, glyphCount * sizeof(SkUnichar)); UniChar unichar = 0; while (glyphCount > 0) { @@ -1627,8 +1628,7 @@ static void populate_glyph_to_unicode_slow(CTFontRef ctFont, CFIndex glyphCount, // Unicode code points that require conjugate pairs in utf16 are not // supported. static void populate_glyph_to_unicode(CTFontRef ctFont, CFIndex glyphCount, - SkUnichar* glyphToUnicode) { - sk_bzero(glyphToUnicode, sizeof(SkUnichar) * glyphCount); + SkTDArray<SkUnichar>* glyphToUnicode) { UniqueCFRef<CFCharacterSetRef> charSet(CTFontCopyCharacterSet(ctFont)); if (!charSet) { populate_glyph_to_unicode_slow(ctFont, glyphCount, glyphToUnicode); @@ -1651,7 +1651,9 @@ static void populate_glyph_to_unicode(CTFontRef ctFont, CFIndex glyphCount, length = 8192; } const UInt8* bits = CFDataGetBytePtr(bitmap.get()); - sk_bzero(glyphToUnicode, glyphCount * sizeof(SkUnichar)); + glyphToUnicode->setCount(SkToInt(glyphCount)); + SkUnichar* out = glyphToUnicode->begin(); + sk_bzero(out, glyphCount * sizeof(SkUnichar)); for (int i = 0; i < length; i++) { int mask = bits[i]; if (!mask) { @@ -1661,7 +1663,7 @@ static void populate_glyph_to_unicode(CTFontRef ctFont, CFIndex glyphCount, CGGlyph glyph; UniChar unichar = static_cast<UniChar>((i << 3) + j); if (mask & (1 << j) && CTFontGetGlyphsForCharacters(ctFont, &unichar, &glyph, 1)) { - glyphToUnicode[glyph] = unichar; + out[glyph] = unichar; } } } @@ -1679,14 +1681,6 @@ static void CFStringToSkString(CFStringRef src, SkString* dst) { dst->resize(strlen(dst->c_str())); } -void SkTypeface_Mac::getGlyphToUnicodeMap(SkUnichar* dstArray) const { - AUTO_CG_LOCK(); - UniqueCFRef<CTFontRef> ctFont = - ctfont_create_exact_copy(fFontRef.get(), CTFontGetUnitsPerEm(fFontRef.get()), nullptr); - CFIndex glyphCount = CTFontGetGlyphCount(ctFont.get()); - populate_glyph_to_unicode(ctFont.get(), glyphCount, dstArray); -} - std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_Mac::onGetAdvancedMetrics() const { AUTO_CG_LOCK(); @@ -1716,6 +1710,10 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_Mac::onGetAdvancedMetrics( } } + CFIndex glyphCount = CTFontGetGlyphCount(ctFont.get()); + + populate_glyph_to_unicode(ctFont.get(), glyphCount, &info->fGlyphToUnicode); + SkOTTableOS2_V4::Type fsType; if (sizeof(fsType) == this->getTableData(SkTEndian_SwapBE32(SkOTTableOS2::TAG), offsetof(SkOTTableOS2_V4, fsType), |