| Differences between
and this patch
- a/Source/WebCore/ChangeLog +12 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-09-07  Myles C. Maxfield  <mmaxfield@apple.com>
2
3
        [Cocoa] Improve performance of glyph advance metrics gathering
4
        https://bugs.webkit.org/show_bug.cgi?id=161119
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        No new tests (OOPS!).
9
10
        * platform/graphics/cocoa/FontCocoa.mm:
11
        (WebCore::Font::platformWidthForGlyph):
12
1
2016-09-06  Commit Queue  <commit-queue@webkit.org>
13
2016-09-06  Commit Queue  <commit-queue@webkit.org>
2
14
3
        Unreviewed, rolling out r205521, r205526, and r205532.
15
        Unreviewed, rolling out r205521, r205526, and r205532.
- a/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm -1 / +11 lines
Lines 596-601 FloatRect Font::platformBoundsForGlyph(Glyph glyph) const a/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm_sec1
596
    return boundingBox;
596
    return boundingBox;
597
}
597
}
598
598
599
#if !((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000))
599
static inline Optional<CGSize> advanceForColorBitmapFont(const FontPlatformData& platformData, Glyph glyph)
600
static inline Optional<CGSize> advanceForColorBitmapFont(const FontPlatformData& platformData, Glyph glyph)
600
{
601
{
601
    CTFontRef font = platformData.font();
602
    CTFontRef font = platformData.font();
Lines 617-632 static inline bool canUseFastGlyphAdvanceGetter(const FontPlatformData& platform a/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm_sec2
617
    }
618
    }
618
    return true;
619
    return true;
619
}
620
}
621
#endif
620
622
621
float Font::platformWidthForGlyph(Glyph glyph) const
623
float Font::platformWidthForGlyph(Glyph glyph) const
622
{
624
{
623
    CGSize advance = CGSizeZero;
625
    CGSize advance = CGSizeZero;
624
    bool horizontal = platformData().orientation() == Horizontal;
626
    bool horizontal = platformData().orientation() == Horizontal;
627
    CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
628
629
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
630
    if (platformData().size())
631
        CTFontGetUnsummedAdvancesForGlyphsAndStyle(m_platformData.ctFont(), horizontal || m_isBrokenIdeographFallback ? kCTFontOrientationHorizontal : kCTFontOrientationVertical, style, &glyph, &advance, 1);
632
633
#else
634
625
    bool populatedAdvance = false;
635
    bool populatedAdvance = false;
626
    if ((horizontal || m_isBrokenIdeographFallback) && canUseFastGlyphAdvanceGetter(this->platformData(), glyph, advance, populatedAdvance)) {
636
    if ((horizontal || m_isBrokenIdeographFallback) && canUseFastGlyphAdvanceGetter(this->platformData(), glyph, advance, populatedAdvance)) {
627
        float pointSize = platformData().size();
637
        float pointSize = platformData().size();
628
        CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
638
        CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
629
        CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
630
        if (!CGFontGetGlyphAdvancesForStyle(platformData().cgFont(), &m, style, &glyph, 1, &advance)) {
639
        if (!CGFontGetGlyphAdvancesForStyle(platformData().cgFont(), &m, style, &glyph, 1, &advance)) {
631
            RetainPtr<CFStringRef> fullName = adoptCF(CGFontCopyFullName(platformData().cgFont()));
640
            RetainPtr<CFStringRef> fullName = adoptCF(CGFontCopyFullName(platformData().cgFont()));
632
            LOG_ERROR("Unable to cache glyph widths for %@ %f", fullName.get(), pointSize);
641
            LOG_ERROR("Unable to cache glyph widths for %@ %f", fullName.get(), pointSize);
Lines 634-639 float Font::platformWidthForGlyph(Glyph glyph) const a/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm_sec3
634
        }
643
        }
635
    } else if (!populatedAdvance && platformData().size())
644
    } else if (!populatedAdvance && platformData().size())
636
        CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), horizontal ? kCTFontOrientationHorizontal : kCTFontOrientationVertical, &glyph, &advance, 1);
645
        CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), horizontal ? kCTFontOrientationHorizontal : kCTFontOrientationVertical, &glyph, &advance, 1);
646
#endif
637
647
638
    return advance.width + m_syntheticBoldOffset;
648
    return advance.width + m_syntheticBoldOffset;
639
}
649
}

Return to Bug 161119