Changeset 64734 in webkit
- Timestamp:
- Aug 5, 2010 4:54:34 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64732 r64734 1 2010-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 1 14 2010-08-05 Steve Block <steveblock@google.com> 2 15 -
trunk/WebCore/platform/graphics/mac/ComplexTextController.h
r61253 r64734 128 128 size_t m_stringLength; 129 129 #if USE(CORE_TEXT) 130 RetainPtr<CFMutableDataRef> m_coreTextIndicesData;130 Vector<CFIndex, 64> m_coreTextIndicesVector; 131 131 const CFIndex* m_coreTextIndices; 132 132 #endif -
trunk/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp
r62627 r64734 52 52 m_coreTextIndices = CTRunGetStringIndicesPtr(m_coreTextRun.get()); 53 53 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(); 58 57 } 59 58 … … 71 70 m_advances = m_advancesVector.data(); 72 71 } 73 74 72 } 75 73 … … 78 76 void ComplexTextController::ComplexTextRun::createTextRunFromFontDataCoreText(bool ltr) 79 77 { 80 Vector<CFIndex, 16> indices;78 m_coreTextIndicesVector.reserveInitialCapacity(m_stringLength); 81 79 unsigned r = 0; 82 80 while (r < m_stringLength) { 83 indices.append(r);81 m_coreTextIndicesVector.uncheckedAppend(r); 84 82 if (U_IS_SURROGATE(m_characters[r])) { 85 83 ASSERT(r + 1 < m_stringLength); … … 90 88 r++; 91 89 } 92 m_glyphCount = indices.size();90 m_glyphCount = m_coreTextIndicesVector.size(); 93 91 if (!ltr) { 94 92 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]); 96 94 } 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(); 100 96 101 97 // Synthesize a run of missing glyphs. … … 121 117 RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(NULL, string.get(), fontData->getCFStringAttributes(m_font.typesettingFeatures()))); 122 118 123 RetainPtr<CT TypesetterRef> typesetter;119 RetainPtr<CTLineRef> line; 124 120 125 121 if (!m_mayUseNaturalWritingDirection || m_run.directionalOverride()) { … … 131 127 static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 132 128 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))); 134 132 } 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())); 138 134 139 135 CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
Note: See TracChangeset
for help on using the changeset viewer.