Changeset 189465 in webkit


Ignore:
Timestamp:
Sep 7, 2015, 10:42:50 AM (10 years ago)
Author:
Antti Koivisto
Message:

Remove unneeded offset and length arguments from glyph page filling functions
https://bugs.webkit.org/show_bug.cgi?id=148929

Reviewed by Andreas Kling.

They are always passed 0/GlyphPage::size.

  • platform/graphics/Font.cpp:

(WebCore::Font::~Font):
(WebCore::fillGlyphPage):
(WebCore::createAndFillGlyphPage):

  • platform/graphics/Font.h:
  • platform/graphics/GlyphPage.h:

(WebCore::GlyphPage::setGlyphDataForIndex):

  • platform/graphics/mac/GlyphPageMac.cpp:

(WebCore::GlyphPage::mayUseMixedFontsWhenFilling):
(WebCore::GlyphPage::fill):

  • platform/graphics/win/GlyphPageTreeNodeCGWin.cpp:

(WebCore::GlyphPage::fill):

  • platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp:

(WebCore::GlyphPage::fill):

  • svg/SVGFontData.cpp:

(WebCore::SVGFontData::applySVGGlyphSelection):
(WebCore::SVGFontData::fillSVGGlyphPage):
(WebCore::SVGFontData::fillBMPGlyphs):
(WebCore::SVGFontData::fillNonBMPGlyphs):

  • svg/SVGFontData.h:

(WebCore::SVGFontData::verticalAdvanceY):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r189452 r189465  
     12015-09-07  Antti Koivisto  <antti@apple.com>
     2
     3        Remove unneeded offset and length arguments from glyph page filling functions
     4        https://bugs.webkit.org/show_bug.cgi?id=148929
     5
     6        Reviewed by Andreas Kling.
     7
     8        They are always passed 0/GlyphPage::size.
     9
     10        * platform/graphics/Font.cpp:
     11        (WebCore::Font::~Font):
     12        (WebCore::fillGlyphPage):
     13        (WebCore::createAndFillGlyphPage):
     14        * platform/graphics/Font.h:
     15        * platform/graphics/GlyphPage.h:
     16        (WebCore::GlyphPage::setGlyphDataForIndex):
     17        * platform/graphics/mac/GlyphPageMac.cpp:
     18        (WebCore::GlyphPage::mayUseMixedFontsWhenFilling):
     19        (WebCore::GlyphPage::fill):
     20        * platform/graphics/win/GlyphPageTreeNodeCGWin.cpp:
     21        (WebCore::GlyphPage::fill):
     22        * platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp:
     23        (WebCore::GlyphPage::fill):
     24        * svg/SVGFontData.cpp:
     25        (WebCore::SVGFontData::applySVGGlyphSelection):
     26        (WebCore::SVGFontData::fillSVGGlyphPage):
     27        (WebCore::SVGFontData::fillBMPGlyphs):
     28        (WebCore::SVGFontData::fillNonBMPGlyphs):
     29        * svg/SVGFontData.h:
     30        (WebCore::SVGFontData::verticalAdvanceY):
     31
    1322015-09-06  Chris Dumez  <cdumez@apple.com>
    233
  • TabularUnified trunk/Source/WebCore/platform/graphics/Font.cpp

    r188797 r189465  
    150150}
    151151
    152 static bool fillGlyphPage(GlyphPage& pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font* font)
     152static bool fillGlyphPage(GlyphPage& pageToFill, UChar* buffer, unsigned bufferLength, const Font* font)
    153153{
    154154#if ENABLE(SVG_FONTS)
    155155    if (auto* svgData = font->svgData())
    156         return svgData->fillSVGGlyphPage(&pageToFill, offset, length, buffer, bufferLength, font);
    157 #endif
    158     bool hasGlyphs = pageToFill.fill(offset, length, buffer, bufferLength, font);
     156        return svgData->fillSVGGlyphPage(&pageToFill, buffer, bufferLength, font);
     157#endif
     158    bool hasGlyphs = pageToFill.fill(buffer, bufferLength, font);
    159159#if ENABLE(OPENTYPE_VERTICAL)
    160160    if (hasGlyphs && font->verticalData())
    161         font->verticalData()->substituteWithVerticalGlyphs(font, &pageToFill, offset, length);
     161        font->verticalData()->substituteWithVerticalGlyphs(font, &pageToFill);
    162162#endif
    163163    return hasGlyphs;
     
    233233        glyphPage = GlyphPage::createForSingleFont(font);
    234234
    235     bool haveGlyphs = fillGlyphPage(*glyphPage, 0, GlyphPage::size, buffer, bufferLength, font);
     235    bool haveGlyphs = fillGlyphPage(*glyphPage, buffer, bufferLength, font);
    236236    if (!haveGlyphs)
    237237        return nullptr;
  • TabularUnified trunk/Source/WebCore/platform/graphics/Font.h

    r188797 r189465  
    7777        virtual void initializeFont(Font*, float fontSize) = 0;
    7878        virtual float widthForSVGGlyph(Glyph, float fontSize) const = 0;
    79         virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font*) const = 0;
     79        virtual bool fillSVGGlyphPage(GlyphPage*, UChar* buffer, unsigned bufferLength, const Font*) const = 0;
    8080    };
    8181
  • TabularUnified trunk/Source/WebCore/platform/graphics/GlyphPage.h

    r181597 r189465  
    157157
    158158    // Implemented by the platform.
    159     bool fill(unsigned offset, unsigned length, UChar* characterBuffer, unsigned bufferLength, const Font*);
     159    bool fill(UChar* characterBuffer, unsigned bufferLength, const Font*);
    160160#if PLATFORM(COCOA)
    161161    static bool mayUseMixedFontsWhenFilling(const UChar* characterBuffer, unsigned bufferLength, const Font*);
  • TabularUnified trunk/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp

    r178940 r189465  
    4040namespace WebCore {
    4141
    42 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font* fontData)
     42bool GlyphPage::fill(UChar* buffer, unsigned bufferLength, const Font* fontData)
    4343{
    4444    cairo_scaled_font_t* scaledFont = fontData->platformData().scaledFont();
     
    5151    bool haveGlyphs = false;
    5252    UTF16UChar32Iterator iterator(buffer, bufferLength);
    53     for (unsigned i = 0; i < length; i++) {
     53    for (unsigned i = 0; i < GlyphPage::size; i++) {
    5454        UChar32 character = iterator.next();
    5555        if (character == iterator.end())
     
    5858        Glyph glyph = FcFreeTypeCharIndex(face, character);
    5959        if (!glyph)
    60             setGlyphDataForIndex(offset + i, 0, 0);
     60            setGlyphDataForIndex(i, 0, 0);
    6161        else {
    62             setGlyphDataForIndex(offset + i, glyph, fontData);
     62            setGlyphDataForIndex(i, glyph, fontData);
    6363            haveGlyphs = true;
    6464        }
  • TabularUnified trunk/Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp

    r188566 r189465  
    7272}
    7373
    74 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font* fontData)
     74bool GlyphPage::fill(UChar* buffer, unsigned bufferLength, const Font* fontData)
    7575{
    7676    bool haveGlyphs = false;
     
    8383        // this should not happen as the only time we pass in 512 characters is when they are surrogates.
    8484        CGFontGetGlyphsForUnichars(fontData->platformData().cgFont(), buffer, glyphs.data(), bufferLength);
    85         for (unsigned i = 0; i < length; ++i) {
     85        for (unsigned i = 0; i < GlyphPage::size; ++i) {
    8686            if (!glyphs[i])
    87                 setGlyphDataForIndex(offset + i, 0, 0);
     87                setGlyphDataForIndex(i, 0, 0);
    8888            else {
    89                 setGlyphDataForIndex(offset + i, glyphs[i], fontData);
     89                setGlyphDataForIndex(i, glyphs[i], fontData);
    9090                haveGlyphs = true;
    9191            }
     
    100100        // When buffer consists of surrogate pairs, CTFontGetVerticalGlyphsForCharacters and CTFontGetGlyphsForCharacters
    101101        // place the glyphs at indices corresponding to the first character of each pair.
    102         ASSERT(!(bufferLength % length) && (bufferLength / length == 1 || bufferLength / length == 2));
    103         unsigned glyphStep = bufferLength / length;
    104         for (unsigned i = 0; i < length; ++i) {
     102        ASSERT(bufferLength == GlyphPage::size || bufferLength == 2 * GlyphPage::size);
     103        unsigned glyphStep = bufferLength / GlyphPage::size;
     104        for (unsigned i = 0; i < GlyphPage::size; ++i) {
    105105            if (!glyphs[i * glyphStep])
    106                 setGlyphDataForIndex(offset + i, 0, 0);
     106                setGlyphDataForIndex(i, 0, 0);
    107107            else {
    108                 setGlyphDataForIndex(offset + i, glyphs[i * glyphStep], fontData);
     108                setGlyphDataForIndex(i, glyphs[i * glyphStep], fontData);
    109109                haveGlyphs = true;
    110110            }
  • TabularUnified trunk/Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp

    r178986 r189465  
    536536}
    537537
    538 void OpenTypeVerticalData::substituteWithVerticalGlyphs(const Font* font, GlyphPage* glyphPage, unsigned offset, unsigned length) const
     538void OpenTypeVerticalData::substituteWithVerticalGlyphs(const Font* font, GlyphPage* glyphPage) const
    539539{
    540540    const HashMap<Glyph, Glyph>& map = m_verticalGlyphMap;
     
    542542        return;
    543543
    544     for (unsigned index = offset, end = offset + length; index < end; ++index) {
     544    for (unsigned index = 0; index < GlyphPage::size; ++index) {
    545545        Glyph glyph = glyphPage->glyphAt(index);
    546546        if (glyph) {
  • TabularUnified trunk/Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.h

    r178940 r189465  
    5151    float advanceHeight(const Font*, Glyph) const;
    5252    void getVerticalTranslationsForGlyphs(const Font*, const Glyph*, size_t, float* outXYArray) const;
    53     void substituteWithVerticalGlyphs(const Font*, GlyphPage*, unsigned offset, unsigned length) const;
     53    void substituteWithVerticalGlyphs(const Font*, GlyphPage*) const;
    5454
    5555private:
  • TabularUnified trunk/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp

    r178940 r189465  
    3535namespace WebCore {
    3636
    37 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font* fontData)
     37bool GlyphPage::fill(UChar* buffer, unsigned bufferLength, const Font* fontData)
    3838{
    3939    // bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs.
    4040    // We won't support this for now.
    41     if (bufferLength > length)
     41    if (bufferLength > GlyphPage::size)
    4242        return false;
    4343
     
    4545    CGGlyph localGlyphBuffer[GlyphPage::size];
    4646    wkGetGlyphs(fontData->platformData().cgFont(), buffer, localGlyphBuffer, bufferLength);
    47     for (unsigned i = 0; i < length; i++) {
     47    for (unsigned i = 0; i < GlyphPage::size; i++) {
    4848        Glyph glyph = localGlyphBuffer[i];
    4949        if (!glyph)
    50             setGlyphDataForIndex(offset + i, 0, 0);
     50            setGlyphDataForIndex(i, 0, 0);
    5151        else {
    52             setGlyphDataForIndex(offset + i, glyph, fontData);
     52            setGlyphDataForIndex(i, glyph, fontData);
    5353            haveGlyphs = true;
    5454        }
  • TabularUnified trunk/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp

    r186862 r189465  
    3535namespace WebCore {
    3636
    37 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font* fontData)
     37bool GlyphPage::fill(UChar* buffer, unsigned bufferLength, const Font* fontData)
    3838{
    3939    // bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs.
    4040    // We won't support this for now.
    41     if (bufferLength > length)
     41    if (bufferLength > GlyphPage::size)
    4242        return false;
    4343
     
    5252    bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength;
    5353    if (success) {
    54         for (unsigned i = 0; i < length; i++) {
     54        for (unsigned i = 0; i < GlyphPage::size; i++) {
    5555            Glyph glyph = localGlyphBuffer[i];
    5656            if (glyph == 0xffff)
    57                 setGlyphDataForIndex(offset + i, 0, 0);
     57                setGlyphDataForIndex(i, 0, 0);
    5858            else {
    59                 setGlyphDataForIndex(offset + i, glyph, fontData);
     59                setGlyphDataForIndex(i, glyph, fontData);
    6060                haveGlyphs = true;
    6161            }
  • TabularUnified trunk/Source/WebCore/svg/SVGFontData.cpp

    r184844 r189465  
    205205}
    206206
    207 bool SVGFontData::fillSVGGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font* font) const
     207bool SVGFontData::fillSVGGlyphPage(GlyphPage* pageToFill, UChar* buffer, unsigned bufferLength, const Font* font) const
    208208{
    209209    ASSERT(font->isCustomFont());
     
    216216    ASSERT(fontElement);
    217217
    218     if (bufferLength == length)
    219         return fillBMPGlyphs(fontElement, pageToFill, offset, length, buffer, font);
    220 
    221     ASSERT(bufferLength == 2 * length);
    222     return fillNonBMPGlyphs(fontElement, pageToFill, offset, length, buffer, font);
    223 }
    224 
    225 bool SVGFontData::fillBMPGlyphs(SVGFontElement* fontElement, GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, const Font* font) const
     218    if (bufferLength == GlyphPage::size)
     219        return fillBMPGlyphs(fontElement, pageToFill, buffer, font);
     220
     221    ASSERT(bufferLength == 2 * GlyphPage::size);
     222    return fillNonBMPGlyphs(fontElement, pageToFill, buffer, font);
     223}
     224
     225bool SVGFontData::fillBMPGlyphs(SVGFontElement* fontElement, GlyphPage* pageToFill, UChar* buffer, const Font* font) const
    226226{
    227227    bool haveGlyphs = false;
    228228    Vector<SVGGlyph> glyphs;
    229     for (unsigned i = 0; i < length; ++i) {
     229    for (unsigned i = 0; i < GlyphPage::size; ++i) {
    230230        String lookupString(buffer + i, 1);
    231231        fontElement->collectGlyphsForString(lookupString, glyphs);
    232232        if (glyphs.isEmpty()) {
    233             pageToFill->setGlyphDataForIndex(offset + i, 0, 0);
     233            pageToFill->setGlyphDataForIndex(i, 0, 0);
    234234            continue;
    235235        }
     
    240240        // only possible within the context of a string (eg. arabic form matching).
    241241        haveGlyphs = true;
    242         pageToFill->setGlyphDataForIndex(offset + i, glyphs.first().tableEntry, font);
     242        pageToFill->setGlyphDataForIndex(i, glyphs.first().tableEntry, font);
    243243        glyphs.clear();
    244244    }
     
    247247}
    248248
    249 bool SVGFontData::fillNonBMPGlyphs(SVGFontElement* fontElement, GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, const Font* font) const
     249bool SVGFontData::fillNonBMPGlyphs(SVGFontElement* fontElement, GlyphPage* pageToFill, UChar* buffer, const Font* font) const
    250250{
    251251    bool haveGlyphs = false;
    252252    Vector<SVGGlyph> glyphs;
    253     for (unsigned i = 0; i < length; ++i) {
     253    for (unsigned i = 0; i < GlyphPage::size; ++i) {
    254254        // Each character here consists of a surrogate pair
    255255        String lookupString(buffer + i * 2, 2);
    256256        fontElement->collectGlyphsForString(lookupString, glyphs);
    257257        if (glyphs.isEmpty()) {
    258             pageToFill->setGlyphDataForIndex(offset + i, 0, 0);
     258            pageToFill->setGlyphDataForIndex(i, 0, 0);
    259259            continue;
    260260        }
     
    265265        // only possible within the context of a string (eg. arabic form matching).
    266266        haveGlyphs = true;
    267         pageToFill->setGlyphDataForIndex(offset + i, glyphs.first().tableEntry, font);
     267        pageToFill->setGlyphDataForIndex(i, glyphs.first().tableEntry, font);
    268268        glyphs.clear();
    269269    }
  • TabularUnified trunk/Source/WebCore/svg/SVGFontData.h

    r178940 r189465  
    3636    virtual void initializeFont(Font*, float fontSize) override;
    3737    virtual float widthForSVGGlyph(Glyph, float fontSize) const override;
    38     virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const Font*) const override;
     38    virtual bool fillSVGGlyphPage(GlyphPage*, UChar* buffer, unsigned bufferLength, const Font*) const override;
    3939
    4040    bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength, String& normalizedSpacesStringCache) const;
     
    5151
    5252private:
    53     bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const Font*) const;
    54     bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const Font*) const;
     53    bool fillBMPGlyphs(SVGFontElement*, GlyphPage*, UChar* buffer, const Font*) const;
     54    bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage*, UChar* buffer, const Font*) const;
    5555
    5656    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t, TypesettingFeatures) const = delete;
Note: See TracChangeset for help on using the changeset viewer.