Changeset 90041 in webkit


Ignore:
Timestamp:
Jun 29, 2011 2:03:13 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-29 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[Freetype] Many tests report ERROR: Failed to get glyph page zero.
https://bugs.webkit.org/show_bug.cgi?id=63498

Instead of conditionally instantiating the m_scaledFont member of FontPlatformData,
always instantiate it. For times when the size is 0 and the instantiation would lead
to a Cairo error, we use size 1 and just make operations which would fail conditional
on the m_size > 0.

No new tests. This change is covered by existing tests. We should
observe no errors on the bots after landing.

  • platform/graphics/cairo/FontCairo.cpp: (WebCore::Font::drawGlyphs): Instead of looking at whether or not there is a scaled font to determine whether to draw, just look at the size.
  • platform/graphics/freetype/FontPlatformData.h: Remove the m_font member.
  • platform/graphics/freetype/FontPlatformDataFreeType.cpp: Always instantiate a scaled font member and remove references to m_font. If we are instantiating a scaled font for a 0 size font, instantiate a size 1 font, so that we can still use Cairo to query font properties.
  • platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp: (WebCore::GlyphPage::fill): We can assume there is always a scaled font now.
  • platform/graphics/freetype/SimpleFontDataFreeType.cpp: (WebCore::SimpleFontData::platformInit): Ditto. (WebCore::SimpleFontData::createScaledFontData): Ditto. (WebCore::SimpleFontData::containsCharacters): Ditto. (WebCore::SimpleFontData::platformWidthForGlyph): Ditto.
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90039 r90041  
     12011-06-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [Freetype] Many tests report ERROR: Failed to get glyph page zero.
     6        https://bugs.webkit.org/show_bug.cgi?id=63498
     7
     8        Instead of conditionally instantiating the m_scaledFont member of FontPlatformData,
     9        always instantiate it. For times when the size is 0 and the instantiation would lead
     10        to a Cairo error, we use size 1 and just make operations which would fail conditional
     11        on the m_size > 0.
     12
     13        No new tests. This change is covered by existing tests. We should
     14        observe no errors on the bots after landing.
     15
     16        * platform/graphics/cairo/FontCairo.cpp:
     17        (WebCore::Font::drawGlyphs): Instead of looking at whether or not there is
     18        a scaled font to determine whether to draw, just look at the size.
     19        * platform/graphics/freetype/FontPlatformData.h: Remove the m_font member.
     20        * platform/graphics/freetype/FontPlatformDataFreeType.cpp: Always instantiate
     21        a scaled font member and remove references to m_font. If we are instantiating
     22        a scaled font for a 0 size font, instantiate a size 1 font, so that we can
     23        still use Cairo to query font properties.
     24        * platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp:
     25        (WebCore::GlyphPage::fill): We can assume there is always a scaled font now.
     26        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
     27        (WebCore::SimpleFontData::platformInit): Ditto.
     28        (WebCore::SimpleFontData::createScaledFontData): Ditto.
     29        (WebCore::SimpleFontData::containsCharacters): Ditto.
     30        (WebCore::SimpleFontData::platformWidthForGlyph): Ditto.
     31
    1322011-06-29  Eric Carlson  <eric.carlson@apple.com>
    233
  • trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp

    r89314 r90041  
    107107                      int from, int numGlyphs, const FloatPoint& point) const
    108108{
    109     if (!font->platformData().scaledFont())
     109    if (!font->platformData().size())
    110110        return;
    111111
  • trunk/Source/WebCore/platform/graphics/freetype/FontPlatformData.h

    r87523 r90041  
    9898    bool m_syntheticOblique;
    9999    bool m_fixedWidth;
    100     RefPtr<cairo_font_face_t> m_font;
    101100    cairo_scaled_font_t* m_scaledFont;
    102101
  • trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp

    r89248 r90041  
    122122    , m_scaledFont(0)
    123123{
    124     m_font = adoptRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));
    125     initializeWithFontFace(m_font.get());
     124    RefPtr<cairo_font_face_t> fontFace = adoptRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));
     125    initializeWithFontFace(fontFace.get());
    126126
    127127    int spacing;
     
    154154    , m_syntheticOblique(italic)
    155155    , m_fixedWidth(false)
    156     , m_font(fontFace)
    157156    , m_scaledFont(0)
    158157{
    159158    initializeWithFontFace(fontFace);
    160159
    161     if (m_scaledFont) {
    162         FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
    163         if (fontConfigFace) {
    164             m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
    165             cairo_ft_scaled_font_unlock_face(m_scaledFont);
    166         }
     160    FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
     161    if (fontConfigFace) {
     162        m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
     163        cairo_ft_scaled_font_unlock_face(m_scaledFont);
    167164    }
    168165}
     
    189186        cairo_scaled_font_destroy(m_scaledFont);
    190187    m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont);
    191     m_font = other.m_font;
    192188
    193189    return *this;
     
    231227    return m_pattern == other.m_pattern
    232228        && m_scaledFont == other.m_scaledFont
    233         && m_font == other.m_font
    234229        && m_size == other.m_size
    235230        && m_syntheticOblique == other.m_syntheticOblique
     
    246241void FontPlatformData::initializeWithFontFace(cairo_font_face_t* fontFace)
    247242{
    248     // Fonts with zero size lead to failed cairo_scaled_font_t instantiations. Instead
    249     // we just do not instantiate the scaled font at all. This will cause all renders
    250     // to be no-ops and all metrics to be zero, which is the desired behavior anyway.
    251     if (!m_size)
    252         return;
    253 
    254243    cairo_font_options_t* options = getDefaultFontOptions();
    255244
     
    257246    cairo_matrix_init_identity(&ctm);
    258247
     248    // Scaling a font with width zero size leads to a failed cairo_scaled_font_t instantiations.
     249    // Instead we scale we scale the font to a very tiny size and just abort rendering later on.
     250    float realSize = m_size ? m_size : 1;
     251
    259252    cairo_matrix_t fontMatrix;
    260253    if (!m_pattern)
    261         cairo_matrix_init_scale(&fontMatrix, m_size, m_size);
     254        cairo_matrix_init_scale(&fontMatrix, realSize, realSize);
    262255    else {
    263256        setCairoFontOptionsFromFontConfigPattern(options, m_pattern.get());
     
    274267                          -fontConfigMatrix.xy, fontConfigMatrix.yy, 0, 0);
    275268
    276         // The matrix from FontConfig does not include the scale.
    277         cairo_matrix_scale(&fontMatrix, m_size, m_size);
     269        // The matrix from FontConfig does not include the scale. 
     270        cairo_matrix_scale(&fontMatrix, realSize, realSize);
    278271    }
    279272
     
    284277bool FontPlatformData::hasCompatibleCharmap()
    285278{
    286     // If m_scaledFont is null, it means that this is a size zero font, which always
    287     // has a compatible charmap since we never really read any font data from the font.
    288     if (!m_scaledFont)
    289         return true;
    290 
     279    ASSERT(m_scaledFont);
    291280    FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
    292281    bool hasCompatibleCharmap = !(FT_Select_Charmap(freeTypeFace, ft_encoding_unicode)
  • trunk/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp

    r87523 r90041  
    4747
    4848    cairo_scaled_font_t* scaledFont = fontData->platformData().scaledFont();
    49     if (!scaledFont)
    50         return false;
     49    ASSERT(scaledFont);
    5150
    5251    FT_Face face = cairo_ft_scaled_font_lock_face(scaledFont);
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r87523 r90041  
    4848void SimpleFontData::platformInit()
    4949{
    50     if (!m_platformData.scaledFont())
     50    if (!m_platformData.m_size)
    5151        return;
    5252
     53    ASSERT(m_platformData.scaledFont());
    5354    cairo_font_extents_t font_extents;
    5455    cairo_text_extents_t text_extents;
     
    9293PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    9394{
    94     return adoptPtr(new SimpleFontData(FontPlatformData(m_platformData.m_font.get(),
     95    ASSERT(m_platformData.scaledFont());
     96    return adoptPtr(new SimpleFontData(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),
    9597                                                        scaleFactor * fontDescription.computedSize(),
    9698                                                        m_platformData.syntheticBold(),
     
    122124bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
    123125{
    124     // If this is a no-op font (zero size), then it should always contain the characters,
    125     // since we never read from or render from this font.
    126     if (!m_platformData.scaledFont())
    127         return true;
    128 
     126    ASSERT(m_platformData.scaledFont());
    129127    FT_Face face = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
    130128    if (!face)
     
    154152float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
    155153{
    156     if (!m_platformData.scaledFont())
     154    if (!m_platformData.size())
    157155        return 0;
    158156
Note: See TracChangeset for help on using the changeset viewer.