/src/skia/third_party/externals/harfbuzz/src/hb-buffer.hh
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright © 1998-2004 David Turner and Werner Lemberg |
3 | | * Copyright © 2004,2007,2009,2010 Red Hat, Inc. |
4 | | * Copyright © 2011,2012 Google, Inc. |
5 | | * |
6 | | * This is part of HarfBuzz, a text shaping library. |
7 | | * |
8 | | * Permission is hereby granted, without written agreement and without |
9 | | * license or royalty fees, to use, copy, modify, and distribute this |
10 | | * software and its documentation for any purpose, provided that the |
11 | | * above copyright notice and the following two paragraphs appear in |
12 | | * all copies of this software. |
13 | | * |
14 | | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
15 | | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
16 | | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
17 | | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
18 | | * DAMAGE. |
19 | | * |
20 | | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
21 | | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
22 | | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
23 | | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
24 | | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
25 | | * |
26 | | * Red Hat Author(s): Owen Taylor, Behdad Esfahbod |
27 | | * Google Author(s): Behdad Esfahbod |
28 | | */ |
29 | | |
30 | | #ifndef HB_BUFFER_HH |
31 | | #define HB_BUFFER_HH |
32 | | |
33 | | #include "hb.hh" |
34 | | #include "hb-unicode.hh" |
35 | | |
36 | | |
37 | | #ifndef HB_BUFFER_MAX_LEN_FACTOR |
38 | 464k | #define HB_BUFFER_MAX_LEN_FACTOR 64 |
39 | | #endif |
40 | | #ifndef HB_BUFFER_MAX_LEN_MIN |
41 | 464k | #define HB_BUFFER_MAX_LEN_MIN 16384 |
42 | | #endif |
43 | | #ifndef HB_BUFFER_MAX_LEN_DEFAULT |
44 | 541k | #define HB_BUFFER_MAX_LEN_DEFAULT 0x3FFFFFFF /* Shaping more than a billion chars? Let us know! */ |
45 | | #endif |
46 | | |
47 | | #ifndef HB_BUFFER_MAX_OPS_FACTOR |
48 | 464k | #define HB_BUFFER_MAX_OPS_FACTOR 1024 |
49 | | #endif |
50 | | #ifndef HB_BUFFER_MAX_OPS_MIN |
51 | 464k | #define HB_BUFFER_MAX_OPS_MIN 16384 |
52 | | #endif |
53 | | #ifndef HB_BUFFER_MAX_OPS_DEFAULT |
54 | 541k | #define HB_BUFFER_MAX_OPS_DEFAULT 0x1FFFFFFF /* Shaping more than a billion operations? Let us know! */ |
55 | | #endif |
56 | | |
57 | | static_assert ((sizeof (hb_glyph_info_t) == 20), ""); |
58 | | static_assert ((sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)), ""); |
59 | | |
60 | | HB_MARK_AS_FLAG_T (hb_buffer_flags_t); |
61 | | HB_MARK_AS_FLAG_T (hb_buffer_serialize_flags_t); |
62 | | HB_MARK_AS_FLAG_T (hb_buffer_diff_flags_t); |
63 | | |
64 | | enum hb_buffer_scratch_flags_t { |
65 | | HB_BUFFER_SCRATCH_FLAG_DEFAULT = 0x00000000u, |
66 | | HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII = 0x00000001u, |
67 | | HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES = 0x00000002u, |
68 | | HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u, |
69 | | HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u, |
70 | | HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK = 0x00000010u, |
71 | | HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000020u, |
72 | | |
73 | | /* Reserved for complex shapers' internal use. */ |
74 | | HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u, |
75 | | HB_BUFFER_SCRATCH_FLAG_COMPLEX1 = 0x02000000u, |
76 | | HB_BUFFER_SCRATCH_FLAG_COMPLEX2 = 0x04000000u, |
77 | | HB_BUFFER_SCRATCH_FLAG_COMPLEX3 = 0x08000000u, |
78 | | }; |
79 | | HB_MARK_AS_FLAG_T (hb_buffer_scratch_flags_t); |
80 | | |
81 | | |
82 | | /* |
83 | | * hb_buffer_t |
84 | | */ |
85 | | |
86 | | struct hb_buffer_t |
87 | | { |
88 | | hb_object_header_t header; |
89 | | |
90 | | /* Information about how the text in the buffer should be treated */ |
91 | | hb_unicode_funcs_t *unicode; /* Unicode functions */ |
92 | | hb_buffer_flags_t flags; /* BOT / EOT / etc. */ |
93 | | hb_buffer_cluster_level_t cluster_level; |
94 | | hb_codepoint_t replacement; /* U+FFFD or something else. */ |
95 | | hb_codepoint_t invisible; /* 0 or something else. */ |
96 | | hb_buffer_scratch_flags_t scratch_flags; /* Have space-fallback, etc. */ |
97 | | unsigned int max_len; /* Maximum allowed len. */ |
98 | | int max_ops; /* Maximum allowed operations. */ |
99 | | |
100 | | /* Buffer contents */ |
101 | | hb_buffer_content_type_t content_type; |
102 | | hb_segment_properties_t props; /* Script, language, direction */ |
103 | | |
104 | | bool successful; /* Allocations successful */ |
105 | | bool have_output; /* Whether we have an output buffer going on */ |
106 | | bool have_positions; /* Whether we have positions */ |
107 | | |
108 | | unsigned int idx; /* Cursor into ->info and ->pos arrays */ |
109 | | unsigned int len; /* Length of ->info and ->pos arrays */ |
110 | | unsigned int out_len; /* Length of ->out_info array if have_output */ |
111 | | |
112 | | unsigned int allocated; /* Length of allocated arrays */ |
113 | | hb_glyph_info_t *info; |
114 | | hb_glyph_info_t *out_info; |
115 | | hb_glyph_position_t *pos; |
116 | | |
117 | | unsigned int serial; |
118 | | |
119 | | /* Text before / after the main buffer contents. |
120 | | * Always in Unicode, and ordered outward. |
121 | | * Index 0 is for "pre-context", 1 for "post-context". */ |
122 | | static constexpr unsigned CONTEXT_LENGTH = 5u; |
123 | | hb_codepoint_t context[2][CONTEXT_LENGTH]; |
124 | | unsigned int context_len[2]; |
125 | | |
126 | | /* Debugging API */ |
127 | | #ifndef HB_NO_BUFFER_MESSAGE |
128 | | hb_buffer_message_func_t message_func; |
129 | | void *message_data; |
130 | | hb_destroy_func_t message_destroy; |
131 | | unsigned message_depth; /* How deeply are we inside a message callback? */ |
132 | | #else |
133 | | static constexpr unsigned message_depth = 0u; |
134 | | #endif |
135 | | |
136 | | /* Internal debugging. */ |
137 | | /* The bits here reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ |
138 | | #ifndef HB_NDEBUG |
139 | | uint8_t allocated_var_bits; |
140 | | #endif |
141 | | |
142 | | |
143 | | /* Methods */ |
144 | | |
145 | 0 | HB_NODISCARD bool in_error () const { return !successful; } |
146 | | |
147 | | void allocate_var (unsigned int start, unsigned int count) |
148 | 2.63M | { |
149 | | #ifndef HB_NDEBUG |
150 | | unsigned int end = start + count; |
151 | | assert (end <= 8); |
152 | | unsigned int bits = (1u<<end) - (1u<<start); |
153 | | assert (0 == (allocated_var_bits & bits)); |
154 | | allocated_var_bits |= bits; |
155 | | #endif |
156 | 2.63M | } |
157 | | void deallocate_var (unsigned int start, unsigned int count) |
158 | 2.63M | { |
159 | | #ifndef HB_NDEBUG |
160 | | unsigned int end = start + count; |
161 | | assert (end <= 8); |
162 | | unsigned int bits = (1u<<end) - (1u<<start); |
163 | | assert (bits == (allocated_var_bits & bits)); |
164 | | allocated_var_bits &= ~bits; |
165 | | #endif |
166 | 2.63M | } |
167 | | void assert_var (unsigned int start, unsigned int count) |
168 | 4.30M | { |
169 | | #ifndef HB_NDEBUG |
170 | | unsigned int end = start + count; |
171 | | assert (end <= 8); |
172 | | unsigned int bits = (1u<<end) - (1u<<start); |
173 | | assert (bits == (allocated_var_bits & bits)); |
174 | | #endif |
175 | 4.30M | } |
176 | | void deallocate_var_all () |
177 | 1.46M | { |
178 | | #ifndef HB_NDEBUG |
179 | | allocated_var_bits = 0; |
180 | | #endif |
181 | 1.46M | } |
182 | | |
183 | 32.3M | hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; } |
184 | 0 | hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; } |
185 | | |
186 | 0 | hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; } |
187 | 0 | hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; } |
188 | | |
189 | 3.58M | hb_glyph_info_t &prev () { return out_info[out_len ? out_len - 1 : 0]; } |
190 | 0 | hb_glyph_info_t prev () const { return out_info[out_len ? out_len - 1 : 0]; } |
191 | | |
192 | | HB_INTERNAL void reset (); |
193 | | HB_INTERNAL void clear (); |
194 | | |
195 | 0 | unsigned int backtrack_len () const { return have_output ? out_len : idx; } |
196 | 0 | unsigned int lookahead_len () const { return len - idx; } |
197 | 0 | unsigned int next_serial () { return serial++; } |
198 | | |
199 | | HB_INTERNAL void add (hb_codepoint_t codepoint, |
200 | | unsigned int cluster); |
201 | | HB_INTERNAL void add_info (const hb_glyph_info_t &glyph_info); |
202 | | |
203 | | HB_INTERNAL void reverse_range (unsigned int start, unsigned int end); |
204 | | HB_INTERNAL void reverse (); |
205 | | HB_INTERNAL void reverse_clusters (); |
206 | | HB_INTERNAL void guess_segment_properties (); |
207 | | |
208 | | HB_INTERNAL void swap_buffers (); |
209 | | HB_INTERNAL void clear_output (); |
210 | | HB_INTERNAL void clear_positions (); |
211 | | |
212 | | template <typename T> |
213 | | HB_NODISCARD bool replace_glyphs (unsigned int num_in, |
214 | | unsigned int num_out, |
215 | | const T *glyph_data) |
216 | 203k | { |
217 | 203k | if (unlikely (!make_room_for (num_in, num_out))) return false; |
218 | | |
219 | 203k | assert (idx + num_in <= len); |
220 | | |
221 | 203k | merge_clusters (idx, idx + num_in); |
222 | | |
223 | 203k | hb_glyph_info_t &orig_info = idx < len ? cur() : prev(); |
224 | | |
225 | 203k | hb_glyph_info_t *pinfo = &out_info[out_len]; |
226 | 406k | for (unsigned int i = 0; i < num_out; i++) |
227 | 203k | { |
228 | 203k | *pinfo = orig_info; |
229 | 203k | pinfo->codepoint = glyph_data[i]; |
230 | 203k | pinfo++; |
231 | 203k | } |
232 | | |
233 | 203k | idx += num_in; |
234 | 203k | out_len += num_out; |
235 | 203k | return true; |
236 | 203k | } bool hb_buffer_t::replace_glyphs<unsigned int>(unsigned int, unsigned int, unsigned int const*) Line | Count | Source | 216 | 203k | { | 217 | 203k | if (unlikely (!make_room_for (num_in, num_out))) return false; | 218 | | | 219 | 203k | assert (idx + num_in <= len); | 220 | | | 221 | 203k | merge_clusters (idx, idx + num_in); | 222 | | | 223 | 203k | hb_glyph_info_t &orig_info = idx < len ? cur() : prev(); | 224 | | | 225 | 203k | hb_glyph_info_t *pinfo = &out_info[out_len]; | 226 | 406k | for (unsigned int i = 0; i < num_out; i++) | 227 | 203k | { | 228 | 203k | *pinfo = orig_info; | 229 | 203k | pinfo->codepoint = glyph_data[i]; | 230 | 203k | pinfo++; | 231 | 203k | } | 232 | | | 233 | 203k | idx += num_in; | 234 | 203k | out_len += num_out; | 235 | 203k | return true; | 236 | 203k | } |
Unexecuted instantiation: bool hb_buffer_t::replace_glyphs<OT::HBGlyphID>(unsigned int, unsigned int, OT::HBGlyphID const*) |
237 | | |
238 | | HB_NODISCARD bool replace_glyph (hb_codepoint_t glyph_index) |
239 | 101k | { return replace_glyphs (1, 1, &glyph_index); } |
240 | | |
241 | | /* Makes a copy of the glyph at idx to output and replace glyph_index */ |
242 | | HB_NODISCARD bool output_glyph (hb_codepoint_t glyph_index) |
243 | 101k | { return replace_glyphs (0, 1, &glyph_index); } |
244 | | |
245 | | HB_NODISCARD bool output_info (const hb_glyph_info_t &glyph_info) |
246 | 0 | { |
247 | 0 | if (unlikely (!make_room_for (0, 1))) return false; |
248 | | |
249 | 0 | out_info[out_len] = glyph_info; |
250 | |
|
251 | 0 | out_len++; |
252 | 0 | return true; |
253 | 0 | } |
254 | | /* Copies glyph at idx to output but doesn't advance idx */ |
255 | | HB_NODISCARD bool copy_glyph () |
256 | 0 | { |
257 | | /* Extra copy because cur()'s return can be freed within |
258 | | * output_info() call if buffer reallocates. */ |
259 | 0 | return output_info (hb_glyph_info_t (cur())); |
260 | 0 | } |
261 | | |
262 | | /* Copies glyph at idx to output and advance idx. |
263 | | * If there's no output, just advance idx. */ |
264 | | HB_NODISCARD bool next_glyph () |
265 | 13.3M | { |
266 | 13.3M | if (have_output) |
267 | 13.3M | { |
268 | 13.3M | if (out_info != info || out_len != idx) |
269 | 324k | { |
270 | 324k | if (unlikely (!make_room_for (1, 1))) return false; |
271 | 324k | out_info[out_len] = info[idx]; |
272 | 324k | } |
273 | 13.3M | out_len++; |
274 | 13.3M | } |
275 | | |
276 | 13.3M | idx++; |
277 | 13.3M | return true; |
278 | 13.3M | } |
279 | | /* Copies n glyphs at idx to output and advance idx. |
280 | | * If there's no output, just advance idx. */ |
281 | | HB_NODISCARD bool next_glyphs (unsigned int n) |
282 | 1.09M | { |
283 | 1.09M | if (have_output) |
284 | 1.09M | { |
285 | 1.09M | if (out_info != info || out_len != idx) |
286 | 16.9k | { |
287 | 16.9k | if (unlikely (!make_room_for (n, n))) return false; |
288 | 16.9k | memmove (out_info + out_len, info + idx, n * sizeof (out_info[0])); |
289 | 16.9k | } |
290 | 1.09M | out_len += n; |
291 | 1.09M | } |
292 | | |
293 | 1.09M | idx += n; |
294 | 1.09M | return true; |
295 | 1.09M | } |
296 | | /* Advance idx without copying to output. */ |
297 | 0 | void skip_glyph () { idx++; } |
298 | | void reset_masks (hb_mask_t mask) |
299 | 464k | { |
300 | 9.04M | for (unsigned int j = 0; j < len; j++) |
301 | 8.58M | info[j].mask = mask; |
302 | 464k | } |
303 | | void add_masks (hb_mask_t mask) |
304 | 0 | { |
305 | 0 | for (unsigned int j = 0; j < len; j++) |
306 | 0 | info[j].mask |= mask; |
307 | 0 | } |
308 | | HB_INTERNAL void set_masks (hb_mask_t value, hb_mask_t mask, |
309 | | unsigned int cluster_start, unsigned int cluster_end); |
310 | | |
311 | | void merge_clusters (unsigned int start, unsigned int end) |
312 | 793k | { |
313 | 793k | if (end - start < 2) |
314 | 750k | return; |
315 | 43.7k | merge_clusters_impl (start, end); |
316 | 43.7k | } |
317 | | HB_INTERNAL void merge_clusters_impl (unsigned int start, unsigned int end); |
318 | | HB_INTERNAL void merge_out_clusters (unsigned int start, unsigned int end); |
319 | | /* Merge clusters for deleting current glyph, and skip it. */ |
320 | | HB_INTERNAL void delete_glyph (); |
321 | | |
322 | | void unsafe_to_break (unsigned int start, |
323 | | unsigned int end) |
324 | 7.93M | { |
325 | 7.93M | if (end - start < 2) |
326 | 7.43M | return; |
327 | 494k | unsafe_to_break_impl (start, end); |
328 | 494k | } |
329 | | HB_INTERNAL void unsafe_to_break_impl (unsigned int start, unsigned int end); |
330 | | HB_INTERNAL void unsafe_to_break_from_outbuffer (unsigned int start, unsigned int end); |
331 | | |
332 | | |
333 | | /* Internal methods */ |
334 | | HB_NODISCARD HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */ |
335 | | |
336 | | HB_NODISCARD HB_INTERNAL bool enlarge (unsigned int size); |
337 | | |
338 | | HB_NODISCARD bool ensure (unsigned int size) |
339 | 10.0M | { return likely (!size || size < allocated) ? true : enlarge (size); } |
340 | | |
341 | | HB_NODISCARD bool ensure_inplace (unsigned int size) |
342 | 0 | { return likely (!size || size < allocated); } |
343 | | |
344 | | void assert_glyphs () |
345 | 0 | { |
346 | 0 | assert ((content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS) || |
347 | 0 | (!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID))); |
348 | 0 | } |
349 | | void assert_unicode () |
350 | 1.85M | { |
351 | 1.85M | assert ((content_type == HB_BUFFER_CONTENT_TYPE_UNICODE) || |
352 | 1.85M | (!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID))); |
353 | 1.85M | } |
354 | | HB_NODISCARD bool ensure_glyphs () |
355 | 0 | { |
356 | 0 | if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) |
357 | 0 | { |
358 | 0 | if (content_type != HB_BUFFER_CONTENT_TYPE_INVALID) |
359 | 0 | return false; |
360 | 0 | assert (len == 0); |
361 | 0 | content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; |
362 | 0 | } |
363 | 0 | return true; |
364 | 0 | } |
365 | | HB_NODISCARD bool ensure_unicode () |
366 | 0 | { |
367 | 0 | if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_UNICODE)) |
368 | 0 | { |
369 | 0 | if (content_type != HB_BUFFER_CONTENT_TYPE_INVALID) |
370 | 0 | return false; |
371 | 0 | assert (len == 0); |
372 | 0 | content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; |
373 | 0 | } |
374 | 0 | return true; |
375 | 0 | } |
376 | | |
377 | | HB_NODISCARD HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out); |
378 | | HB_NODISCARD HB_INTERNAL bool shift_forward (unsigned int count); |
379 | | |
380 | | typedef long scratch_buffer_t; |
381 | | HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size); |
382 | | |
383 | 9.95M | void clear_context (unsigned int side) { context_len[side] = 0; } |
384 | | |
385 | | HB_INTERNAL void sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *)); |
386 | | |
387 | | bool messaging () |
388 | 1.79M | { |
389 | | #ifdef HB_NO_BUFFER_MESSAGE |
390 | | return false; |
391 | | #else |
392 | 1.79M | return unlikely (message_func); |
393 | 1.79M | #endif |
394 | 1.79M | } |
395 | | bool message (hb_font_t *font, const char *fmt, ...) HB_PRINTF_FUNC(3, 4) |
396 | 1.79M | { |
397 | | #ifdef HB_NO_BUFFER_MESSAGE |
398 | | return true; |
399 | | #else |
400 | 1.79M | if (!messaging ()) |
401 | 1.79M | return true; |
402 | | |
403 | 0 | message_depth++; |
404 | |
|
405 | 0 | va_list ap; |
406 | 0 | va_start (ap, fmt); |
407 | 0 | bool ret = message_impl (font, fmt, ap); |
408 | 0 | va_end (ap); |
409 | |
|
410 | 0 | message_depth--; |
411 | |
|
412 | 0 | return ret; |
413 | 0 | #endif |
414 | 0 | } |
415 | | HB_INTERNAL bool message_impl (hb_font_t *font, const char *fmt, va_list ap) HB_PRINTF_FUNC(3, 0); |
416 | | |
417 | | static void |
418 | | set_cluster (hb_glyph_info_t &inf, unsigned int cluster, unsigned int mask = 0) |
419 | 346k | { |
420 | 346k | if (inf.cluster != cluster) |
421 | 211k | { |
422 | 211k | if (mask & HB_GLYPH_FLAG_UNSAFE_TO_BREAK) |
423 | 979 | inf.mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK; |
424 | 210k | else |
425 | 210k | inf.mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; |
426 | 211k | } |
427 | 346k | inf.cluster = cluster; |
428 | 346k | } |
429 | | |
430 | | unsigned int |
431 | | _unsafe_to_break_find_min_cluster (const hb_glyph_info_t *infos, |
432 | | unsigned int start, unsigned int end, |
433 | | unsigned int cluster) const |
434 | 494k | { |
435 | 1.63M | for (unsigned int i = start; i < end; i++) |
436 | 1.13M | cluster = hb_min (cluster, infos[i].cluster); |
437 | 494k | return cluster; |
438 | 494k | } |
439 | | void |
440 | | _unsafe_to_break_set_mask (hb_glyph_info_t *infos, |
441 | | unsigned int start, unsigned int end, |
442 | | unsigned int cluster) |
443 | 494k | { |
444 | 1.63M | for (unsigned int i = start; i < end; i++) |
445 | 1.13M | if (cluster != infos[i].cluster) |
446 | 639k | { |
447 | 639k | scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK; |
448 | 639k | infos[i].mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK; |
449 | 639k | } |
450 | 494k | } |
451 | | |
452 | 0 | void unsafe_to_break_all () { unsafe_to_break_impl (0, len); } |
453 | | void safe_to_break_all () |
454 | 0 | { |
455 | 0 | for (unsigned int i = 0; i < len; i++) |
456 | 0 | info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; |
457 | 0 | } |
458 | | }; |
459 | | DECLARE_NULL_INSTANCE (hb_buffer_t); |
460 | | |
461 | | |
462 | | /* Loop over clusters. Duplicated in foreach_syllable(). */ |
463 | | #define foreach_cluster(buffer, start, end) \ |
464 | 47.2k | for (unsigned int \ |
465 | 47.2k | _count = buffer->len, \ |
466 | 47.2k | start = 0, end = _count ? _next_cluster (buffer, 0) : 0; \ |
467 | 3.58M | start < _count; \ |
468 | 3.53M | start = end, end = _next_cluster (buffer, start)) |
469 | | |
470 | | static inline unsigned int |
471 | | _next_cluster (hb_buffer_t *buffer, unsigned int start) |
472 | 3.58M | { |
473 | 3.58M | hb_glyph_info_t *info = buffer->info; |
474 | 3.58M | unsigned int count = buffer->len; |
475 | | |
476 | 3.58M | unsigned int cluster = info[start].cluster; |
477 | 3.78M | while (++start < count && cluster == info[start].cluster) |
478 | 199k | ; |
479 | | |
480 | 3.58M | return start; |
481 | 3.58M | } Unexecuted instantiation: hb-buffer.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-face.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-fallback-shape.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-font.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-face.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-font.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-metrics.cc:_next_cluster(hb_buffer_t*, unsigned int) hb-ot-shape.cc:_next_cluster(hb_buffer_t*, unsigned int) Line | Count | Source | 472 | 3.58M | { | 473 | 3.58M | hb_glyph_info_t *info = buffer->info; | 474 | 3.58M | unsigned int count = buffer->len; | 475 | | | 476 | 3.58M | unsigned int cluster = info[start].cluster; | 477 | 3.78M | while (++start < count && cluster == info[start].cluster) | 478 | 199k | ; | 479 | | | 480 | 3.58M | return start; | 481 | 3.58M | } |
Unexecuted instantiation: hb-ot-var.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-shape-plan.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-shape.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-static.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-aat-layout.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-aat-map.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-cff1-table.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-cff2-table.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-layout.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-map.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-arabic.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-default.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-hangul.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-hebrew.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-indic.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-khmer.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-myanmar.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-syllabic.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-thai.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-use.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-vowel-constraints.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-fallback.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-normalize.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-ot-shape-complex-indic-table.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-subset-input.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-subset.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-subset-cff1.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-subset-cff2.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-subset-plan.cc:_next_cluster(hb_buffer_t*, unsigned int) Unexecuted instantiation: hb-subset-cff-common.cc:_next_cluster(hb_buffer_t*, unsigned int) |
482 | | |
483 | | |
484 | | #define HB_BUFFER_XALLOCATE_VAR(b, func, var) \ |
485 | 9.58M | b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ |
486 | 9.58M | sizeof (b->info[0].var)) |
487 | 2.63M | #define HB_BUFFER_ALLOCATE_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var ()) |
488 | 2.63M | #define HB_BUFFER_DEALLOCATE_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var ()) |
489 | 4.30M | #define HB_BUFFER_ASSERT_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, assert_var, var ()) |
490 | | |
491 | | |
492 | | #endif /* HB_BUFFER_HH */ |