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

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

Issue 2622553002: Roll HarfBuzz to 1.4.1 (Closed)
Patch Set: Linux rebaselines 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 © 2009,2010 Red Hat, Inc. 2 * Copyright © 2009,2010 Red Hat, Inc.
3 * Copyright © 2010,2011,2013 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
(...skipping 13 matching lines...) Expand all
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" 31 #include "hb-ot-layout-private.hh"
32 32
33 33
34 void 34 void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_o ut) const
35 hb_ot_map_t::add_lookups (hb_face_t *face,
36 » » » unsigned int table_index,
37 » » » unsigned int feature_index,
38 » » » hb_mask_t mask,
39 » » » bool auto_zwj)
40 { 35 {
41 unsigned int lookup_indices[32]; 36 for (unsigned int i = 0; i < lookups[table_index].len; i++)
42 unsigned int offset, len; 37 hb_set_add (lookups_out, lookups[table_index][i].index);
43 unsigned int table_lookup_count; 38 }
44 39
45 table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[tab le_index]);
46
47 offset = 0;
48 do {
49 len = ARRAY_LENGTH (lookup_indices);
50 hb_ot_layout_feature_get_lookups (face,
51 table_tags[table_index],
52 feature_index,
53 offset, &len,
54 lookup_indices);
55
56 for (unsigned int i = 0; i < len; i++)
57 {
58 if (lookup_indices[i] >= table_lookup_count)
59 continue;
60 hb_ot_map_t::lookup_map_t *lookup = lookups[table_index].push ();
61 if (unlikely (!lookup))
62 return;
63 lookup->mask = mask;
64 lookup->index = lookup_indices[i];
65 lookup->auto_zwj = auto_zwj;
66 }
67
68 offset += len;
69 } while (len == ARRAY_LENGTH (lookup_indices));
70 }
71 40
72 hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_, 41 hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_,
73 const hb_segment_properties_t *props_) 42 const hb_segment_properties_t *props_)
74 { 43 {
75 memset (this, 0, sizeof (*this)); 44 memset (this, 0, sizeof (*this));
76 45
77 face = face_; 46 face = face_;
78 props = *props_; 47 props = *props_;
79 48
80 49
(...skipping 21 matching lines...) Expand all
102 if (unlikely (!tag)) return; 71 if (unlikely (!tag)) return;
103 info->tag = tag; 72 info->tag = tag;
104 info->seq = feature_infos.len; 73 info->seq = feature_infos.len;
105 info->max_value = value; 74 info->max_value = value;
106 info->flags = flags; 75 info->flags = flags;
107 info->default_value = (flags & F_GLOBAL) ? value : 0; 76 info->default_value = (flags & F_GLOBAL) ? value : 0;
108 info->stage[0] = current_stage[0]; 77 info->stage[0] = current_stage[0];
109 info->stage[1] = current_stage[1]; 78 info->stage[1] = current_stage[1];
110 } 79 }
111 80
81 void
82 hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m,
83 hb_face_t *face,
84 unsigned int table_index,
85 unsigned int feature_index,
86 unsigned int variations_index,
87 hb_mask_t mask,
88 bool auto_zwj)
89 {
90 unsigned int lookup_indices[32];
91 unsigned int offset, len;
92 unsigned int table_lookup_count;
112 93
113 void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_o ut) const 94 table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[tab le_index]);
114 { 95
115 for (unsigned int i = 0; i < lookups[table_index].len; i++) 96 offset = 0;
116 hb_set_add (lookups_out, lookups[table_index][i].index); 97 do {
98 len = ARRAY_LENGTH (lookup_indices);
99 hb_ot_layout_feature_with_variations_get_lookups (face,
100 » » » » » » table_tags[table_index],
101 » » » » » » feature_index,
102 » » » » » » variations_index,
103 » » » » » » offset, &len,
104 » » » » » » lookup_indices);
105
106 for (unsigned int i = 0; i < len; i++)
107 {
108 if (lookup_indices[i] >= table_lookup_count)
109 » continue;
110 hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push ();
111 if (unlikely (!lookup))
112 return;
113 lookup->mask = mask;
114 lookup->index = lookup_indices[i];
115 lookup->auto_zwj = auto_zwj;
116 }
117
118 offset += len;
119 } while (len == ARRAY_LENGTH (lookup_indices));
117 } 120 }
118 121
122
119 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus e_func_t pause_func) 123 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus e_func_t pause_func)
120 { 124 {
121 stage_info_t *s = stages[table_index].push (); 125 stage_info_t *s = stages[table_index].push ();
122 if (likely (s)) { 126 if (likely (s)) {
123 s->index = current_stage[table_index]; 127 s->index = current_stage[table_index];
124 s->pause_func = pause_func; 128 s->pause_func = pause_func;
125 } 129 }
126 130
127 current_stage[table_index]++; 131 current_stage[table_index]++;
128 } 132 }
129 133
130 void 134 void
131 hb_ot_map_builder_t::compile (hb_ot_map_t &m) 135 hb_ot_map_builder_t::compile (hb_ot_map_t &m,
136 » » » const int *coords,
137 » » » unsigned int num_coords)
132 { 138 {
133 m.global_mask = 1; 139 m.global_mask = 1;
134 140
135 unsigned int required_feature_index[2]; 141 unsigned int required_feature_index[2];
136 hb_tag_t required_feature_tag[2]; 142 hb_tag_t required_feature_tag[2];
137 /* We default to applying required feature in stage 0. If the required 143 /* We default to applying required feature in stage 0. If the required
138 * feature has a tag that is known to the shaper, we apply required feature 144 * feature has a tag that is known to the shaper, we apply required feature
139 * in the stage for that tag. 145 * in the stage for that tag.
140 */ 146 */
141 unsigned int required_feature_stage[2] = {0, 0}; 147 unsigned int required_feature_stage[2] = {0, 0};
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 feature_infos.shrink (0); /* Done with these */ 261 feature_infos.shrink (0); /* Done with these */
256 262
257 263
258 add_gsub_pause (NULL); 264 add_gsub_pause (NULL);
259 add_gpos_pause (NULL); 265 add_gpos_pause (NULL);
260 266
261 for (unsigned int table_index = 0; table_index < 2; table_index++) 267 for (unsigned int table_index = 0; table_index < 2; table_index++)
262 { 268 {
263 /* Collect lookup indices for features */ 269 /* Collect lookup indices for features */
264 270
271 unsigned int variations_index;
272 hb_ot_layout_table_find_feature_variations (face,
273 table_tags[table_index],
274 coords,
275 num_coords,
276 &variations_index);
277
265 unsigned int stage_index = 0; 278 unsigned int stage_index = 0;
266 unsigned int last_num_lookups = 0; 279 unsigned int last_num_lookups = 0;
267 for (unsigned stage = 0; stage < current_stage[table_index]; stage++) 280 for (unsigned stage = 0; stage < current_stage[table_index]; stage++)
268 { 281 {
269 if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX & & 282 if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX & &
270 required_feature_stage[table_index] == stage) 283 required_feature_stage[table_index] == stage)
271 » m.add_lookups (face, table_index, 284 » add_lookups (m, face, table_index,
272 » » required_feature_index[table_index], 285 » » required_feature_index[table_index],
273 » » 1 /* mask */, 286 » » variations_index,
274 » » true /* auto_zwj */); 287 » » 1 /* mask */,
288 » » true /* auto_zwj */);
275 289
276 for (unsigned i = 0; i < m.features.len; i++) 290 for (unsigned i = 0; i < m.features.len; i++)
277 if (m.features[i].stage[table_index] == stage) 291 if (m.features[i].stage[table_index] == stage)
278 » m.add_lookups (face, table_index, 292 » add_lookups (m, face, table_index,
279 » » » m.features[i].index[table_index], 293 » » m.features[i].index[table_index],
280 » » » m.features[i].mask, 294 » » variations_index,
281 » » » m.features[i].auto_zwj); 295 » » m.features[i].mask,
296 » » m.features[i].auto_zwj);
282 297
283 /* Sort lookups and merge duplicates */ 298 /* Sort lookups and merge duplicates */
284 if (last_num_lookups < m.lookups[table_index].len) 299 if (last_num_lookups < m.lookups[table_index].len)
285 { 300 {
286 m.lookups[table_index].qsort (last_num_lookups, m.lookups[table_index].l en); 301 m.lookups[table_index].qsort (last_num_lookups, m.lookups[table_index].l en);
287 302
288 unsigned int j = last_num_lookups; 303 unsigned int j = last_num_lookups;
289 for (unsigned int i = j + 1; i < m.lookups[table_index].len; i++) 304 for (unsigned int i = j + 1; i < m.lookups[table_index].len; i++)
290 if (m.lookups[table_index][i].index != m.lookups[table_index][j].index ) 305 if (m.lookups[table_index][i].index != m.lookups[table_index][j].index )
291 m.lookups[table_index][++j] = m.lookups[table_index][i]; 306 m.lookups[table_index][++j] = m.lookups[table_index][i];
(...skipping 12 matching lines...) Expand all
304 if (likely (stage_map)) { 319 if (likely (stage_map)) {
305 stage_map->last_lookup = last_num_lookups; 320 stage_map->last_lookup = last_num_lookups;
306 stage_map->pause_func = stages[table_index][stage_index].pause_func; 321 stage_map->pause_func = stages[table_index][stage_index].pause_func;
307 } 322 }
308 323
309 stage_index++; 324 stage_index++;
310 } 325 }
311 } 326 }
312 } 327 }
313 } 328 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-layout-gsubgpos-private.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