Changeset 64734 in webkit


Ignore:
Timestamp:
Aug 5, 2010 4:54:34 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-08-05 Ned Holbrook <nholbrook@apple.com>

Reviewed by Darin Adler.

~5% complex layout performance improvement.
https://bugs.webkit.org/show_bug.cgi?id=43436

  • platform/graphics/mac/ComplexTextController.h:
  • platform/graphics/mac/ComplexTextControllerCoreText.cpp: (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Use Vector rather than CFMutableData. (WebCore::ComplexTextController::ComplexTextRun::createTextRunFromFontDataCoreText): Ditto. (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText): Avoid typesetter allocation unless using typesetter options.
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64732 r64734  
     12010-08-05  Ned Holbrook  <nholbrook@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        ~5% complex layout performance improvement.
     6        https://bugs.webkit.org/show_bug.cgi?id=43436
     7
     8        * platform/graphics/mac/ComplexTextController.h:
     9        * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
     10        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Use Vector rather than CFMutableData.
     11        (WebCore::ComplexTextController::ComplexTextRun::createTextRunFromFontDataCoreText): Ditto.
     12        (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText): Avoid typesetter allocation unless using typesetter options.
     13
    1142010-08-05  Steve Block  <steveblock@google.com>
    215
  • trunk/WebCore/platform/graphics/mac/ComplexTextController.h

    r61253 r64734  
    128128        size_t m_stringLength;
    129129#if USE(CORE_TEXT)
    130         RetainPtr<CFMutableDataRef> m_coreTextIndicesData;
     130        Vector<CFIndex, 64> m_coreTextIndicesVector;
    131131        const CFIndex* m_coreTextIndices;
    132132#endif
  • trunk/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp

    r62627 r64734  
    5252    m_coreTextIndices = CTRunGetStringIndicesPtr(m_coreTextRun.get());
    5353    if (!m_coreTextIndices) {
    54         m_coreTextIndicesData.adoptCF(CFDataCreateMutable(kCFAllocatorDefault, m_glyphCount * sizeof(CFIndex)));
    55         CFDataIncreaseLength(m_coreTextIndicesData.get(), m_glyphCount * sizeof(CFIndex));
    56         m_coreTextIndices = reinterpret_cast<const CFIndex*>(CFDataGetMutableBytePtr(m_coreTextIndicesData.get()));
    57         CTRunGetStringIndices(m_coreTextRun.get(), CFRangeMake(0, 0), const_cast<CFIndex*>(m_coreTextIndices));
     54        m_coreTextIndicesVector.grow(m_glyphCount);
     55        CTRunGetStringIndices(m_coreTextRun.get(), CFRangeMake(0, 0), m_coreTextIndicesVector.data());
     56        m_coreTextIndices = m_coreTextIndicesVector.data();
    5857    }
    5958
     
    7170        m_advances = m_advancesVector.data();
    7271    }
    73 
    7472}
    7573
     
    7876void ComplexTextController::ComplexTextRun::createTextRunFromFontDataCoreText(bool ltr)
    7977{
    80     Vector<CFIndex, 16> indices;
     78    m_coreTextIndicesVector.reserveInitialCapacity(m_stringLength);
    8179    unsigned r = 0;
    8280    while (r < m_stringLength) {
    83         indices.append(r);
     81        m_coreTextIndicesVector.uncheckedAppend(r);
    8482        if (U_IS_SURROGATE(m_characters[r])) {
    8583            ASSERT(r + 1 < m_stringLength);
     
    9088            r++;
    9189    }
    92     m_glyphCount = indices.size();
     90    m_glyphCount = m_coreTextIndicesVector.size();
    9391    if (!ltr) {
    9492        for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end)
    95             std::swap(indices[r], indices[end]);
     93            std::swap(m_coreTextIndicesVector[r], m_coreTextIndicesVector[end]);
    9694    }
    97     m_coreTextIndicesData.adoptCF(CFDataCreateMutable(kCFAllocatorDefault, m_glyphCount * sizeof(CFIndex)));
    98     CFDataAppendBytes(m_coreTextIndicesData.get(), reinterpret_cast<const UInt8*>(indices.data()), m_glyphCount * sizeof(CFIndex));
    99     m_coreTextIndices = reinterpret_cast<const CFIndex*>(CFDataGetBytePtr(m_coreTextIndicesData.get()));
     95    m_coreTextIndices = m_coreTextIndicesVector.data();
    10096
    10197    // Synthesize a run of missing glyphs.
     
    121117    RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(NULL, string.get(), fontData->getCFStringAttributes(m_font.typesettingFeatures())));
    122118
    123     RetainPtr<CTTypesetterRef> typesetter;
     119    RetainPtr<CTLineRef> line;
    124120
    125121    if (!m_mayUseNaturalWritingDirection || m_run.directionalOverride()) {
     
    131127        static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    132128        static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    133         typesetter.adoptCF(CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
     129        RetainPtr<CTTypesetterRef> typesetter(AdoptCF, CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
     130
     131        line.adoptCF(CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
    134132    } else
    135         typesetter.adoptCF(CTTypesetterCreateWithAttributedString(attributedString.get()));
    136 
    137     RetainPtr<CTLineRef> line(AdoptCF, CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
     133        line.adoptCF(CTLineCreateWithAttributedString(attributedString.get()));
    138134
    139135    CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
Note: See TracChangeset for help on using the changeset viewer.