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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 add(glyph, font, FloatSize(width, 0)); | 72 add(glyph, font, FloatSize(width, 0)); |
73 } | 73 } |
74 | 74 |
75 void add(Glyph glyph, const SimpleFontData* font, const FloatSize& advance) | 75 void add(Glyph glyph, const SimpleFontData* font, const FloatSize& advance) |
76 { | 76 { |
77 m_fontData.append(font); | 77 m_fontData.append(font); |
78 m_glyphs.append(glyph); | 78 m_glyphs.append(glyph); |
79 m_advances.append(advance); | 79 m_advances.append(advance); |
80 } | 80 } |
81 | 81 |
82 void reverse(unsigned from, unsigned length) | 82 void reverse() |
83 { | 83 { |
84 for (unsigned i = from, end = from + length - 1; i < end; ++i, --end) | 84 m_fontData.reverse(); |
85 swap(i, end); | 85 m_glyphs.reverse(); |
| 86 m_advances.reverse(); |
86 } | 87 } |
87 | 88 |
88 void expandLastAdvance(float width) | 89 void expandLastAdvance(float width) |
89 { | 90 { |
90 ASSERT(!isEmpty()); | 91 ASSERT(!isEmpty()); |
91 FloatSize& lastAdvance = m_advances.last(); | 92 FloatSize& lastAdvance = m_advances.last(); |
92 lastAdvance.setWidth(lastAdvance.width() + width); | 93 lastAdvance.setWidth(lastAdvance.width() + width); |
93 } | 94 } |
94 | 95 |
95 private: | 96 private: |
96 void swap(unsigned index1, unsigned index2) | |
97 { | |
98 const SimpleFontData* f = m_fontData[index1]; | |
99 m_fontData[index1] = m_fontData[index2]; | |
100 m_fontData[index2] = f; | |
101 | |
102 Glyph g = m_glyphs[index1]; | |
103 m_glyphs[index1] = m_glyphs[index2]; | |
104 m_glyphs[index2] = g; | |
105 | |
106 FloatSize s = m_advances[index1]; | |
107 m_advances[index1] = m_advances[index2]; | |
108 m_advances[index2] = s; | |
109 } | |
110 | |
111 Vector<const SimpleFontData*, 2048> m_fontData; | 97 Vector<const SimpleFontData*, 2048> m_fontData; |
112 Vector<Glyph, 2048> m_glyphs; | 98 Vector<Glyph, 2048> m_glyphs; |
113 Vector<FloatSize, 2048> m_advances; | 99 Vector<FloatSize, 2048> m_advances; |
114 }; | 100 }; |
115 | 101 |
116 } | 102 } |
117 #endif | 103 #endif |
OLD | NEW |