Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp

Issue 627273003: Carry advances between runs in HarfBuzzShaper.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have Linux baseline be generated by the bot Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/harfbuzz/HarfBuzzShaper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
diff --git a/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp b/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
index 9869c5c081b9a9faa24b6a667c06ffe3bfe94d93..054ef00aed73dd49dd663526816dccca3a1fb7f8 100644
--- a/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
+++ b/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
@@ -948,29 +948,35 @@ void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, hb
m_totalWidth += currentRun->width();
}
-void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBufferWithOffsets* glyphBuffer, HarfBuzzRun* currentRun)
+void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBufferWithOffsets* glyphBuffer, HarfBuzzRun* currentRun, float& carryAdvance)
{
FloatSize* offsets = currentRun->offsets();
uint16_t* glyphs = currentRun->glyphs();
float* advances = currentRun->advances();
unsigned numGlyphs = currentRun->numGlyphs();
uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes();
- float advanceSoFar = 0;
+ FloatSize runStartOffset = FloatSize();
if (m_run.rtl()) {
for (unsigned i = 0; i < numGlyphs; ++i) {
uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToCharacterIndexes[i];
- if (currentCharacterIndex >= m_toIndex)
- advanceSoFar += advances[i];
- else if (currentCharacterIndex >= m_fromIndex)
- glyphBuffer->add(glyphs[i], currentRun->fontData(), offsets[i] + FloatSize(advanceSoFar, 0), advances[i]);
+ if (currentCharacterIndex >= m_toIndex) {
+ carryAdvance += advances[i];
+ } else if (currentCharacterIndex >= m_fromIndex) {
+ runStartOffset = HB_DIRECTION_IS_HORIZONTAL(currentRun->direction()) ? FloatSize(carryAdvance, 0) : FloatSize(0, carryAdvance);
+ glyphBuffer->add(glyphs[i], currentRun->fontData(), runStartOffset + offsets[i], carryAdvance + advances[i]);
+ carryAdvance = 0;
+ }
}
} else {
for (unsigned i = 0; i < numGlyphs; ++i) {
uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToCharacterIndexes[i];
- if (currentCharacterIndex < m_fromIndex)
- advanceSoFar += advances[i];
- else if (currentCharacterIndex < m_toIndex)
- glyphBuffer->add(glyphs[i], currentRun->fontData(), offsets[i] + FloatSize(advanceSoFar, 0), advances[i]);
+ if (currentCharacterIndex < m_fromIndex) {
+ carryAdvance += advances[i];
+ } else if (currentCharacterIndex < m_toIndex) {
+ runStartOffset = HB_DIRECTION_IS_HORIZONTAL(currentRun->direction()) ? FloatSize(carryAdvance, 0) : FloatSize(0, carryAdvance);
+ glyphBuffer->add(glyphs[i], currentRun->fontData(), runStartOffset + offsets[i], carryAdvance + advances[i]);
+ carryAdvance = 0;
+ }
}
}
}
@@ -1032,6 +1038,7 @@ void HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, Ha
bool HarfBuzzShaper::fillGlyphBuffer(GlyphBuffer* glyphBuffer)
{
unsigned numRuns = m_harfBuzzRuns.size();
+ float carryAdvance = 0;
if (m_run.rtl()) {
for (int runIndex = numRuns - 1; runIndex >= 0; --runIndex) {
HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
@@ -1045,7 +1052,7 @@ bool HarfBuzzShaper::fillGlyphBuffer(GlyphBuffer* glyphBuffer)
} else {
ASSERT(glyphBuffer->hasOffsets());
fillGlyphBufferFromHarfBuzzRun(
- static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRun);
+ static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRun, carryAdvance);
}
}
} else {
@@ -1061,7 +1068,7 @@ bool HarfBuzzShaper::fillGlyphBuffer(GlyphBuffer* glyphBuffer)
} else {
ASSERT(glyphBuffer->hasOffsets());
fillGlyphBufferFromHarfBuzzRun(
- static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRun);
+ static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRun, carryAdvance);
}
}
}
« no previous file with comments | « Source/platform/fonts/harfbuzz/HarfBuzzShaper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698