Cache glyph widths to GlyphPages
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Mar 2015 01:10:53 +0000 (01:10 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Mar 2015 01:10:53 +0000 (01:10 +0000)
commit869418a1bed1ae919bf4441fd8fdf2d16f45ef31
tree16d098f597804fec1ccf9966158103fa1a9d2a64
parent828d5601fd5da5b14aa4ab98ce4a579301796145
Cache glyph widths to GlyphPages
https://bugs.webkit.org/show_bug.cgi?id=142028

Reviewed by Andreas Kling.

Currently we have a separate cache in Font for glyph widths. In practice we always need
the widths so we can just cache them in GlyphPages. This simplifies the code and removes
a per-character hash lookup from WidthIterator.

* platform/graphics/Font.cpp:
(WebCore::Font::Font):
(WebCore::Font::initCharWidths):
(WebCore::Font::platformGlyphInit):
(WebCore::createAndFillGlyphPage):
(WebCore::Font::computeWidthForGlyph):

    Rename to make it clear this doesn't cache.

(WebCore::GlyphPage::setGlyphDataForIndex):

    Initialize the width.
    This could go to GlyphPage.cpp if we had one.

* platform/graphics/Font.h:
(WebCore::Font::glyphZeroWidth):
(WebCore::Font::isZeroWidthSpaceGlyph):
(WebCore::Font::zeroGlyph): Deleted.
(WebCore::Font::setZeroGlyph): Deleted.
(WebCore::Font::widthForGlyph): Deleted.
* platform/graphics/FontCascade.cpp:
(WebCore::offsetToMiddleOfGlyph):
* platform/graphics/FontCascadeFonts.cpp:
(WebCore::FontCascadeFonts::glyphDataForCharacter):
* platform/graphics/GlyphPage.h:
(WebCore::GlyphData::GlyphData):

    Return width too as part of GlyphData.

(WebCore::GlyphPage::glyphDataForIndex):
(WebCore::GlyphPage::setGlyphDataForCharacter):
(WebCore::GlyphPage::setGlyphDataForIndex):
(WebCore::GlyphPage::GlyphPage):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::advanceInternal):

    No need to lookup width separately now.

* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::advanceForGlyph):
* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::missingGlyphForFont):
* svg/SVGFontData.cpp:
(WebCore::SVGFontData::initializeFont):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181492 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/FontCascade.cpp
Source/WebCore/platform/graphics/FontCascadeFonts.cpp
Source/WebCore/platform/graphics/GlyphPage.h
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
Source/WebCore/svg/SVGFontData.cpp