summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/GlyphBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/GlyphBuffer.h')
-rw-r--r--Source/WebCore/platform/graphics/GlyphBuffer.h87
1 files changed, 51 insertions, 36 deletions
diff --git a/Source/WebCore/platform/graphics/GlyphBuffer.h b/Source/WebCore/platform/graphics/GlyphBuffer.h
index 0305ced0f..5feafb140 100644
--- a/Source/WebCore/platform/graphics/GlyphBuffer.h
+++ b/Source/WebCore/platform/graphics/GlyphBuffer.h
@@ -63,11 +63,32 @@ typedef Glyph GlyphBufferGlyph;
// CG uses CGSize instead of FloatSize so that the result of advances()
// can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm
#if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM)))
-typedef CGSize GlyphBufferAdvance;
+struct GlyphBufferAdvance : CGSize {
+public:
+ GlyphBufferAdvance(CGSize size) : CGSize(size)
+ {
+ }
+
+ void setWidth(CGFloat width) { this->CGSize::width = width; }
+ CGFloat width() const { return this->CGSize::width; }
+ CGFloat height() const { return this->CGSize::height; }
+};
#elif OS(WINCE)
// There is no cross-platform code that uses the height of GlyphBufferAdvance,
// so we can save memory space on embedded devices by storing only the width
-typedef float GlyphBufferAdvance;
+struct GlyphBufferAdvance {
+public:
+ GlyphBufferAdvance(float width)
+ : advance(width)
+ {
+ }
+
+ void setWidth(float width) { advance = width; }
+ float width() const { return advance; }
+
+private:
+ float advance;
+};
#else
typedef FloatSize GlyphBufferAdvance;
#endif
@@ -94,27 +115,6 @@ public:
const SimpleFontData* fontDataAt(int index) const { return m_fontData[index]; }
- void swap(int index1, int index2)
- {
- const SimpleFontData* f = m_fontData[index1];
- m_fontData[index1] = m_fontData[index2];
- m_fontData[index2] = f;
-
- GlyphBufferGlyph g = m_glyphs[index1];
- m_glyphs[index1] = m_glyphs[index2];
- m_glyphs[index2] = g;
-
- GlyphBufferAdvance s = m_advances[index1];
- m_advances[index1] = m_advances[index2];
- m_advances[index2] = s;
-
-#if PLATFORM(WIN)
- FloatSize offset = m_offsets[index1];
- m_offsets[index1] = m_offsets[index2];
- m_offsets[index2] = offset;
-#endif
- }
-
Glyph glyphAt(int index) const
{
#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
@@ -126,13 +126,7 @@ public:
float advanceAt(int index) const
{
-#if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM)))
- return m_advances[index].width;
-#elif OS(WINCE)
- return m_advances[index];
-#else
return m_advances[index].width();
-#endif
}
FloatSize offsetAt(int index) const
@@ -192,20 +186,41 @@ public:
}
#endif
+ void reverse(int from, int length)
+ {
+ for (int i = from, end = from + length - 1; i < end; ++i, --end)
+ swap(i, end);
+ }
+
void expandLastAdvance(float width)
{
ASSERT(!isEmpty());
GlyphBufferAdvance& lastAdvance = m_advances.last();
-#if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM)))
- lastAdvance.width += width;
-#elif OS(WINCE)
- lastAdvance += width;
-#else
- lastAdvance += FloatSize(width, 0);
-#endif
+ lastAdvance.setWidth(lastAdvance.width() + width);
}
private:
+ void swap(int index1, int index2)
+ {
+ const SimpleFontData* f = m_fontData[index1];
+ m_fontData[index1] = m_fontData[index2];
+ m_fontData[index2] = f;
+
+ GlyphBufferGlyph g = m_glyphs[index1];
+ m_glyphs[index1] = m_glyphs[index2];
+ m_glyphs[index2] = g;
+
+ GlyphBufferAdvance s = m_advances[index1];
+ m_advances[index1] = m_advances[index2];
+ m_advances[index2] = s;
+
+#if PLATFORM(WIN)
+ FloatSize offset = m_offsets[index1];
+ m_offsets[index1] = m_offsets[index2];
+ m_offsets[index2] = offset;
+#endif
+ }
+
Vector<const SimpleFontData*, 2048> m_fontData;
Vector<GlyphBufferGlyph, 2048> m_glyphs;
Vector<GlyphBufferAdvance, 2048> m_advances;