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

Unified Diff: Source/platform/fonts/GlyphBuffer.h

Issue 607483002: Separate advance from offset in GlypBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase w/HEAD Created 6 years, 3 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/Font.cpp ('k') | Source/platform/fonts/GlyphBufferTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/GlyphBuffer.h
diff --git a/Source/platform/fonts/GlyphBuffer.h b/Source/platform/fonts/GlyphBuffer.h
index 3b30954e7831f68956107a4131124d290b2182ac..3b086559b13d09fbc6c0f390adb056568a78bf45 100644
--- a/Source/platform/fonts/GlyphBuffer.h
+++ b/Source/platform/fonts/GlyphBuffer.h
@@ -42,23 +42,19 @@ class SimpleFontData;
class GlyphBuffer {
STACK_ALLOCATED();
public:
- GlyphBuffer() : m_hasVerticalAdvances(false) { }
-
bool isEmpty() const { return m_fontData.isEmpty(); }
+ virtual bool hasOffsets() const { return false; }
unsigned size() const { return m_fontData.size(); }
- bool hasVerticalAdvances() const { return m_hasVerticalAdvances; }
- void clear()
+ virtual void clear()
{
m_fontData.clear();
m_glyphs.clear();
m_advances.clear();
- m_hasVerticalAdvances = false;
}
const Glyph* glyphs(unsigned from) const { return m_glyphs.data() + from; }
- const FloatSize* advances(unsigned from) const { return m_advances.data() + from; }
-
+ const float* advances(unsigned from) const { return m_advances.data() + from; }
const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[index]; }
Glyph glyphAt(unsigned index) const
@@ -66,7 +62,7 @@ public:
return m_glyphs[index];
}
- FloatSize advanceAt(unsigned index) const
+ float advanceAt(unsigned index) const
{
return m_advances[index];
}
@@ -75,42 +71,68 @@ public:
{
m_fontData.append(font);
m_glyphs.append(glyph);
- m_advances.append(FloatSize(width, 0));
- }
-
- void add(Glyph glyph, const SimpleFontData* font, const FloatSize& advance)
- {
- m_fontData.append(font);
- m_glyphs.append(glyph);
- m_advances.append(advance);
- if (advance.height())
- m_hasVerticalAdvances = true;
+ m_advances.append(width);
}
- void reverse()
+ virtual void reverse()
{
m_fontData.reverse();
m_glyphs.reverse();
m_advances.reverse();
}
- void setAdvanceWidth(unsigned index, float newWidth)
- {
- m_advances[index].setWidth(newWidth);
- }
-
void expandLastAdvance(float width)
{
ASSERT(!isEmpty());
- FloatSize& lastAdvance = m_advances.last();
- lastAdvance.setWidth(lastAdvance.width() + width);
+ float& lastAdvance = m_advances.last();
+ lastAdvance += width;
}
-private:
+protected:
Vector<const SimpleFontData*, 2048> m_fontData;
Vector<Glyph, 2048> m_glyphs;
- Vector<FloatSize, 2048> m_advances;
- bool m_hasVerticalAdvances;
+ Vector<float, 2048> m_advances;
+};
+
+
+class GlyphBufferWithOffsets : public GlyphBuffer {
+public:
+ virtual bool hasOffsets() const OVERRIDE { return true; }
+
+ virtual void clear() OVERRIDE
+ {
+ GlyphBuffer::clear();
+ m_offsets.clear();
+ }
+
+ const FloatSize* offsets(unsigned from) const { return m_offsets.data() + from; }
+
+ FloatSize offsetAt(unsigned index) const
+ {
+ return m_offsets[index];
+ }
+
+ void add(Glyph glyph, const SimpleFontData* font, const FloatSize& offset, float advance)
+ {
+ m_fontData.append(font);
+ m_glyphs.append(glyph);
+ m_offsets.append(offset);
+ m_advances.append(advance);
+ }
+
+ virtual void reverse() OVERRIDE
+ {
+ GlyphBuffer::reverse();
+ m_offsets.reverse();
+ }
+
+private:
+ void add(Glyph glyph, const SimpleFontData* font, float width)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ Vector<FloatSize, 1024> m_offsets;
};
} // namespace blink
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | Source/platform/fonts/GlyphBufferTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698