<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205703] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205703">205703</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-09-09 01:33:44 -0700 (Fri, 09 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Cocoa] Improve performance of glyph advance metrics gathering
https://bugs.webkit.org/show_bug.cgi?id=161119
Reviewed by Simon Fraser.
Most of the glyphs in a GlyphPage are never read from. Therefore, we can get a performance boost
by not populating as many items in the GlyphPage. Because of the performance characteristics of
CTFontGetGlyphsForCharacters(), a better size for a GlyphPage is 16 items. This, coupled with
using CTFontGetUnsummedAdvancesForGlyphsAndStyle(), causes between a 0.01%-0.5% speedup on PLT.
No new tests because there is no behavior change.
* platform/graphics/Font.cpp:
(WebCore::Font::initCharWidths):
(WebCore::Font::platformGlyphInit):
(WebCore::createAndFillGlyphPage):
* platform/graphics/Font.h:
(WebCore::Font::widthForGlyph):
* platform/graphics/GlyphMetricsMap.h:
* platform/graphics/GlyphPage.h:
* platform/graphics/cocoa/FontCocoa.mm:
* platform/spi/cocoa/CoreTextSPI.h:
(WebCore::Font::platformWidthForGlyph):
(WebCore::canUseFastGlyphAdvanceGetter): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontcpp">trunk/Source/WebCore/platform/graphics/Font.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFonth">trunk/Source/WebCore/platform/graphics/Font.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCascadeFontscpp">trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGlyphMetricsMaph">trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGlyphPageh">trunk/Source/WebCore/platform/graphics/GlyphPage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformspicocoaCoreTextSPIh">trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/ChangeLog        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-09-09 Myles C. Maxfield <mmaxfield@apple.com>
+
+ [Cocoa] Improve performance of glyph advance metrics gathering
+ https://bugs.webkit.org/show_bug.cgi?id=161119
+
+ Reviewed by Simon Fraser.
+
+ Most of the glyphs in a GlyphPage are never read from. Therefore, we can get a performance boost
+ by not populating as many items in the GlyphPage. Because of the performance characteristics of
+ CTFontGetGlyphsForCharacters(), a better size for a GlyphPage is 16 items. This, coupled with
+ using CTFontGetUnsummedAdvancesForGlyphsAndStyle(), causes between a 0.01%-0.5% speedup on PLT.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::initCharWidths):
+ (WebCore::Font::platformGlyphInit):
+ (WebCore::createAndFillGlyphPage):
+ * platform/graphics/Font.h:
+ (WebCore::Font::widthForGlyph):
+ * platform/graphics/GlyphMetricsMap.h:
+ * platform/graphics/GlyphPage.h:
+ * platform/graphics/cocoa/FontCocoa.mm:
+ * platform/spi/cocoa/CoreTextSPI.h:
+ (WebCore::Font::platformWidthForGlyph):
+ (WebCore::canUseFastGlyphAdvanceGetter): Deleted.
+
</ins><span class="cx"> 2016-09-09 Antti Koivisto <antti@apple.com>
</span><span class="cx">
</span><span class="cx"> v3: WebContent crash due to RELEASE_ASSERT in WebCore: WebCore::StyleResolver::styleForElement
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.cpp        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -81,12 +81,11 @@
</span><span class="cx"> // Estimates of avgCharWidth and maxCharWidth for platforms that don't support accessing these values from the font.
</span><span class="cx"> void Font::initCharWidths()
</span><span class="cx"> {
</span><del>- auto* glyphPageZero = glyphPage(0);
</del><ins>+ auto* glyphPageZero = glyphPage(GlyphPage::pageNumberForCodePoint('0'));
</ins><span class="cx">
</span><span class="cx"> // Treat the width of a '0' as the avgCharWidth.
</span><span class="cx"> if (m_avgCharWidth <= 0.f && glyphPageZero) {
</span><del>- static const UChar32 digitZeroChar = '0';
- Glyph digitZeroGlyph = glyphPageZero->glyphDataForCharacter(digitZeroChar).glyph;
</del><ins>+ Glyph digitZeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
</ins><span class="cx"> if (digitZeroGlyph)
</span><span class="cx"> m_avgCharWidth = widthForGlyph(digitZeroGlyph);
</span><span class="cx"> }
</span><span class="lines">@@ -102,22 +101,23 @@
</span><span class="cx"> void Font::platformGlyphInit()
</span><span class="cx"> {
</span><span class="cx"> auto* glyphPageZero = glyphPage(0);
</span><del>- if (!glyphPageZero) {
- determinePitch();
- return;
- }
</del><ins>+ auto* glyphPageCharacterZero = glyphPage(GlyphPage::pageNumberForCodePoint('0'));
+ auto* glyphPageSpace = glyphPage(GlyphPage::pageNumberForCodePoint(space));
</ins><span class="cx">
</span><span class="cx"> // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0,
</span><span class="cx"> // are mapped to the ZERO WIDTH SPACE glyph.
</span><del>- m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
</del><ins>+ if (glyphPageZero)
+ m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
</ins><span class="cx">
</span><span class="cx"> // Nasty hack to determine if we should round or ceil space widths.
</span><span class="cx"> // If the font is monospace or fake monospace we ceil to ensure that
</span><span class="cx"> // every character and the space are the same width. Otherwise we round.
</span><del>- m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
</del><ins>+ if (glyphPageSpace)
+ m_spaceGlyph = glyphPageSpace->glyphDataForCharacter(space).glyph;
</ins><span class="cx"> float width = widthForGlyph(m_spaceGlyph);
</span><span class="cx"> m_spaceWidth = width;
</span><del>- m_zeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
</del><ins>+ if (glyphPageCharacterZero)
+ m_zeroGlyph = glyphPageCharacterZero->glyphDataForCharacter('0').glyph;
</ins><span class="cx"> m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph));
</span><span class="cx"> determinePitch();
</span><span class="cx"> m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
</span><span class="lines">@@ -152,56 +152,59 @@
</span><span class="cx"> // FIXME: Times New Roman contains Arabic glyphs, but Core Text doesn't know how to shape them. See <rdar://problem/9823975>.
</span><span class="cx"> // Once we have the fix for <rdar://problem/9823975> then remove this code together with Font::shouldNotBeUsedForArabic()
</span><span class="cx"> // in <rdar://problem/12096835>.
</span><del>- if (pageNumber == 6 && font.shouldNotBeUsedForArabic())
</del><ins>+ if (GlyphPage::pageNumberIsUsedForArabic(pageNumber) && font.shouldNotBeUsedForArabic())
</ins><span class="cx"> return nullptr;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- unsigned start = pageNumber * GlyphPage::size;
- UChar buffer[GlyphPage::size * 2 + 2];
</del><ins>+ unsigned glyphPageSize = GlyphPage::sizeForPageNumber(pageNumber);
+
+ unsigned start = GlyphPage::startingCodePointInPageNumber(pageNumber);
+ unsigned end = start + glyphPageSize;
+ Vector<UChar> buffer(glyphPageSize * 2 + 2);
</ins><span class="cx"> unsigned bufferLength;
</span><span class="cx"> // Fill in a buffer with the entire "page" of characters that we want to look up glyphs for.
</span><span class="cx"> if (U_IS_BMP(start)) {
</span><del>- bufferLength = GlyphPage::size;
- for (unsigned i = 0; i < GlyphPage::size; i++)
</del><ins>+ bufferLength = glyphPageSize;
+ for (unsigned i = 0; i < bufferLength; i++)
</ins><span class="cx"> buffer[i] = start + i;
</span><span class="cx">
</span><del>- if (!start) {
- // Control characters must not render at all.
- for (unsigned i = 0; i < 0x20; ++i)
- buffer[i] = zeroWidthSpace;
- for (unsigned i = 0x7F; i < 0xA0; i++)
- buffer[i] = zeroWidthSpace;
- buffer[softHyphen] = zeroWidthSpace;
</del><ins>+ // Code points 0x0 - 0x20 and 0x7F - 0xA0 are control character and shouldn't render. Map them to ZERO WIDTH SPACE.
+ auto overwriteCodePoints = [&](unsigned minimum, unsigned maximum, UChar newCodePoint) {
+ unsigned begin = std::max(start, minimum);
+ unsigned complete = std::min(end, maximum);
+ for (unsigned i = begin; i < complete; ++i)
+ buffer[i - start] = newCodePoint;
+ };
</ins><span class="cx">
</span><del>- // \n, \t, and nonbreaking space must render as a space.
- buffer[(int)'\n'] = ' ';
- buffer[(int)'\t'] = ' ';
- buffer[noBreakSpace] = ' ';
- } else if (start == (leftToRightMark & ~(GlyphPage::size - 1))) {
- // LRM, RLM, LRE, RLE, ZWNJ, ZWJ, and PDF must not render at all.
- buffer[leftToRightMark - start] = zeroWidthSpace;
- buffer[rightToLeftMark - start] = zeroWidthSpace;
- buffer[leftToRightEmbed - start] = zeroWidthSpace;
- buffer[rightToLeftEmbed - start] = zeroWidthSpace;
- buffer[leftToRightOverride - start] = zeroWidthSpace;
- buffer[rightToLeftOverride - start] = zeroWidthSpace;
- buffer[leftToRightIsolate - start] = zeroWidthSpace;
- buffer[rightToLeftIsolate - start] = zeroWidthSpace;
- buffer[zeroWidthNonJoiner - start] = zeroWidthSpace;
- buffer[zeroWidthJoiner - start] = zeroWidthSpace;
- buffer[popDirectionalFormatting - start] = zeroWidthSpace;
- buffer[popDirectionalIsolate - start] = zeroWidthSpace;
- buffer[firstStrongIsolate - start] = zeroWidthSpace;
- } else if (start == (objectReplacementCharacter & ~(GlyphPage::size - 1))) {
- // Object replacement character must not render at all.
- buffer[objectReplacementCharacter - start] = zeroWidthSpace;
- } else if (start == (zeroWidthNoBreakSpace & ~(GlyphPage::size - 1))) {
- // ZWNBS/BOM must not render at all.
- buffer[zeroWidthNoBreakSpace - start] = zeroWidthSpace;
- }
</del><ins>+ auto overwriteCodePoint = [&](UChar codePoint, UChar newCodePoint) {
+ if (codePoint >= start && codePoint < end)
+ buffer[codePoint - start] = newCodePoint;
+ };
+
+ overwriteCodePoints(0x0, 0x20, zeroWidthSpace);
+ overwriteCodePoints(0x7F, 0xA0, zeroWidthSpace);
+ overwriteCodePoint(softHyphen, zeroWidthSpace);
+ overwriteCodePoint('\n', space);
+ overwriteCodePoint('\t', space);
+ overwriteCodePoint(noBreakSpace, space);
+ overwriteCodePoint(leftToRightMark, zeroWidthSpace);
+ overwriteCodePoint(rightToLeftMark, zeroWidthSpace);
+ overwriteCodePoint(leftToRightEmbed, zeroWidthSpace);
+ overwriteCodePoint(rightToLeftEmbed, zeroWidthSpace);
+ overwriteCodePoint(leftToRightOverride, zeroWidthSpace);
+ overwriteCodePoint(rightToLeftOverride, zeroWidthSpace);
+ overwriteCodePoint(leftToRightIsolate, zeroWidthSpace);
+ overwriteCodePoint(rightToLeftIsolate, zeroWidthSpace);
+ overwriteCodePoint(zeroWidthNonJoiner, zeroWidthSpace);
+ overwriteCodePoint(zeroWidthJoiner, zeroWidthSpace);
+ overwriteCodePoint(popDirectionalFormatting, zeroWidthSpace);
+ overwriteCodePoint(popDirectionalIsolate, zeroWidthSpace);
+ overwriteCodePoint(firstStrongIsolate, zeroWidthSpace);
+ overwriteCodePoint(objectReplacementCharacter, zeroWidthSpace);
+ overwriteCodePoint(zeroWidthNoBreakSpace, zeroWidthSpace);
</ins><span class="cx"> } else {
</span><del>- bufferLength = GlyphPage::size * 2;
- for (unsigned i = 0; i < GlyphPage::size; i++) {
</del><ins>+ bufferLength = glyphPageSize * 2;
+ for (unsigned i = 0; i < glyphPageSize; i++) {
</ins><span class="cx"> int c = i + start;
</span><span class="cx"> buffer[i * 2] = U16_LEAD(c);
</span><span class="cx"> buffer[i * 2 + 1] = U16_TRAIL(c);
</span><span class="lines">@@ -215,7 +218,7 @@
</span><span class="cx"> // for only 128 out of 256 characters.
</span><span class="cx"> Ref<GlyphPage> glyphPage = GlyphPage::create(font);
</span><span class="cx">
</span><del>- bool haveGlyphs = fillGlyphPage(glyphPage, buffer, bufferLength, font);
</del><ins>+ bool haveGlyphs = fillGlyphPage(glyphPage, buffer.data(), bufferLength, font);
</ins><span class="cx"> if (!haveGlyphs)
</span><span class="cx"> return nullptr;
</span><span class="cx">
</span><span class="lines">@@ -238,7 +241,7 @@
</span><span class="cx">
</span><span class="cx"> Glyph Font::glyphForCharacter(UChar32 character) const
</span><span class="cx"> {
</span><del>- auto* page = glyphPage(character / GlyphPage::size);
</del><ins>+ auto* page = glyphPage(GlyphPage::pageNumberForCodePoint(character));
</ins><span class="cx"> if (!page)
</span><span class="cx"> return 0;
</span><span class="cx"> return page->glyphForCharacter(character);
</span><span class="lines">@@ -246,7 +249,7 @@
</span><span class="cx">
</span><span class="cx"> GlyphData Font::glyphDataForCharacter(UChar32 character) const
</span><span class="cx"> {
</span><del>- auto* page = glyphPage(character / GlyphPage::size);
</del><ins>+ auto* page = glyphPage(GlyphPage::pageNumberForCodePoint(character));
</ins><span class="cx"> if (!page)
</span><span class="cx"> return GlyphData();
</span><span class="cx"> return page->glyphDataForCharacter(character);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.h (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.h        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/platform/graphics/Font.h        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -337,13 +337,13 @@
</span><span class="cx"> return width;
</span><span class="cx">
</span><span class="cx"> #if ENABLE(OPENTYPE_VERTICAL)
</span><del>- if (m_verticalData)
</del><ins>+ if (m_verticalData) {
</ins><span class="cx"> #if USE(CG) || USE(CAIRO)
</span><span class="cx"> width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset;
</span><span class="cx"> #else
</span><span class="cx"> width = m_verticalData->advanceHeight(this, glyph);
</span><span class="cx"> #endif
</span><del>- else
</del><ins>+ } else
</ins><span class="cx"> #endif
</span><span class="cx"> width = platformWidthForGlyph(glyph);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCascadeFontscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">
</span><span class="cx"> GlyphData glyphDataForCharacter(UChar32 c) const
</span><span class="cx"> {
</span><del>- unsigned index = GlyphPage::indexForCharacter(c);
</del><ins>+ unsigned index = GlyphPage::indexForCodePoint(c);
</ins><span class="cx"> ASSERT_WITH_SECURITY_IMPLICATION(index < GlyphPage::size);
</span><span class="cx"> return { m_glyphs[index], m_fonts[index] };
</span><span class="cx"> }
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">
</span><span class="cx"> void setGlyphDataForCharacter(UChar32 c, GlyphData glyphData)
</span><span class="cx"> {
</span><del>- setGlyphDataForIndex(GlyphPage::indexForCharacter(c), glyphData);
</del><ins>+ setGlyphDataForIndex(GlyphPage::indexForCodePoint(c), glyphData);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -428,7 +428,7 @@
</span><span class="cx"> if (variant != NormalVariant)
</span><span class="cx"> return glyphDataForVariant(c, description, variant, 0);
</span><span class="cx">
</span><del>- const unsigned pageNumber = c / GlyphPage::size;
</del><ins>+ const unsigned pageNumber = GlyphPage::pageNumberForCodePoint(c);
</ins><span class="cx">
</span><span class="cx"> auto& cacheEntry = pageNumber ? m_cachedPages.add(pageNumber, GlyphPageCacheEntry()).iterator->value : m_cachedPageZero;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGlyphMetricsMaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx"> class GlyphMetricsPage {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>- static const size_t size = 256; // Usually covers Latin-1 in a single page.
</del><ins>+ static const size_t size = 16;
</ins><span class="cx">
</span><span class="cx"> GlyphMetricsPage() = default;
</span><span class="cx"> explicit GlyphMetricsPage(const T& initialValue)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGlyphPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GlyphPage.h (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GlyphPage.h        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/platform/graphics/GlyphPage.h        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx">
</span><span class="cx"> // A GlyphPage contains a fixed-size set of GlyphData mappings for a contiguous
</span><span class="cx"> // range of characters in the Unicode code space. GlyphPages are indexed
</span><del>-// starting from 0 and incrementing for each 256 glyphs.
</del><ins>+// starting from 0 and incrementing for each "size" number of glyphs.
</ins><span class="cx"> class GlyphPage : public RefCounted<GlyphPage> {
</span><span class="cx"> public:
</span><span class="cx"> static Ref<GlyphPage> create(const Font& font)
</span><span class="lines">@@ -72,17 +72,22 @@
</span><span class="cx">
</span><span class="cx"> static unsigned count() { return s_count; }
</span><span class="cx">
</span><del>- static const size_t size = 256; // Covers Latin-1 in a single page.
- static unsigned indexForCharacter(UChar32 c) { return c % GlyphPage::size; }
</del><ins>+ static const unsigned size = 16;
</ins><span class="cx">
</span><ins>+ static unsigned sizeForPageNumber(unsigned) { return 16; }
+ static unsigned indexForCodePoint(UChar32 c) { return c % size; }
+ static unsigned pageNumberForCodePoint(UChar32 c) { return c / size; }
+ static UChar32 startingCodePointInPageNumber(unsigned pageNumber) { return pageNumber * size; }
+ static bool pageNumberIsUsedForArabic(unsigned pageNumber) { return startingCodePointInPageNumber(pageNumber) >= 0x600 && startingCodePointInPageNumber(pageNumber) + sizeForPageNumber(pageNumber) < 0x700; }
+
</ins><span class="cx"> GlyphData glyphDataForCharacter(UChar32 c) const
</span><span class="cx"> {
</span><del>- return glyphDataForIndex(indexForCharacter(c));
</del><ins>+ return glyphDataForIndex(indexForCodePoint(c));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Glyph glyphForCharacter(UChar32 c) const
</span><span class="cx"> {
</span><del>- return glyphForIndex(indexForCharacter(c));
</del><ins>+ return glyphForIndex(indexForCodePoint(c));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> GlyphData glyphDataForIndex(unsigned index) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -596,6 +596,7 @@
</span><span class="cx"> return boundingBox;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if !((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000))
</ins><span class="cx"> static inline Optional<CGSize> advanceForColorBitmapFont(const FontPlatformData& platformData, Glyph glyph)
</span><span class="cx"> {
</span><span class="cx"> CTFontRef font = platformData.font();
</span><span class="lines">@@ -617,16 +618,30 @@
</span><span class="cx"> }
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx">
</span><span class="cx"> float Font::platformWidthForGlyph(Glyph glyph) const
</span><span class="cx"> {
</span><span class="cx"> CGSize advance = CGSizeZero;
</span><span class="cx"> bool horizontal = platformData().orientation() == Horizontal;
</span><ins>+ CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
+ if (platformData().size()) {
+ CTFontOrientation orientation = horizontal || m_isBrokenIdeographFallback ? kCTFontOrientationHorizontal : kCTFontOrientationVertical;
+ // FIXME: Remove this special-casing when <rdar://problem/28197291> is fixed.
+ if (CTFontIsAppleColorEmoji(m_platformData.ctFont()))
+ CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), orientation, &glyph, &advance, 1);
+ else
+ CTFontGetUnsummedAdvancesForGlyphsAndStyle(m_platformData.ctFont(), orientation, style, &glyph, &advance, 1);
+ }
+
+#else
+
</ins><span class="cx"> bool populatedAdvance = false;
</span><span class="cx"> if ((horizontal || m_isBrokenIdeographFallback) && canUseFastGlyphAdvanceGetter(this->platformData(), glyph, advance, populatedAdvance)) {
</span><span class="cx"> float pointSize = platformData().size();
</span><span class="cx"> CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
</span><del>- CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
</del><span class="cx"> if (!CGFontGetGlyphAdvancesForStyle(platformData().cgFont(), &m, style, &glyph, 1, &advance)) {
</span><span class="cx"> RetainPtr<CFStringRef> fullName = adoptCF(CGFontCopyFullName(platformData().cgFont()));
</span><span class="cx"> LOG_ERROR("Unable to cache glyph widths for %@ %f", fullName.get(), pointSize);
</span><span class="lines">@@ -634,6 +649,7 @@
</span><span class="cx"> }
</span><span class="cx"> } else if (!populatedAdvance && platformData().size())
</span><span class="cx"> CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), horizontal ? kCTFontOrientationHorizontal : kCTFontOrientationVertical, &glyph, &advance, 1);
</span><ins>+#endif
</ins><span class="cx">
</span><span class="cx"> return advance.width + m_syntheticBoldOffset;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicocoaCoreTextSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (205702 => 205703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h        2016-09-09 08:15:29 UTC (rev 205702)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h        2016-09-09 08:33:44 UTC (rev 205703)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> void CTRunGetBaseAdvancesAndOrigins(CTRunRef, CFRange, CGSize baseAdvances[], CGPoint origins[]);
</span><span class="cx"> CTTypesetterRef CTTypesetterCreateWithUniCharProviderAndOptions(CTUniCharProviderCallback provide, CTUniCharDisposeCallback dispose, void* refCon, CFDictionaryRef options);
</span><span class="cx"> bool CTFontGetVerticalGlyphsForCharacters(CTFontRef, const UniChar characters[], CGGlyph glyphs[], CFIndex count);
</span><ins>+void CTFontGetUnsummedAdvancesForGlyphsAndStyle(CTFontRef, CTFontOrientation, CGFontRenderingStyle, const CGGlyph[], CGSize advances[], CFIndex count);
</ins><span class="cx">
</span><span class="cx"> CTFontDescriptorRef CTFontDescriptorCreateForUIType(CTFontUIFontType, CGFloat size, CFStringRef language);
</span><span class="cx"> CTFontDescriptorRef CTFontDescriptorCreateWithTextStyle(CFStringRef style, CFStringRef size, CFStringRef language);
</span></span></pre>
</div>
</div>
</body>
</html>