OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2009, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007-2008 Torch Mobile Inc. | 3 * Copyright (C) 2007-2008 Torch Mobile Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
36 | 36 |
37 #if OS(MACOSX) | 37 #if OS(MACOSX) |
38 #include <ApplicationServices/ApplicationServices.h> | 38 #include <ApplicationServices/ApplicationServices.h> |
39 #endif | 39 #endif |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 class SimpleFontData; | 43 class SimpleFontData; |
44 | 44 |
45 typedef Glyph GlyphBufferGlyph; | |
46 | |
47 // CG uses CGSize instead of FloatSize so that the result of advances() | 45 // CG uses CGSize instead of FloatSize so that the result of advances() |
48 // can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm | 46 // can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm |
49 #if OS(MACOSX) | 47 #if OS(MACOSX) |
50 struct GlyphBufferAdvance : CGSize { | 48 struct GlyphBufferAdvance : CGSize { |
51 public: | 49 public: |
52 GlyphBufferAdvance(CGSize size) : CGSize(size) | 50 GlyphBufferAdvance(CGSize size) : CGSize(size) |
53 { | 51 { |
54 } | 52 } |
55 | 53 |
56 void setWidth(CGFloat width) { this->CGSize::width = width; } | 54 void setWidth(CGFloat width) { this->CGSize::width = width; } |
57 CGFloat width() const { return this->CGSize::width; } | 55 CGFloat width() const { return this->CGSize::width; } |
58 CGFloat height() const { return this->CGSize::height; } | 56 CGFloat height() const { return this->CGSize::height; } |
59 }; | 57 }; |
60 #else | 58 #else |
61 typedef FloatSize GlyphBufferAdvance; | 59 typedef FloatSize GlyphBufferAdvance; |
62 #endif | 60 #endif |
63 | 61 |
64 class GlyphBuffer { | 62 class GlyphBuffer { |
65 public: | 63 public: |
66 bool isEmpty() const { return m_fontData.isEmpty(); } | 64 bool isEmpty() const { return m_fontData.isEmpty(); } |
67 unsigned size() const { return m_fontData.size(); } | 65 unsigned size() const { return m_fontData.size(); } |
68 | 66 |
69 void clear() | 67 void clear() |
70 { | 68 { |
71 m_fontData.clear(); | 69 m_fontData.clear(); |
72 m_glyphs.clear(); | 70 m_glyphs.clear(); |
73 m_advances.clear(); | 71 m_advances.clear(); |
74 } | 72 } |
75 | 73 |
76 GlyphBufferGlyph* glyphs(unsigned from) { return m_glyphs.data() + from; } | 74 Glyph* glyphs(unsigned from) { return m_glyphs.data() + from; } |
77 GlyphBufferAdvance* advances(unsigned from) { return m_advances.data() + fro
m; } | 75 GlyphBufferAdvance* advances(unsigned from) { return m_advances.data() + fro
m; } |
78 const GlyphBufferGlyph* glyphs(unsigned from) const { return m_glyphs.data()
+ from; } | 76 const Glyph* glyphs(unsigned from) const { return m_glyphs.data() + from; } |
79 const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.
data() + from; } | 77 const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.
data() + from; } |
80 | 78 |
81 const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[i
ndex]; } | 79 const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[i
ndex]; } |
82 | 80 |
83 Glyph glyphAt(unsigned index) const | 81 Glyph glyphAt(unsigned index) const |
84 { | 82 { |
85 return m_glyphs[index]; | 83 return m_glyphs[index]; |
86 } | 84 } |
87 | 85 |
88 FloatSize advanceAt(unsigned index) const | 86 FloatSize advanceAt(unsigned index) const |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 lastAdvance.setWidth(lastAdvance.width() + width); | 125 lastAdvance.setWidth(lastAdvance.width() + width); |
128 } | 126 } |
129 | 127 |
130 private: | 128 private: |
131 void swap(unsigned index1, unsigned index2) | 129 void swap(unsigned index1, unsigned index2) |
132 { | 130 { |
133 const SimpleFontData* f = m_fontData[index1]; | 131 const SimpleFontData* f = m_fontData[index1]; |
134 m_fontData[index1] = m_fontData[index2]; | 132 m_fontData[index1] = m_fontData[index2]; |
135 m_fontData[index2] = f; | 133 m_fontData[index2] = f; |
136 | 134 |
137 GlyphBufferGlyph g = m_glyphs[index1]; | 135 Glyph g = m_glyphs[index1]; |
138 m_glyphs[index1] = m_glyphs[index2]; | 136 m_glyphs[index1] = m_glyphs[index2]; |
139 m_glyphs[index2] = g; | 137 m_glyphs[index2] = g; |
140 | 138 |
141 GlyphBufferAdvance s = m_advances[index1]; | 139 GlyphBufferAdvance s = m_advances[index1]; |
142 m_advances[index1] = m_advances[index2]; | 140 m_advances[index1] = m_advances[index2]; |
143 m_advances[index2] = s; | 141 m_advances[index2] = s; |
144 } | 142 } |
145 | 143 |
146 Vector<const SimpleFontData*, 2048> m_fontData; | 144 Vector<const SimpleFontData*, 2048> m_fontData; |
147 Vector<GlyphBufferGlyph, 2048> m_glyphs; | 145 Vector<Glyph, 2048> m_glyphs; |
148 Vector<GlyphBufferAdvance, 2048> m_advances; | 146 Vector<GlyphBufferAdvance, 2048> m_advances; |
149 }; | 147 }; |
150 | 148 |
151 } | 149 } |
152 #endif | 150 #endif |
OLD | NEW |