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

Side by Side Diff: third_party/harfbuzz-ng/src/hb-ot-map.cc

Issue 16053004: Update harfbuzz-ng to 0.9.17 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright © 2009,2010 Red Hat, Inc. 2 * Copyright © 2009,2010 Red Hat, Inc.
3 * Copyright © 2010,2011 Google, Inc. 3 * Copyright © 2010,2011,2013 Google, Inc.
4 * 4 *
5 * This is part of HarfBuzz, a text shaping library. 5 * This is part of HarfBuzz, a text shaping library.
6 * 6 *
7 * Permission is hereby granted, without written agreement and without 7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this 8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the 9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in 10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software. 11 * all copies of this software.
12 * 12 *
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE. 17 * DAMAGE.
18 * 18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * 24 *
25 * Red Hat Author(s): Behdad Esfahbod 25 * Red Hat Author(s): Behdad Esfahbod
26 * Google Author(s): Behdad Esfahbod 26 * Google Author(s): Behdad Esfahbod
27 */ 27 */
28 28
29 #include "hb-ot-map-private.hh" 29 #include "hb-ot-map-private.hh"
30 30
31 #include "hb-ot-layout-private.hh"
32
31 33
32 void 34 void
33 hb_ot_map_t::add_lookups (hb_face_t *face, 35 hb_ot_map_t::add_lookups (hb_face_t *face,
34 unsigned int table_index, 36 unsigned int table_index,
35 unsigned int feature_index, 37 unsigned int feature_index,
36 hb_mask_t mask, 38 hb_mask_t mask,
37 bool auto_zwj) 39 bool auto_zwj)
38 { 40 {
39 unsigned int lookup_indices[32]; 41 unsigned int lookup_indices[32];
40 unsigned int offset, len; 42 unsigned int offset, len;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (unlikely (!info)) return; 95 if (unlikely (!info)) return;
94 info->tag = tag; 96 info->tag = tag;
95 info->seq = feature_infos.len; 97 info->seq = feature_infos.len;
96 info->max_value = value; 98 info->max_value = value;
97 info->flags = flags; 99 info->flags = flags;
98 info->default_value = (flags & F_GLOBAL) ? value : 0; 100 info->default_value = (flags & F_GLOBAL) ? value : 0;
99 info->stage[0] = current_stage[0]; 101 info->stage[0] = current_stage[0];
100 info->stage[1] = current_stage[1]; 102 info->stage[1] = current_stage[1];
101 } 103 }
102 104
103 /* Keep the next two functions in sync. */ 105 inline void hb_ot_map_t::apply (unsigned int table_index,
106 » » » » const hb_ot_shape_plan_t *plan,
107 » » » » hb_font_t *font,
108 » » » » hb_buffer_t *buffer) const
109 {
110 unsigned int i = 0;
111
112 for (unsigned int stage_index = 0; stage_index < stages[table_index].len; stag e_index++) {
113 const stage_map_t *stage = &stages[table_index][stage_index];
114 for (; i < stage->last_lookup; i++)
115 switch (table_index)
116 {
117 case 0:
118 » hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i]. index,
119 » » » » » lookups[table_index][i].mask,
120 » » » » » lookups[table_index][i].auto_zwj);
121 » break;
122
123 » case 1:
124 » hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].in dex,
125 » » » » » lookups[table_index][i].mask,
126 » » » » » lookups[table_index][i].auto_zwj);
127 » break;
128 }
129
130 if (stage->pause_func)
131 {
132 buffer->clear_output ();
133 stage->pause_func (plan, font, buffer);
134 }
135 }
136 }
104 137
105 void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, h b_buffer_t *buffer) const 138 void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, h b_buffer_t *buffer) const
106 { 139 {
107 const unsigned int table_index = 0; 140 apply (0, plan, font, buffer);
108 unsigned int i = 0;
109
110 for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; paus e_index++) {
111 const pause_map_t *pause = &pauses[table_index][pause_index];
112 for (; i < pause->num_lookups; i++)
113 hb_ot_layout_substitute_lookup (font, buffer,
114 » » » » lookups[table_index][i].index,
115 » » » » lookups[table_index][i].mask,
116 » » » » lookups[table_index][i].auto_zwj);
117
118 buffer->clear_output ();
119
120 if (pause->callback)
121 pause->callback (plan, font, buffer);
122 }
123
124 for (; i < lookups[table_index].len; i++)
125 hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index,
126 » » » » lookups[table_index][i].mask,
127 » » » » lookups[table_index][i].auto_zwj);
128 } 141 }
129 142
130 void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_ buffer_t *buffer) const 143 void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_ buffer_t *buffer) const
131 { 144 {
132 const unsigned int table_index = 1; 145 apply (1, plan, font, buffer);
133 unsigned int i = 0; 146 }
134 147
135 for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; paus e_index++) {
136 const pause_map_t *pause = &pauses[table_index][pause_index];
137 for (; i < pause->num_lookups; i++)
138 hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index,
139 lookups[table_index][i].mask,
140 lookups[table_index][i].auto_zwj);
141
142 if (pause->callback)
143 pause->callback (plan, font, buffer);
144 }
145
146 for (; i < lookups[table_index].len; i++)
147 hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index,
148 lookups[table_index][i].mask,
149 lookups[table_index][i].auto_zwj);
150 }
151 148
152 void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_o ut) const 149 void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_o ut) const
153 { 150 {
154 for (unsigned int i = 0; i < lookups[table_index].len; i++) 151 for (unsigned int i = 0; i < lookups[table_index].len; i++)
155 hb_set_add (lookups_out, lookups[table_index][i].index); 152 hb_set_add (lookups_out, lookups[table_index][i].index);
156 } 153 }
157 154
158 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus e_func_t pause_func) 155 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus e_func_t pause_func)
159 { 156 {
160 pause_info_t *p = pauses[table_index].push (); 157 stage_info_t *s = stages[table_index].push ();
161 if (likely (p)) { 158 if (likely (s)) {
162 p->stage = current_stage[table_index]; 159 s->index = current_stage[table_index];
163 p->callback = pause_func; 160 s->pause_func = pause_func;
164 } 161 }
165 162
166 current_stage[table_index]++; 163 current_stage[table_index]++;
167 } 164 }
168 165
169 void 166 void
170 hb_ot_map_builder_t::compile (hb_ot_map_t &m) 167 hb_ot_map_builder_t::compile (hb_ot_map_t &m)
171 { 168 {
172 m.global_mask = 1; 169 m.global_mask = 1;
173 170
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 /* Collect lookup indices for features */ 267 /* Collect lookup indices for features */
271 268
272 unsigned int required_feature_index; 269 unsigned int required_feature_index;
273 if (hb_ot_layout_language_get_required_feature_index (face, 270 if (hb_ot_layout_language_get_required_feature_index (face,
274 table_tag, 271 table_tag,
275 script_index[table_ind ex], 272 script_index[table_ind ex],
276 language_index[table_i ndex], 273 language_index[table_i ndex],
277 &required_feature_inde x)) 274 &required_feature_inde x))
278 m.add_lookups (face, table_index, required_feature_index, 1, true); 275 m.add_lookups (face, table_index, required_feature_index, 1, true);
279 276
280 unsigned int pause_index = 0; 277 unsigned int stage_index = 0;
281 unsigned int last_num_lookups = 0; 278 unsigned int last_num_lookups = 0;
282 for (unsigned stage = 0; stage < current_stage[table_index]; stage++) 279 for (unsigned stage = 0; stage < current_stage[table_index]; stage++)
283 { 280 {
284 for (unsigned i = 0; i < m.features.len; i++) 281 for (unsigned i = 0; i < m.features.len; i++)
285 if (m.features[i].stage[table_index] == stage) 282 if (m.features[i].stage[table_index] == stage)
286 m.add_lookups (face, table_index, 283 m.add_lookups (face, table_index,
287 m.features[i].index[table_index], 284 m.features[i].index[table_index],
288 m.features[i].mask, 285 m.features[i].mask,
289 m.features[i].auto_zwj); 286 m.features[i].auto_zwj);
290 287
291 /* Sort lookups and merge duplicates */ 288 /* Sort lookups and merge duplicates */
292 if (last_num_lookups < m.lookups[table_index].len) 289 if (last_num_lookups < m.lookups[table_index].len)
293 { 290 {
294 m.lookups[table_index].sort (last_num_lookups, m.lookups[table_index].le n); 291 m.lookups[table_index].sort (last_num_lookups, m.lookups[table_index].le n);
295 292
296 unsigned int j = last_num_lookups; 293 unsigned int j = last_num_lookups;
297 for (unsigned int i = j + 1; i < m.lookups[table_index].len; i++) 294 for (unsigned int i = j + 1; i < m.lookups[table_index].len; i++)
298 if (m.lookups[table_index][i].index != m.lookups[table_index][j].index ) 295 if (m.lookups[table_index][i].index != m.lookups[table_index][j].index )
299 m.lookups[table_index][++j] = m.lookups[table_index][i]; 296 m.lookups[table_index][++j] = m.lookups[table_index][i];
300 else 297 else
301 { 298 {
302 m.lookups[table_index][j].mask |= m.lookups[table_index][i].mask; 299 m.lookups[table_index][j].mask |= m.lookups[table_index][i].mask;
303 m.lookups[table_index][j].auto_zwj &= m.lookups[table_index][i].auto _zwj; 300 m.lookups[table_index][j].auto_zwj &= m.lookups[table_index][i].auto _zwj;
304 } 301 }
305 m.lookups[table_index].shrink (j + 1); 302 m.lookups[table_index].shrink (j + 1);
306 } 303 }
307 304
308 last_num_lookups = m.lookups[table_index].len; 305 last_num_lookups = m.lookups[table_index].len;
309 306
310 if (pause_index < pauses[table_index].len && pauses[table_index][pause_ind ex].stage == stage) { 307 if (stage_index < stages[table_index].len && stages[table_index][stage_ind ex].index == stage) {
311 » hb_ot_map_t::pause_map_t *pause_map = m.pauses[table_index].push (); 308 » hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push ();
312 » if (likely (pause_map)) { 309 » if (likely (stage_map)) {
313 » pause_map->num_lookups = last_num_lookups; 310 » stage_map->last_lookup = last_num_lookups;
314 » pause_map->callback = pauses[table_index][pause_index].callback; 311 » stage_map->pause_func = stages[table_index][stage_index].pause_func;
315 } 312 }
316 313
317 » pause_index++; 314 » stage_index++;
318 } 315 }
319 } 316 }
320 } 317 }
321 } 318 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-layout-gsub-table.hh ('k') | third_party/harfbuzz-ng/src/hb-ot-map-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698