Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/GlyphBuffer.h

Issue 2598393002: Do not skip ink for ideographic scripts (Closed)
Patch Set: Fix not to compute twice Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 ASSERT(index < size()); 85 ASSERT(index < size());
86 return hasVerticalOffsets() ? m_offsets[index * 2] : m_offsets[index]; 86 return hasVerticalOffsets() ? m_offsets[index * 2] : m_offsets[index];
87 } 87 }
88 88
89 float yOffsetAt(unsigned index) const { 89 float yOffsetAt(unsigned index) const {
90 ASSERT(index < size()); 90 ASSERT(index < size());
91 ASSERT(hasVerticalOffsets()); 91 ASSERT(hasVerticalOffsets());
92 return m_offsets[index * 2 + 1]; 92 return m_offsets[index * 2 + 1];
93 } 93 }
94 94
95 void add(Glyph glyph, const SimpleFontData* font, float x) { 95 void add(Glyph glyph,
96 const SimpleFontData* font,
97 float x,
98 unsigned characterIndex = 0) {
96 // cannot mix x-only/xy offsets 99 // cannot mix x-only/xy offsets
97 ASSERT(!hasVerticalOffsets()); 100 ASSERT(!hasVerticalOffsets());
98 101
99 m_fontData.append(font); 102 m_fontData.append(font);
100 m_glyphs.append(glyph); 103 m_glyphs.append(glyph);
101 m_offsets.append(x); 104 m_offsets.append(x);
105 if (m_characterIndexes)
106 m_characterIndexes->append(characterIndex);
102 } 107 }
103 108
104 void add(Glyph glyph, const SimpleFontData* font, const FloatPoint& offset) { 109 void add(Glyph glyph,
110 const SimpleFontData* font,
111 const FloatPoint& offset,
112 unsigned characterIndex = 0) {
105 // cannot mix x-only/xy offsets 113 // cannot mix x-only/xy offsets
106 ASSERT(isEmpty() || hasVerticalOffsets()); 114 ASSERT(isEmpty() || hasVerticalOffsets());
107 115
108 m_fontData.append(font); 116 m_fontData.append(font);
109 m_glyphs.append(glyph); 117 m_glyphs.append(glyph);
110 m_offsets.append(offset.x()); 118 m_offsets.append(offset.x());
111 m_offsets.append(offset.y()); 119 m_offsets.append(offset.y());
120 if (m_characterIndexes)
121 m_characterIndexes->append(characterIndex);
112 } 122 }
113 123
114 void reverseForSimpleRTL(float afterOffset, float totalWidth) { 124 void reverseForSimpleRTL(float afterOffset, float totalWidth) {
115 ASSERT(!hasVerticalOffsets()); 125 ASSERT(!hasVerticalOffsets());
116 126
117 if (isEmpty()) 127 if (isEmpty())
118 return; 128 return;
119 129
120 m_fontData.reverse(); 130 m_fontData.reverse();
121 m_glyphs.reverse(); 131 m_glyphs.reverse();
(...skipping 12 matching lines...) Expand all
134 // yield correctly positioned RTL glyphs without any post-shape 144 // yield correctly positioned RTL glyphs without any post-shape
135 // munging). 145 // munging).
136 SECURITY_DCHECK(!m_offsets.isEmpty()); 146 SECURITY_DCHECK(!m_offsets.isEmpty());
137 for (unsigned i = 0; i + 1 < m_offsets.size(); ++i) 147 for (unsigned i = 0; i + 1 < m_offsets.size(); ++i)
138 m_offsets[i] = totalWidth - m_offsets[i + 1]; 148 m_offsets[i] = totalWidth - m_offsets[i + 1];
139 m_offsets.back() = totalWidth - afterOffset; 149 m_offsets.back() = totalWidth - afterOffset;
140 150
141 m_offsets.reverse(); 151 m_offsets.reverse();
142 } 152 }
143 153
154 void saveCharacterIndexes() {
155 m_characterIndexes.reset(new Vector<unsigned, 2048>());
156 }
157
158 unsigned characterIndex(unsigned index) const {
159 DCHECK(m_characterIndexes);
160 return (*m_characterIndexes)[index];
161 }
162
144 protected: 163 protected:
145 Vector<const SimpleFontData*, 2048> m_fontData; 164 Vector<const SimpleFontData*, 2048> m_fontData;
146 Vector<Glyph, 2048> m_glyphs; 165 Vector<Glyph, 2048> m_glyphs;
147 166
148 // Glyph positioning: either x-only offsets, or interleaved x,y offsets 167 // Glyph positioning: either x-only offsets, or interleaved x,y offsets
149 // (depending on the buffer-wide positioning mode). This matches the 168 // (depending on the buffer-wide positioning mode). This matches the
150 // glyph positioning format used by Skia. 169 // glyph positioning format used by Skia.
151 Vector<float, 2048> m_offsets; 170 Vector<float, 2048> m_offsets;
171
172 std::unique_ptr<Vector<unsigned, 2048>> m_characterIndexes;
152 }; 173 };
153 174
154 } // namespace blink 175 } // namespace blink
155 176
156 #endif 177 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698