Index: Source/platform/fonts/GlyphBuffer.h |
diff --git a/Source/platform/fonts/GlyphBuffer.h b/Source/platform/fonts/GlyphBuffer.h |
index 5ca769b548f2922eccef52c32b1749d8b77e8aba..e3b8a016028b426b2be2d0a77fef4f8e45cf8c92 100644 |
--- a/Source/platform/fonts/GlyphBuffer.h |
+++ b/Source/platform/fonts/GlyphBuffer.h |
@@ -40,22 +40,24 @@ class SimpleFontData; |
class GlyphBuffer { |
public: |
- GlyphBuffer() : m_hasVerticalAdvances(false) { } |
+ GlyphBuffer() { } |
bool isEmpty() const { return m_fontData.isEmpty(); } |
+ bool hasOffsets() const { return !m_offsets.isEmpty(); } |
unsigned size() const { return m_fontData.size(); } |
- bool hasVerticalAdvances() const { return m_hasVerticalAdvances; } |
+ void reserveOffsetsCapacity(size_t size) { m_offsets.reserveCapacity(size); } |
jbroman
2014/09/25 17:03:31
This seems like an odd method to have. Why not jus
eae
2014/09/26 05:26:51
Good point, I'll rename it and change it to operat
|
void clear() |
{ |
m_fontData.clear(); |
m_glyphs.clear(); |
+ m_offsets.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 FloatSize* offsets(unsigned from) const { return m_offsets.data() + from; } |
+ const float* advances(unsigned from) const { return m_advances.data() + from; } |
const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[index]; } |
@@ -64,7 +66,12 @@ public: |
return m_glyphs[index]; |
} |
- FloatSize advanceAt(unsigned index) const |
+ FloatSize offsetAt(unsigned index) const |
+ { |
+ return m_offsets[index]; |
+ } |
+ |
+ float advanceAt(unsigned index) const |
{ |
return m_advances[index]; |
} |
@@ -73,42 +80,37 @@ public: |
{ |
jbroman
2014/09/25 17:03:32
Could we do something to ensure callers don't wind
eae
2014/09/26 05:26:51
Yeah, I was thinking about that, I don't really wa
|
m_fontData.append(font); |
m_glyphs.append(glyph); |
- m_advances.append(FloatSize(width, 0)); |
+ m_advances.append(width); |
} |
- void add(Glyph glyph, const SimpleFontData* font, const FloatSize& advance) |
+ void add(Glyph glyph, const SimpleFontData* font, const FloatSize& offset, float advance = 0) |
{ |
m_fontData.append(font); |
m_glyphs.append(glyph); |
+ m_offsets.append(offset); |
m_advances.append(advance); |
- if (advance.height()) |
- m_hasVerticalAdvances = true; |
} |
void reverse() |
{ |
m_fontData.reverse(); |
m_glyphs.reverse(); |
+ m_offsets.reverse(); |
jbroman
2014/09/25 17:11:35
Are these offsets from the text origin, or from th
|
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: |
Vector<const SimpleFontData*, 2048> m_fontData; |
Vector<Glyph, 2048> m_glyphs; |
- Vector<FloatSize, 2048> m_advances; |
- bool m_hasVerticalAdvances; |
+ Vector<float, 2048> m_advances; |
+ Vector<FloatSize> m_offsets; |
f(malita)
2014/09/25 16:42:05
Why no inline capacity for m_offsets? Using stack-
eae
2014/09/26 05:26:51
As explained in the CL description the m_offsets f
|
}; |
} // namespace blink |