Commit 7bc6bf06 authored by jbroman@chromium.org's avatar jbroman@chromium.org

Simplify GlyphBuffer::reverse.

Since only the entire buffer is ever reversed, a simpler and more
obvious implementation using WTF::Vector::reverse is possible.

Review URL: https://codereview.chromium.org/348553003

git-svn-id: svn://svn.chromium.org/blink/trunk@176526 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bb0339b9
...@@ -648,7 +648,7 @@ float Font::getGlyphsAndAdvancesForSimpleText(const TextRunPaintInfo& runInfo, G ...@@ -648,7 +648,7 @@ float Font::getGlyphsAndAdvancesForSimpleText(const TextRunPaintInfo& runInfo, G
float finalRoundingWidth = it.m_finalRoundingWidth; float finalRoundingWidth = it.m_finalRoundingWidth;
it.advance(runInfo.run.length(), &localGlyphBuffer); it.advance(runInfo.run.length(), &localGlyphBuffer);
initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth; initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
glyphBuffer.reverse(0, glyphBuffer.size()); glyphBuffer.reverse();
} else { } else {
initialAdvance = beforeWidth; initialAdvance = beforeWidth;
} }
......
...@@ -79,10 +79,11 @@ public: ...@@ -79,10 +79,11 @@ public:
m_advances.append(advance); m_advances.append(advance);
} }
void reverse(unsigned from, unsigned length) void reverse()
{ {
for (unsigned i = from, end = from + length - 1; i < end; ++i, --end) m_fontData.reverse();
swap(i, end); m_glyphs.reverse();
m_advances.reverse();
} }
void expandLastAdvance(float width) void expandLastAdvance(float width)
...@@ -93,21 +94,6 @@ public: ...@@ -93,21 +94,6 @@ public:
} }
private: private:
void swap(unsigned index1, unsigned index2)
{
const SimpleFontData* f = m_fontData[index1];
m_fontData[index1] = m_fontData[index2];
m_fontData[index2] = f;
Glyph g = m_glyphs[index1];
m_glyphs[index1] = m_glyphs[index2];
m_glyphs[index2] = g;
FloatSize s = m_advances[index1];
m_advances[index1] = m_advances[index2];
m_advances[index2] = s;
}
Vector<const SimpleFontData*, 2048> m_fontData; Vector<const SimpleFontData*, 2048> m_fontData;
Vector<Glyph, 2048> m_glyphs; Vector<Glyph, 2048> m_glyphs;
Vector<FloatSize, 2048> m_advances; Vector<FloatSize, 2048> m_advances;
......
...@@ -85,7 +85,7 @@ float Font::getGlyphsAndAdvancesForComplexText(const TextRunPaintInfo& runInfo, ...@@ -85,7 +85,7 @@ float Font::getGlyphsAndAdvancesForComplexText(const TextRunPaintInfo& runInfo,
if (runInfo.run.rtl()) { if (runInfo.run.rtl()) {
initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth; initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
glyphBuffer.reverse(0, glyphBuffer.size()); glyphBuffer.reverse();
} else } else
initialAdvance = beforeWidth; initialAdvance = beforeWidth;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment