| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg | 2 * Copyright © 1998-2004 David Turner and Werner Lemberg |
| 3 * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc. | 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. |
| 4 * Copyright © 2011 Google, Inc. |
| 4 * | 5 * |
| 5 * This is part of HarfBuzz, a text shaping library. | 6 * This is part of HarfBuzz, a text shaping library. |
| 6 * | 7 * |
| 7 * Permission is hereby granted, without written agreement and without | 8 * Permission is hereby granted, without written agreement and without |
| 8 * license or royalty fees, to use, copy, modify, and distribute this | 9 * license or royalty fees, to use, copy, modify, and distribute this |
| 9 * software and its documentation for any purpose, provided that the | 10 * software and its documentation for any purpose, provided that the |
| 10 * above copyright notice and the following two paragraphs appear in | 11 * above copyright notice and the following two paragraphs appear in |
| 11 * all copies of this software. | 12 * all copies of this software. |
| 12 * | 13 * |
| 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 14 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES | 15 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN | 16 * 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 | 17 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 17 * DAMAGE. | 18 * DAMAGE. |
| 18 * | 19 * |
| 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, | 20 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | 21 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | 22 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO | 23 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 24 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 24 * | 25 * |
| 25 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod | 26 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod |
| 27 * Google Author(s): Behdad Esfahbod |
| 26 */ | 28 */ |
| 27 | 29 |
| 28 #ifndef HB_BUFFER_PRIVATE_HH | 30 #ifndef HB_BUFFER_PRIVATE_HH |
| 29 #define HB_BUFFER_PRIVATE_HH | 31 #define HB_BUFFER_PRIVATE_HH |
| 30 | 32 |
| 31 #include "hb-private.h" | 33 #include "hb-private.hh" |
| 32 #include "hb-buffer.h" | 34 #include "hb-buffer.h" |
| 33 #include "hb-unicode-private.h" | 35 #include "hb-object-private.hh" |
| 36 #include "hb-unicode-private.hh" |
| 34 | 37 |
| 35 HB_BEGIN_DECLS | |
| 36 | 38 |
| 37 | 39 |
| 38 ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); | 40 ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); |
| 39 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); | 41 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); |
| 40 | 42 |
| 41 typedef struct _hb_segment_properties_t { | 43 typedef struct _hb_segment_properties_t { |
| 42 hb_direction_t direction; | 44 hb_direction_t direction; |
| 43 hb_script_t script; | 45 hb_script_t script; |
| 44 hb_language_t language; | 46 hb_language_t language; |
| 45 } hb_segment_properties_t; | 47 } hb_segment_properties_t; |
| 46 | 48 |
| 47 | 49 |
| 48 HB_INTERNAL void | |
| 49 _hb_buffer_swap (hb_buffer_t *buffer); | |
| 50 | |
| 51 HB_INTERNAL void | |
| 52 _hb_buffer_clear_output (hb_buffer_t *buffer); | |
| 53 | |
| 54 HB_INTERNAL void | |
| 55 _hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer, | |
| 56 unsigned int num_in, | |
| 57 unsigned int num_out, | |
| 58 const uint16_t *glyph_data_be); | |
| 59 | |
| 60 HB_INTERNAL void | |
| 61 _hb_buffer_replace_glyph (hb_buffer_t *buffer, | |
| 62 hb_codepoint_t glyph_index); | |
| 63 | |
| 64 HB_INTERNAL void | |
| 65 _hb_buffer_next_glyph (hb_buffer_t *buffer); | |
| 66 | |
| 67 | |
| 68 HB_INTERNAL void | |
| 69 _hb_buffer_reset_masks (hb_buffer_t *buffer, | |
| 70 hb_mask_t mask); | |
| 71 | |
| 72 HB_INTERNAL void | |
| 73 _hb_buffer_add_masks (hb_buffer_t *buffer, | |
| 74 hb_mask_t mask); | |
| 75 | |
| 76 HB_INTERNAL void | |
| 77 _hb_buffer_set_masks (hb_buffer_t *buffer, | |
| 78 hb_mask_t value, | |
| 79 hb_mask_t mask, | |
| 80 unsigned int cluster_start, | |
| 81 unsigned int cluster_end); | |
| 82 | |
| 83 | |
| 84 struct _hb_buffer_t { | 50 struct _hb_buffer_t { |
| 85 hb_reference_count_t ref_count; | 51 hb_object_header_t header; |
| 86 | 52 |
| 87 /* Information about how the text in the buffer should be treated */ | 53 /* Information about how the text in the buffer should be treated */ |
| 88 | 54 |
| 89 hb_unicode_funcs_t *unicode; /* Unicode functions */ | 55 hb_unicode_funcs_t *unicode; /* Unicode functions */ |
| 90 hb_segment_properties_t props; /* Script, language, direction */ | 56 hb_segment_properties_t props; /* Script, language, direction */ |
| 91 | 57 |
| 92 /* Buffer contents */ | 58 /* Buffer contents */ |
| 93 | 59 |
| 60 bool in_error; /* Allocation failed */ |
| 61 bool have_output; /* Whether we have an output buffer going on */ |
| 62 bool have_positions; /* Whether we have positions */ |
| 63 |
| 64 unsigned int idx; /* Cursor into ->info and ->pos arrays */ |
| 65 unsigned int len; /* Length of ->info and ->pos arrays */ |
| 66 unsigned int out_len; /* Length of ->out array if have_output */ |
| 67 |
| 94 unsigned int allocated; /* Length of allocated arrays */ | 68 unsigned int allocated; /* Length of allocated arrays */ |
| 95 | |
| 96 hb_bool_t have_output; /* Whether we have an output buffer going on */ | |
| 97 hb_bool_t have_positions; /* Whether we have positions */ | |
| 98 hb_bool_t in_error; /* Allocation failed */ | |
| 99 | |
| 100 unsigned int i; /* Cursor into ->info and ->pos arrays */ | |
| 101 unsigned int len; /* Length of ->info and ->pos arrays */ | |
| 102 unsigned int out_len; /* Length of ->out array */ | |
| 103 | |
| 104 hb_glyph_info_t *info; | 69 hb_glyph_info_t *info; |
| 105 hb_glyph_info_t *out_info; | 70 hb_glyph_info_t *out_info; |
| 106 hb_glyph_position_t *pos; | 71 hb_glyph_position_t *pos; |
| 107 | 72 |
| 108 /* Other stuff */ | |
| 109 | |
| 110 unsigned int serial; | 73 unsigned int serial; |
| 74 uint8_t allocated_var_bytes[8]; |
| 75 const char *allocated_var_owner[8]; |
| 111 | 76 |
| 112 | 77 |
| 113 /* Methods */ | 78 /* Methods */ |
| 79 |
| 80 HB_INTERNAL void reset (void); |
| 81 |
| 82 inline unsigned int backtrack_len (void) const |
| 83 { return have_output? out_len : idx; } |
| 114 inline unsigned int next_serial (void) { return serial++; } | 84 inline unsigned int next_serial (void) { return serial++; } |
| 115 inline void swap (void) { _hb_buffer_swap (this); } | 85 |
| 116 inline void clear_output (void) { _hb_buffer_clear_output (this); } | 86 HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const
char *owner); |
| 117 inline void next_glyph (void) { _hb_buffer_next_glyph (this); } | 87 HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, cons
t char *owner); |
| 118 inline void replace_glyphs_be16 (unsigned int num_in, | 88 HB_INTERNAL void deallocate_var_all (void); |
| 89 |
| 90 HB_INTERNAL void add (hb_codepoint_t codepoint, |
| 91 » » » hb_mask_t mask, |
| 92 » » » unsigned int cluster); |
| 93 |
| 94 HB_INTERNAL void reverse_range (unsigned int start, unsigned int end); |
| 95 HB_INTERNAL void reverse (void); |
| 96 HB_INTERNAL void reverse_clusters (void); |
| 97 HB_INTERNAL void guess_properties (void); |
| 98 |
| 99 HB_INTERNAL void swap_buffers (void); |
| 100 HB_INTERNAL void clear_output (void); |
| 101 HB_INTERNAL void clear_positions (void); |
| 102 HB_INTERNAL void replace_glyphs_be16 (unsigned int num_in, |
| 103 » » » » » unsigned int num_out, |
| 104 » » » » » const uint16_t *glyph_data_be); |
| 105 HB_INTERNAL void replace_glyphs (unsigned int num_in, |
| 119 unsigned int num_out, | 106 unsigned int num_out, |
| 120 » » » » const uint16_t *glyph_data_be) | 107 » » » » const uint16_t *glyph_data); |
| 121 { _hb_buffer_replace_glyphs_be16 (this, num_in, num_out, glyph_data_be); } | 108 HB_INTERNAL void replace_glyph (hb_codepoint_t glyph_index); |
| 122 inline void replace_glyph (hb_codepoint_t glyph_index) | 109 /* Makes a copy of the glyph at idx to output and replace glyph_index */ |
| 123 { _hb_buffer_replace_glyph (this, glyph_index); } | 110 HB_INTERNAL void output_glyph (hb_codepoint_t glyph_index); |
| 111 /* Copies glyph at idx to output but doesn't advance idx */ |
| 112 HB_INTERNAL void copy_glyph (void); |
| 113 /* Copies glyph at idx to output and advance idx. |
| 114 * If there's no output, just advance idx. */ |
| 115 HB_INTERNAL void next_glyph (void); |
| 116 /* Advance idx without copying to output. */ |
| 117 inline void skip_glyph (void) { idx++; } |
| 124 | 118 |
| 125 inline void reset_masks (hb_mask_t mask) | 119 inline void reset_masks (hb_mask_t mask) |
| 126 { | 120 { |
| 127 for (unsigned int i = 0; i < len; i++) | 121 for (unsigned int j = 0; j < len; j++) |
| 128 info[i].mask = mask; | 122 info[j].mask = mask; |
| 129 } | 123 } |
| 130 inline void add_masks (hb_mask_t mask) | 124 inline void add_masks (hb_mask_t mask) |
| 131 { | 125 { |
| 132 for (unsigned int i = 0; i < len; i++) | 126 for (unsigned int j = 0; j < len; j++) |
| 133 info[i].mask |= mask; | 127 info[j].mask |= mask; |
| 134 } | 128 } |
| 135 inline void set_masks (hb_mask_t value, | 129 HB_INTERNAL void set_masks (hb_mask_t value, |
| 136 » » » hb_mask_t mask, | 130 » » » hb_mask_t mask, |
| 137 » » » unsigned int cluster_start, | 131 » » » unsigned int cluster_start, |
| 138 » » » unsigned int cluster_end) | 132 » » » unsigned int cluster_end); |
| 139 { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); } | |
| 140 | 133 |
| 134 /* Internal methods */ |
| 135 HB_INTERNAL bool enlarge (unsigned int size); |
| 136 |
| 137 inline bool ensure (unsigned int size) |
| 138 { return likely (size <= allocated) ? TRUE : enlarge (size); } |
| 139 |
| 140 HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out); |
| 141 |
| 142 HB_INTERNAL void *get_scratch_buffer (unsigned int *size); |
| 141 }; | 143 }; |
| 142 | 144 |
| 143 | 145 |
| 144 HB_END_DECLS | 146 #define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \ |
| 147 b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ |
| 148 » sizeof (b->info[0].var), owner) |
| 149 #define HB_BUFFER_ALLOCATE_VAR(b, var) \ |
| 150 » HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var) |
| 151 #define HB_BUFFER_DEALLOCATE_VAR(b, var) \ |
| 152 » HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var (), #var) |
| 153 |
| 154 |
| 145 | 155 |
| 146 #endif /* HB_BUFFER_PRIVATE_HH */ | 156 #endif /* HB_BUFFER_PRIVATE_HH */ |
| OLD | NEW |