diff options
author | Steve Block <steveblock@google.com> | 2010-02-15 12:23:52 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-16 11:48:32 +0000 |
commit | 8a0914b749bbe7da7768e07a7db5c6d4bb09472b (patch) | |
tree | 73f9065f370435d6fde32ae129d458a8c77c8dff /WebCore/platform/graphics/mac | |
parent | bf14be70295513b8076f3fa47a268a7e42b2c478 (diff) | |
download | external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.zip external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.gz external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.bz2 |
Merge webkit.org at r54731 : Initial merge by git
Change-Id: Ia79977b6cf3b0b00c06ef39419989b28e57e4f4a
Diffstat (limited to 'WebCore/platform/graphics/mac')
6 files changed, 69 insertions, 26 deletions
diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp index 7d12b61..543d885 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -316,6 +316,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* font , m_characters(characters) , m_stringLocation(stringLocation) , m_stringLength(stringLength) + , m_isMonotonic(true) { #if USE(CORE_TEXT) && USE(ATSUI) shouldUseATSUIAPI() ? createTextRunFromFontDataATSUI(ltr) : createTextRunFromFontDataCoreText(ltr); @@ -326,6 +327,30 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* font #endif } +void ComplexTextController::ComplexTextRun::setIsNonMonotonic() +{ + ASSERT(m_isMonotonic); + m_isMonotonic = false; + + Vector<bool, 64> mappedIndices(m_stringLength); + for (size_t i = 0; i < m_glyphCount; ++i) { + ASSERT(indexAt(i) < static_cast<CFIndex>(m_stringLength)); + mappedIndices[indexAt(i)] = true; + } + + m_glyphEndOffsets.grow(m_glyphCount); + for (size_t i = 0; i < m_glyphCount; ++i) { + CFIndex nextMappedIndex = m_stringLength; + for (size_t j = indexAt(i) + 1; j < m_stringLength; ++j) { + if (mappedIndices[j]) { + nextMappedIndex = j; + break; + } + } + m_glyphEndOffsets[i] = nextMappedIndex; + } +} + void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer) { if (static_cast<int>(offset) > m_end) @@ -348,10 +373,13 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer) while (m_glyphInCurrentRun < glyphCount) { unsigned glyphStartOffset = complexTextRun.indexAt(g); unsigned glyphEndOffset; - if (ltr) - glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? complexTextRun.indexAt(g + 1) : complexTextRun.stringLength()); - else - glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? complexTextRun.indexAt(g - 1) : complexTextRun.stringLength()); + if (complexTextRun.isMonotonic()) { + if (ltr) + glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? complexTextRun.indexAt(g + 1) : complexTextRun.stringLength()); + else + glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? complexTextRun.indexAt(g - 1) : complexTextRun.stringLength()); + } else + glyphEndOffset = complexTextRun.endOffsetAt(g); CGSize adjustedAdvance = m_adjustedAdvances[k]; @@ -393,7 +421,7 @@ void ComplexTextController::adjustGlyphsAndAdvances() { size_t runCount = m_complexTextRuns.size(); for (size_t r = 0; r < runCount; ++r) { - const ComplexTextRun& complexTextRun = *m_complexTextRuns[r]; + ComplexTextRun& complexTextRun = *m_complexTextRuns[r]; unsigned glyphCount = complexTextRun.glyphCount(); const SimpleFontData* fontData = complexTextRun.fontData(); @@ -405,10 +433,18 @@ void ComplexTextController::adjustGlyphsAndAdvances() CGFloat roundedSpaceWidth = roundCGFloat(fontData->spaceWidth()); bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances(); bool hasExtraSpacing = (m_font.letterSpacing() || m_font.wordSpacing() || m_padding) && !m_run.spacingDisabled(); - + CFIndex lastCharacterIndex = m_run.ltr() ? numeric_limits<CFIndex>::min() : numeric_limits<CFIndex>::max(); + bool isMonotonic = true; for (unsigned i = 0; i < glyphCount; i++) { CFIndex characterIndex = complexTextRun.indexAt(i); + if (m_run.ltr()) { + if (characterIndex < lastCharacterIndex) + isMonotonic = false; + } else { + if (characterIndex > lastCharacterIndex) + isMonotonic = false; + } UChar ch = *(cp + characterIndex); bool lastGlyph = lastRun && i + 1 == glyphCount; UChar nextCh; @@ -500,7 +536,10 @@ void ComplexTextController::adjustGlyphsAndAdvances() advance.height *= -1; m_adjustedAdvances.append(advance); m_adjustedGlyphs.append(glyph); + lastCharacterIndex = characterIndex; } + if (!isMonotonic) + complexTextRun.setIsNonMonotonic(); } } diff --git a/WebCore/platform/graphics/mac/ComplexTextController.h b/WebCore/platform/graphics/mac/ComplexTextController.h index 3fec18a..53e8f7a 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.h +++ b/WebCore/platform/graphics/mac/ComplexTextController.h @@ -88,8 +88,11 @@ private: unsigned stringLocation() const { return m_stringLocation; } size_t stringLength() const { return m_stringLength; } ALWAYS_INLINE CFIndex indexAt(size_t i) const; + CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; } const CGGlyph* glyphs() const { return m_glyphs; } const CGSize* advances() const { return m_advances; } + bool isMonotonic() const { return m_isMonotonic; } + void setIsNonMonotonic(); private: #if USE(CORE_TEXT) @@ -124,14 +127,15 @@ private: #if USE(ATSUI) Vector<CFIndex, 64> m_atsuiIndices; #endif + Vector<CFIndex, 64> m_glyphEndOffsets; Vector<CGGlyph, 64> m_glyphsVector; const CGGlyph* m_glyphs; Vector<CGSize, 64> m_advancesVector; const CGSize* m_advances; #if USE(ATSUI) - bool m_ltr; bool m_directionalOverride; #endif + bool m_isMonotonic; }; void collectComplexTextRuns(); diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp index 48aa174..1656854 100644 --- a/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp @@ -145,8 +145,8 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(ATSUTextLayout atsuTextLay , m_characters(characters) , m_stringLocation(stringLocation) , m_stringLength(stringLength) - , m_ltr(ltr) , m_directionalOverride(directionalOverride) + , m_isMonotonic(true) { OSStatus status; diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp index dd5e96a..9f20b68 100644 --- a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp @@ -46,6 +46,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Simp , m_characters(characters) , m_stringLocation(stringLocation) , m_stringLength(stringLength) + , m_isMonotonic(true) { m_glyphCount = CTRunGetGlyphCount(m_coreTextRun.get()); m_coreTextIndices = CTRunGetStringIndicesPtr(m_coreTextRun.get()); diff --git a/WebCore/platform/graphics/mac/FontCacheMac.mm b/WebCore/platform/graphics/mac/FontCacheMac.mm index 2730d5a..0747dd7 100644 --- a/WebCore/platform/graphics/mac/FontCacheMac.mm +++ b/WebCore/platform/graphics/mac/FontCacheMac.mm @@ -146,43 +146,43 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, cons return getCachedFontData(&alternateFont); } -FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font) +SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) { // Attempt to find an appropriate font using a match based on // the presence of keywords in the the requested names. For example, we'll // match any name that contains "Arabic" to Geeza Pro. - FontPlatformData* platformData = 0; + SimpleFontData* simpleFontData = 0; const FontFamily* currFamily = &font.fontDescription().family(); - while (currFamily && !platformData) { + while (currFamily && !simpleFontData) { if (currFamily->family().length()) { static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") }; DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro")); - for (int j = 0; j < 3 && !platformData; ++j) + for (int j = 0; j < 3 && !simpleFontData; ++j) if (currFamily->family().contains(*matchWords[j], false)) - platformData = getCachedFontPlatformData(font.fontDescription(), geezaStr); + simpleFontData = getCachedFontData(font.fontDescription(), geezaStr); } currFamily = currFamily->next(); } - return platformData; + return simpleFontData; } -FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) +SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) { DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times")); - DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande")); // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick // the default that the user would get without changing any prefs. - FontPlatformData* platformFont = getCachedFontPlatformData(fontDescription, timesStr); - if (!platformFont) - // The Times fallback will almost always work, but in the highly unusual case where - // the user doesn't have it, we fall back on Lucida Grande because that's - // guaranteed to be there, according to Nathan Taylor. This is good enough - // to avoid a crash at least. - platformFont = getCachedFontPlatformData(fontDescription, lucidaGrandeStr); - - return platformFont; + SimpleFontData* simpleFontData = getCachedFontData(fontDescription, timesStr); + if (simpleFontData) + return simpleFontData; + + // The Times fallback will almost always work, but in the highly unusual case where + // the user doesn't have it, we fall back on Lucida Grande because that's + // guaranteed to be there, according to Nathan Taylor. This is good enough + // to avoid a crash at least. + DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande")); + return getCachedFontData(fontDescription, lucidaGrandeStr); } void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks) diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp index 5e5e1f4..99ad130 100644 --- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp +++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp @@ -223,7 +223,6 @@ void GraphicsContext3D::reshape(int width, int height) notImplemented(); } - ::glViewport(0, 0, m_currentWidth, m_currentHeight); ::glClear(GL_COLOR_BUFFER_BIT); ::glFlush(); } |