| 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 25 matching lines...) Expand all Loading... |
| 36 #include <wtf/Vector.h> | 36 #include <wtf/Vector.h> |
| 37 | 37 |
| 38 #if USE(CG) | 38 #if USE(CG) |
| 39 #include <CoreGraphics/CGGeometry.h> | 39 #include <CoreGraphics/CGGeometry.h> |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM)) | 42 #if OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM)) |
| 43 #include <ApplicationServices/ApplicationServices.h> | 43 #include <ApplicationServices/ApplicationServices.h> |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO) | |
| 47 #include <cairo.h> | |
| 48 #endif | |
| 49 | |
| 50 namespace WebCore { | 46 namespace WebCore { |
| 51 | 47 |
| 52 class SimpleFontData; | 48 class SimpleFontData; |
| 53 | 49 |
| 54 #if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO) | 50 #if OS(WINCE) |
| 55 // FIXME: Why does Cairo use such a huge struct instead of just an offset into a
n array? | |
| 56 typedef cairo_glyph_t GlyphBufferGlyph; | |
| 57 #elif OS(WINCE) | |
| 58 typedef wchar_t GlyphBufferGlyph; | 51 typedef wchar_t GlyphBufferGlyph; |
| 59 #elif PLATFORM(QT) | 52 #elif PLATFORM(QT) |
| 60 typedef quint32 GlyphBufferGlyph; | 53 typedef quint32 GlyphBufferGlyph; |
| 61 #else | 54 #else |
| 62 typedef Glyph GlyphBufferGlyph; | 55 typedef Glyph GlyphBufferGlyph; |
| 63 #endif | 56 #endif |
| 64 | 57 |
| 65 // CG uses CGSize instead of FloatSize so that the result of advances() | 58 // CG uses CGSize instead of FloatSize so that the result of advances() |
| 66 // can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm | 59 // can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm |
| 67 #if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM))) | 60 #if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM))) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 117 |
| 125 GlyphBufferGlyph* glyphs(int from) { return m_glyphs.data() + from; } | 118 GlyphBufferGlyph* glyphs(int from) { return m_glyphs.data() + from; } |
| 126 GlyphBufferAdvance* advances(int from) { return m_advances.data() + from; } | 119 GlyphBufferAdvance* advances(int from) { return m_advances.data() + from; } |
| 127 const GlyphBufferGlyph* glyphs(int from) const { return m_glyphs.data() + fr
om; } | 120 const GlyphBufferGlyph* glyphs(int from) const { return m_glyphs.data() + fr
om; } |
| 128 const GlyphBufferAdvance* advances(int from) const { return m_advances.data(
) + from; } | 121 const GlyphBufferAdvance* advances(int from) const { return m_advances.data(
) + from; } |
| 129 | 122 |
| 130 const SimpleFontData* fontDataAt(int index) const { return m_fontData[index]
; } | 123 const SimpleFontData* fontDataAt(int index) const { return m_fontData[index]
; } |
| 131 | 124 |
| 132 Glyph glyphAt(int index) const | 125 Glyph glyphAt(int index) const |
| 133 { | 126 { |
| 134 #if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO) | |
| 135 return m_glyphs[index].index; | |
| 136 #else | |
| 137 return m_glyphs[index]; | 127 return m_glyphs[index]; |
| 138 #endif | |
| 139 } | 128 } |
| 140 | 129 |
| 141 float advanceAt(int index) const | 130 float advanceAt(int index) const |
| 142 { | 131 { |
| 143 return m_advances[index].width(); | 132 return m_advances[index].width(); |
| 144 } | 133 } |
| 145 | 134 |
| 146 FloatSize offsetAt(int index) const | 135 FloatSize offsetAt(int index) const |
| 147 { | 136 { |
| 148 #if PLATFORM(WIN) | 137 #if PLATFORM(WIN) |
| 149 return m_offsets[index]; | 138 return m_offsets[index]; |
| 150 #else | 139 #else |
| 151 UNUSED_PARAM(index); | 140 UNUSED_PARAM(index); |
| 152 return FloatSize(); | 141 return FloatSize(); |
| 153 #endif | 142 #endif |
| 154 } | 143 } |
| 155 | 144 |
| 156 void add(Glyph glyph, const SimpleFontData* font, float width, const FloatSi
ze* offset = 0) | 145 void add(Glyph glyph, const SimpleFontData* font, float width, const FloatSi
ze* offset = 0) |
| 157 { | 146 { |
| 158 m_fontData.append(font); | 147 m_fontData.append(font); |
| 159 | |
| 160 #if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO) | |
| 161 cairo_glyph_t cairoGlyph; | |
| 162 cairoGlyph.index = glyph; | |
| 163 m_glyphs.append(cairoGlyph); | |
| 164 #else | |
| 165 m_glyphs.append(glyph); | 148 m_glyphs.append(glyph); |
| 166 #endif | |
| 167 | 149 |
| 168 #if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM))) | 150 #if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM))) |
| 169 CGSize advance = { width, 0 }; | 151 CGSize advance = { width, 0 }; |
| 170 m_advances.append(advance); | 152 m_advances.append(advance); |
| 171 #elif OS(WINCE) | 153 #elif OS(WINCE) |
| 172 m_advances.append(width); | 154 m_advances.append(width); |
| 173 #elif PLATFORM(QT) | 155 #elif PLATFORM(QT) |
| 174 m_advances.append(QPointF(width, 0)); | 156 m_advances.append(QPointF(width, 0)); |
| 175 #else | 157 #else |
| 176 m_advances.append(FloatSize(width, 0)); | 158 m_advances.append(FloatSize(width, 0)); |
| 177 #endif | 159 #endif |
| 178 | 160 |
| 179 #if PLATFORM(WIN) | 161 #if PLATFORM(WIN) |
| 180 if (offset) | 162 if (offset) |
| 181 m_offsets.append(*offset); | 163 m_offsets.append(*offset); |
| 182 else | 164 else |
| 183 m_offsets.append(FloatSize()); | 165 m_offsets.append(FloatSize()); |
| 184 #else | 166 #else |
| 185 UNUSED_PARAM(offset); | 167 UNUSED_PARAM(offset); |
| 186 #endif | 168 #endif |
| 187 } | 169 } |
| 188 | 170 |
| 189 #if !OS(WINCE) | 171 #if !OS(WINCE) |
| 190 void add(Glyph glyph, const SimpleFontData* font, GlyphBufferAdvance advance
) | 172 void add(Glyph glyph, const SimpleFontData* font, GlyphBufferAdvance advance
) |
| 191 { | 173 { |
| 192 m_fontData.append(font); | 174 m_fontData.append(font); |
| 193 #if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO) | |
| 194 cairo_glyph_t cairoGlyph; | |
| 195 cairoGlyph.index = glyph; | |
| 196 m_glyphs.append(cairoGlyph); | |
| 197 #else | |
| 198 m_glyphs.append(glyph); | 175 m_glyphs.append(glyph); |
| 199 #endif | |
| 200 | |
| 201 m_advances.append(advance); | 176 m_advances.append(advance); |
| 202 } | 177 } |
| 203 #endif | 178 #endif |
| 204 | 179 |
| 205 void reverse(int from, int length) | 180 void reverse(int from, int length) |
| 206 { | 181 { |
| 207 for (int i = from, end = from + length - 1; i < end; ++i, --end) | 182 for (int i = from, end = from + length - 1; i < end; ++i, --end) |
| 208 swap(i, end); | 183 swap(i, end); |
| 209 } | 184 } |
| 210 | 185 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 240 Vector<const SimpleFontData*, 2048> m_fontData; | 215 Vector<const SimpleFontData*, 2048> m_fontData; |
| 241 Vector<GlyphBufferGlyph, 2048> m_glyphs; | 216 Vector<GlyphBufferGlyph, 2048> m_glyphs; |
| 242 Vector<GlyphBufferAdvance, 2048> m_advances; | 217 Vector<GlyphBufferAdvance, 2048> m_advances; |
| 243 #if PLATFORM(WIN) | 218 #if PLATFORM(WIN) |
| 244 Vector<FloatSize, 2048> m_offsets; | 219 Vector<FloatSize, 2048> m_offsets; |
| 245 #endif | 220 #endif |
| 246 }; | 221 }; |
| 247 | 222 |
| 248 } | 223 } |
| 249 #endif | 224 #endif |
| OLD | NEW |