Optimize GlyphPage for case where all glyphs are available in the same font.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 17 Feb 2013 08:17:42 +0000 (08:17 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 17 Feb 2013 08:17:42 +0000 (08:17 +0000)
commitbd183587095cab67b8f70c4d3fd1025968b7c4f3
tree3d4cb9710fc2479faba4c20a060cbb426ccceab5
parentea17bd064436f7b63d286232e6e20c5609d21c9c
Optimize GlyphPage for case where all glyphs are available in the same font.
<http://webkit.org/b/108835>
<rdar://problem/13157042>

Reviewed by Antti Koivisto.

Let GlyphPage begin optimistically assuming that all its glyphs will be represented in
the same SimpleFontData*. In this (very common) case, only keep a single SimpleFontData*.

If glyphs from multiple fonts are mixed in one page, an array of per-glyph SimpleFontData*
is allocated transparently.

This was landed before with some bogus branch prediction hints and didn't fare well on
page cyclers (intl2 specifically.) These have been removed this time around, and will
hopefully be regression-free.

4.98 MB progression on Membuster3.

* platform/graphics/GlyphPageTreeNode.cpp:
(WebCore::GlyphPageTreeNode::initializePage):
* platform/graphics/GlyphPage.h:
(WebCore::GlyphPage::createUninitialized):
(WebCore::GlyphPage::createZeroedSystemFallbackPage):
(WebCore::GlyphPage::createCopiedSystemFallbackPage):

    There are now three ways of constructing a GlyphPage, two of them are only used for
    creating system fallback pages.

(WebCore::GlyphPage::setGlyphDataForIndex):

    Hold off creating a SimpleFontData* array until we're sure there are two different
    SimpleFontData* backing the glyphs in this page.
    We don't store font data for glyph #0, instead we let the getters always return null for it.

(WebCore::GlyphPage::~GlyphPage):

    Free the SimpleFontData* array if needed.

(WebCore::GlyphPage::glyphDataForCharacter):
(WebCore::GlyphPage::glyphDataForIndex):
(WebCore::GlyphPage::fontDataForCharacter):

    The font data for glyph #0 is always a null pointer now.

(WebCore::GlyphPage::clearForFontData):

    Updated for new storage format.

* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):

    Fix bug where non-zero glyph was temporarily associated with null font data,
    which triggered the new assertion in setGlyphDataForIndex().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143125 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GlyphPage.h
Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp