| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 public: | 45 public: |
| 46 bool isEmpty() const { return m_fontData.isEmpty(); } | 46 bool isEmpty() const { return m_fontData.isEmpty(); } |
| 47 unsigned size() const { | 47 unsigned size() const { |
| 48 ASSERT(m_fontData.size() == m_glyphs.size()); | 48 ASSERT(m_fontData.size() == m_glyphs.size()); |
| 49 ASSERT(m_fontData.size() == m_offsets.size() || | 49 ASSERT(m_fontData.size() == m_offsets.size() || |
| 50 2 * m_fontData.size() == m_offsets.size()); | 50 2 * m_fontData.size() == m_offsets.size()); |
| 51 return m_fontData.size(); | 51 return m_fontData.size(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool hasVerticalOffsets() const { | 54 bool hasVerticalOffsets() const { |
| 55 // We exclusively store either horizontal/x-only ofssets -- in which case m_
offsets.size == size, | 55 // We exclusively store either horizontal/x-only ofssets -- in which case |
| 56 // or vertical/xy offsets -- in which case m_offsets.size == size * 2. | 56 // m_offsets.size == size, or vertical/xy offsets -- in which case |
| 57 // m_offsets.size == size * 2. |
| 57 return size() != m_offsets.size(); | 58 return size() != m_offsets.size(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 const Glyph* glyphs(unsigned from) const { | 61 const Glyph* glyphs(unsigned from) const { |
| 61 ASSERT(from < size()); | 62 ASSERT(from < size()); |
| 62 return m_glyphs.data() + from; | 63 return m_glyphs.data() + from; |
| 63 } | 64 } |
| 64 | 65 |
| 65 // Depending on the GlyphBuffer-wide positioning mode, this either points to a
n array of | 66 // Depending on the GlyphBuffer-wide positioning mode, this either points to |
| 66 // x-only offsets for horizontal positioning ([x1, x2, ... xn]), or interleave
d x,y offsets | 67 // an array of x-only offsets for horizontal positioning ([x1, x2, ... xn]), |
| 67 // for full positioning ([x1, y1, x2, y2, ... xn, yn]). | 68 // or interleaved x,y offsets for full positioning ([x1, y1, ... xn, yn]). |
| 68 const float* offsets(unsigned from) const { | 69 const float* offsets(unsigned from) const { |
| 69 ASSERT(from < size()); | 70 ASSERT(from < size()); |
| 70 return m_offsets.data() + (hasVerticalOffsets() ? from * 2 : from); | 71 return m_offsets.data() + (hasVerticalOffsets() ? from * 2 : from); |
| 71 } | 72 } |
| 72 | 73 |
| 73 const SimpleFontData* fontDataAt(unsigned index) const { | 74 const SimpleFontData* fontDataAt(unsigned index) const { |
| 74 ASSERT(index < size()); | 75 ASSERT(index < size()); |
| 75 return m_fontData[index]; | 76 return m_fontData[index]; |
| 76 } | 77 } |
| 77 | 78 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 if (isEmpty()) | 117 if (isEmpty()) |
| 117 return; | 118 return; |
| 118 | 119 |
| 119 m_fontData.reverse(); | 120 m_fontData.reverse(); |
| 120 m_glyphs.reverse(); | 121 m_glyphs.reverse(); |
| 121 | 122 |
| 122 // | .. [X0 X1 .. Xn] .. | | 123 // | .. [X0 X1 .. Xn] .. | |
| 123 // ^ ^ ^ | 124 // ^ ^ ^ |
| 124 // 0 afterOffset totalWidth | 125 // 0 afterOffset totalWidth |
| 125 // | 126 // |
| 126 // The input buffer is shaped using RTL advances, but since the right edge i
s unknown at | 127 // The input buffer is shaped using RTL advances, but since the right edge |
| 127 // that time, offsets are computed as if the advances were LTR. This method
performs the | 128 // is unknown at that time, offsets are computed as if the advances were |
| 128 // required adjustments by reconstructing advances and positioning offsets i
n an RTL | 129 // LTR. This method performs the required adjustments by reconstructing |
| 129 // progression. | 130 // advances and positioning offsets in an RTL progression. |
| 130 | 131 |
| 131 // FIXME: we should get rid of this (idea: store negative offsets while shap
ing, | 132 // FIXME: we should get rid of this (idea: store negative offsets while |
| 132 // and adjust the initial advance accordingly -> should yield correct
ly positioned | 133 // shaping, and adjust the initial advance accordingly -> should |
| 133 // RTL glyphs without any post-shape munging). | 134 // yield correctly positioned RTL glyphs without any post-shape |
| 135 // munging). |
| 134 ASSERT_WITH_SECURITY_IMPLICATION(!m_offsets.isEmpty()); | 136 ASSERT_WITH_SECURITY_IMPLICATION(!m_offsets.isEmpty()); |
| 135 for (unsigned i = 0; i + 1 < m_offsets.size(); ++i) | 137 for (unsigned i = 0; i + 1 < m_offsets.size(); ++i) |
| 136 m_offsets[i] = totalWidth - m_offsets[i + 1]; | 138 m_offsets[i] = totalWidth - m_offsets[i + 1]; |
| 137 m_offsets.last() = totalWidth - afterOffset; | 139 m_offsets.last() = totalWidth - afterOffset; |
| 138 | 140 |
| 139 m_offsets.reverse(); | 141 m_offsets.reverse(); |
| 140 } | 142 } |
| 141 | 143 |
| 142 protected: | 144 protected: |
| 143 Vector<const SimpleFontData*, 2048> m_fontData; | 145 Vector<const SimpleFontData*, 2048> m_fontData; |
| 144 Vector<Glyph, 2048> m_glyphs; | 146 Vector<Glyph, 2048> m_glyphs; |
| 145 | 147 |
| 146 // Glyph positioning: either x-only offsets, or interleaved x,y offsets | 148 // Glyph positioning: either x-only offsets, or interleaved x,y offsets |
| 147 // (depending on the buffer-wide positioning mode). This matches the | 149 // (depending on the buffer-wide positioning mode). This matches the |
| 148 // glyph positioning format used by Skia. | 150 // glyph positioning format used by Skia. |
| 149 Vector<float, 2048> m_offsets; | 151 Vector<float, 2048> m_offsets; |
| 150 }; | 152 }; |
| 151 | 153 |
| 152 } // namespace blink | 154 } // namespace blink |
| 153 | 155 |
| 154 #endif | 156 #endif |
| OLD | NEW |