Laying out a TextRun using an SVG font is O(n^2)
https://bugs.webkit.org/show_bug.cgi?id=136584
Reviewed by Andreas Kling.
PerformanceTests:
Time how long it takes to lay out and render some text using an SVG font.
* SVG/SVG-Text.html: Added.
* SVG/resources/graffiti.svg: Added.
Source/WebCore:
Caching the version of the run with normalized spaces leads to a 5x speedup on the
performance test this patch adds.
Note that SVGFontData::applySVGGlyphSelection() is still unnecesarrily O(n), so more
work can be done here. In particular, the call to collectGlyphsForString() can likely
be sped up.
No new correctness tests because there is no behavior change.
Performance Test: SVG/SVG-Text.html
* platform/graphics/Font.h:
(WebCore::Font::treatAsSpace): Make inline.
(WebCore::Font::treatAsZeroWidthSpace): Ditto.
(WebCore::Font::treatAsZeroWidthSpaceInComplexScript): Ditto.
* platform/graphics/SimpleFontData.h: Add String cache argument.
* platform/graphics/TextRun.h: Move member variables around for better packing.
(WebCore::TextRun::TextRun): Ditto.
* platform/graphics/WidthIterator.cpp: Add String cache argument.
(WebCore::WidthIterator::glyphDataForCharacter): Ditto.
(WebCore::WidthIterator::advanceInternal): Create String cache and pass it to
glyphDataForCharacter.
* platform/graphics/WidthIterator.h: Add String cache argument.
* rendering/svg/SVGTextRunRenderingContext.cpp: Ditto.
(WebCore::SVGTextRunRenderingContext::glyphDataForCharacter): Ditto.
* rendering/svg/SVGTextRunRenderingContext.h: Ditto.
* svg/SVGFontData.cpp:
(WebCore::SVGFontData::applySVGGlyphSelection): Call computeNormalizedSpaces
to consult with the cache.
(WebCore::computeNormalizedSpaces): Compute cached String value.
* svg/SVGFontData.h: Add String cache argument.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed