Changeset 58467 in webkit


Ignore:
Timestamp:
Apr 28, 2010 8:11:37 PM (14 years ago)
Author:
mitz@apple.com
Message:

More of <rdar://problem/7855777> REGRESSION: Memory usage increase caused by storing glyph bounds in GlyphMetricsMap
https://bugs.webkit.org/show_bug.cgi?id=37936

Reviewed by Adele Peterson.

Assigning zero width and empty bounds to the ZERO WIDTH SPACE glyph often allocates a width map
page and a bounds map page for the glyph, each of which pages contains 255 unused entries. Save
this space by not storing the zero width and empty bounds in the metrics maps.

  • platform/graphics/SimpleFontData.cpp:

(WebCore::SimpleFontData::SimpleFontData): Initialize m_zeroWidthSpaceGlyph.
(WebCore::SimpleFontData::platformGlyphInit): Set m_zeroWidthSpaceGlyph. Don’t create entries
for the ZERO WIDTH SPACE glyph in the width map and in the bounds map.

  • platform/graphics/SimpleFontData.h:

(WebCore::SimpleFontData::boundsForGlyph): Return empty bounds for the ZERO WIDTH SPACE glyph
without consulting the bounds map.
(WebCore::SimpleFontData::widthForGlyph): Return zero for the ZERO WIDTH SPACE glyph without
consulting the width map.

Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58466 r58467  
     12010-04-28  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Adele Peterson.
     4
     5        More of <rdar://problem/7855777> REGRESSION: Memory usage increase caused by storing glyph bounds in GlyphMetricsMap
     6        https://bugs.webkit.org/show_bug.cgi?id=37936
     7
     8        Assigning zero width and empty bounds to the ZERO WIDTH SPACE glyph often allocates a width map
     9        page and a bounds map page for the glyph, each of which pages contains 255 unused entries. Save
     10        this space by not storing the zero width and empty bounds in the metrics maps.
     11
     12        * platform/graphics/SimpleFontData.cpp:
     13        (WebCore::SimpleFontData::SimpleFontData): Initialize m_zeroWidthSpaceGlyph.
     14        (WebCore::SimpleFontData::platformGlyphInit): Set m_zeroWidthSpaceGlyph. Don’t create entries
     15        for the ZERO WIDTH SPACE glyph in the width map and in the bounds map.
     16        * platform/graphics/SimpleFontData.h:
     17        (WebCore::SimpleFontData::boundsForGlyph): Return empty bounds for the ZERO WIDTH SPACE glyph
     18        without consulting the bounds map.
     19        (WebCore::SimpleFontData::widthForGlyph): Return zero for the ZERO WIDTH SPACE glyph without
     20        consulting the width map.
     21
    1222010-04-28  Mark Rowe  <mrowe@apple.com>
    223
  • trunk/WebCore/platform/graphics/SimpleFontData.cpp

    r58192 r58467  
    9393        // FIXME: is there a way we can get the space glyph from the SVGGlyphIdentifier above?
    9494        m_spaceGlyph = 0;
     95        m_zeroWidthSpaceGlyph = 0;
    9596        determinePitch();
    9697        m_adjustedSpaceWidth = roundf(m_spaceWidth);
     
    137138        m_adjustedSpaceWidth = 0;
    138139        determinePitch();
     140        m_zeroWidthSpaceGlyph = 0;
    139141        m_missingGlyphData.fontData = this;
    140142        m_missingGlyphData.glyph = 0;
     
    156158    // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0,
    157159    // are mapped to the ZERO WIDTH SPACE glyph.
    158     Glyph zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
    159     if (zeroWidthSpaceGlyph) {
    160         if (zeroWidthSpaceGlyph != m_spaceGlyph) {
    161             m_glyphToWidthMap.setMetricsForGlyph(zeroWidthSpaceGlyph, 0);
    162             m_glyphToBoundsMap.setMetricsForGlyph(zeroWidthSpaceGlyph, FloatRect());
    163         } else
    164             LOG_ERROR("Font maps SPACE and ZERO WIDTH SPACE to the same glyph. Glyph width not overridden.");
     160    m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
     161    if (m_zeroWidthSpaceGlyph == m_spaceGlyph) {
     162        m_zeroWidthSpaceGlyph = 0;
     163        LOG_ERROR("Font maps SPACE and ZERO WIDTH SPACE to the same glyph. Glyph width will not be overridden.");
    165164    }
    166165
  • trunk/WebCore/platform/graphics/SimpleFontData.h

    r58192 r58467  
    201201    float m_adjustedSpaceWidth;
    202202
     203    Glyph m_zeroWidthSpaceGlyph;
     204
    203205    GlyphData m_missingGlyphData;
    204206
     
    244246ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const
    245247{
     248    if (glyph == m_zeroWidthSpaceGlyph && glyph)
     249        return FloatRect();
     250
    246251    FloatRect bounds = m_glyphToBoundsMap.metricsForGlyph(glyph);
    247252    if (bounds.width() != cGlyphSizeUnknown)
    248253        return bounds;
     254
    249255    bounds = platformBoundsForGlyph(glyph);
    250256    m_glyphToBoundsMap.setMetricsForGlyph(glyph, bounds);
     
    254260ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const
    255261{
     262    if (glyph == m_zeroWidthSpaceGlyph && glyph)
     263        return 0;
     264
    256265    float width = m_glyphToWidthMap.metricsForGlyph(glyph);
    257266    if (width != cGlyphSizeUnknown)
Note: See TracChangeset for help on using the changeset viewer.