| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 1998-2004 David Turner and Werner Lemberg | 2 * Copyright © 1998-2004 David Turner and Werner Lemberg |
| 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. | 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. |
| 4 * Copyright © 2011,2012 Google, Inc. | 4 * Copyright © 2011,2012 Google, Inc. |
| 5 * | 5 * |
| 6 * This is part of HarfBuzz, a text shaping library. | 6 * This is part of HarfBuzz, a text shaping library. |
| 7 * | 7 * |
| 8 * Permission is hereby granted, without written agreement and without | 8 * Permission is hereby granted, without written agreement and without |
| 9 * license or royalty fees, to use, copy, modify, and distribute this | 9 * license or royalty fees, to use, copy, modify, and distribute this |
| 10 * software and its documentation for any purpose, provided that the | 10 * software and its documentation for any purpose, provided that the |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]
; } | 105 inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]
; } |
| 106 inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx
+ i]; } | 106 inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx
+ i]; } |
| 107 | 107 |
| 108 inline hb_glyph_info_t &prev (void) { return out_info[out_len ? out_len - 1 :
0]; } | 108 inline hb_glyph_info_t &prev (void) { return out_info[out_len ? out_len - 1 :
0]; } |
| 109 inline hb_glyph_info_t prev (void) const { return out_info[out_len ? out_len -
1 : 0]; } | 109 inline hb_glyph_info_t prev (void) const { return out_info[out_len ? out_len -
1 : 0]; } |
| 110 | 110 |
| 111 inline bool has_separate_output (void) const { return info != out_info; } | 111 inline bool has_separate_output (void) const { return info != out_info; } |
| 112 | 112 |
| 113 unsigned int serial; | 113 unsigned int serial; |
| 114 | 114 |
| 115 /* These reflect current allocations of the bytes in glyph_info_t's var1 and v
ar2. */ | |
| 116 uint8_t allocated_var_bytes[8]; | |
| 117 const char *allocated_var_owner[8]; | |
| 118 | |
| 119 /* Text before / after the main buffer contents. | 115 /* Text before / after the main buffer contents. |
| 120 * Always in Unicode, and ordered outward. | 116 * Always in Unicode, and ordered outward. |
| 121 * Index 0 is for "pre-context", 1 for "post-context". */ | 117 * Index 0 is for "pre-context", 1 for "post-context". */ |
| 122 static const unsigned int CONTEXT_LENGTH = 5; | 118 static const unsigned int CONTEXT_LENGTH = 5; |
| 123 hb_codepoint_t context[2][CONTEXT_LENGTH]; | 119 hb_codepoint_t context[2][CONTEXT_LENGTH]; |
| 124 unsigned int context_len[2]; | 120 unsigned int context_len[2]; |
| 125 | 121 |
| 126 /* Debugging */ | 122 /* Debugging API */ |
| 127 hb_buffer_message_func_t message_func; | 123 hb_buffer_message_func_t message_func; |
| 128 void *message_data; | 124 void *message_data; |
| 129 hb_destroy_func_t message_destroy; | 125 hb_destroy_func_t message_destroy; |
| 130 | 126 |
| 127 /* Internal debugging. */ |
| 128 /* The bits here reflect current allocations of the bytes in glyph_info_t's va
r1 and var2. */ |
| 129 #ifndef HB_NDEBUG |
| 130 uint8_t allocated_var_bits; |
| 131 #endif |
| 132 inline void allocate_var (unsigned int start, unsigned int count) |
| 133 { |
| 134 #ifndef HB_NDEBUG |
| 135 unsigned int end = start + count; |
| 136 assert (end <= 8); |
| 137 unsigned int bits = (1<<end) - (1<<start); |
| 138 assert (0 == (allocated_var_bits & bits)); |
| 139 allocated_var_bits |= bits; |
| 140 #endif |
| 141 } |
| 142 inline void deallocate_var (unsigned int start, unsigned int count) |
| 143 { |
| 144 #ifndef HB_NDEBUG |
| 145 unsigned int end = start + count; |
| 146 assert (end <= 8); |
| 147 unsigned int bits = (1<<end) - (1<<start); |
| 148 assert (bits == (allocated_var_bits & bits)); |
| 149 allocated_var_bits &= ~bits; |
| 150 #endif |
| 151 } |
| 152 inline void assert_var (unsigned int start, unsigned int count) |
| 153 { |
| 154 #ifndef HB_NDEBUG |
| 155 unsigned int end = start + count; |
| 156 assert (end <= 8); |
| 157 unsigned int bits = (1<<end) - (1<<start); |
| 158 assert (bits == (allocated_var_bits & bits)); |
| 159 #endif |
| 160 } |
| 161 inline void deallocate_var_all (void) |
| 162 { |
| 163 #ifndef HB_NDEBUG |
| 164 allocated_var_bits = 0; |
| 165 #endif |
| 166 } |
| 167 |
| 131 | 168 |
| 132 /* Methods */ | 169 /* Methods */ |
| 133 | 170 |
| 134 HB_INTERNAL void reset (void); | 171 HB_INTERNAL void reset (void); |
| 135 HB_INTERNAL void clear (void); | 172 HB_INTERNAL void clear (void); |
| 136 | 173 |
| 137 inline unsigned int backtrack_len (void) const | 174 inline unsigned int backtrack_len (void) const |
| 138 { return have_output? out_len : idx; } | 175 { return have_output? out_len : idx; } |
| 139 inline unsigned int lookahead_len (void) const | 176 inline unsigned int lookahead_len (void) const |
| 140 { return len - idx; } | 177 { return len - idx; } |
| 141 inline unsigned int next_serial (void) { return serial++; } | 178 inline unsigned int next_serial (void) { return serial++; } |
| 142 | 179 |
| 143 HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const
char *owner); | |
| 144 HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, cons
t char *owner); | |
| 145 HB_INTERNAL void assert_var (unsigned int byte_i, unsigned int count, const ch
ar *owner); | |
| 146 HB_INTERNAL void deallocate_var_all (void); | |
| 147 | |
| 148 HB_INTERNAL void add (hb_codepoint_t codepoint, | 180 HB_INTERNAL void add (hb_codepoint_t codepoint, |
| 149 unsigned int cluster); | 181 unsigned int cluster); |
| 150 HB_INTERNAL void add_info (const hb_glyph_info_t &glyph_info); | 182 HB_INTERNAL void add_info (const hb_glyph_info_t &glyph_info); |
| 151 | 183 |
| 152 HB_INTERNAL void reverse_range (unsigned int start, unsigned int end); | 184 HB_INTERNAL void reverse_range (unsigned int start, unsigned int end); |
| 153 HB_INTERNAL void reverse (void); | 185 HB_INTERNAL void reverse (void); |
| 154 HB_INTERNAL void reverse_clusters (void); | 186 HB_INTERNAL void reverse_clusters (void); |
| 155 HB_INTERNAL void guess_segment_properties (void); | 187 HB_INTERNAL void guess_segment_properties (void); |
| 156 | 188 |
| 157 HB_INTERNAL void swap_buffers (void); | 189 HB_INTERNAL void swap_buffers (void); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 va_list ap; | 278 va_list ap; |
| 247 va_start (ap, fmt); | 279 va_start (ap, fmt); |
| 248 bool ret = message_impl (font, fmt, ap); | 280 bool ret = message_impl (font, fmt, ap); |
| 249 va_end (ap); | 281 va_end (ap); |
| 250 return ret; | 282 return ret; |
| 251 } | 283 } |
| 252 HB_INTERNAL bool message_impl (hb_font_t *font, const char *fmt, va_list ap) H
B_PRINTF_FUNC(3, 0); | 284 HB_INTERNAL bool message_impl (hb_font_t *font, const char *fmt, va_list ap) H
B_PRINTF_FUNC(3, 0); |
| 253 }; | 285 }; |
| 254 | 286 |
| 255 | 287 |
| 256 #define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \ | 288 #define HB_BUFFER_XALLOCATE_VAR(b, func, var) \ |
| 257 b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ | 289 b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ |
| 258 » sizeof (b->info[0].var), owner) | 290 » sizeof (b->info[0].var)) |
| 259 #define HB_BUFFER_ALLOCATE_VAR(b, var) \ | 291 #define HB_BUFFER_ALLOCATE_VAR(b, var)» » HB_BUFFER_XALLOCATE_VAR (b, allo
cate_var, var ()) |
| 260 » HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var) | 292 #define HB_BUFFER_DEALLOCATE_VAR(b, var)» HB_BUFFER_XALLOCATE_VAR (b, deal
locate_var, var ()) |
| 261 #define HB_BUFFER_DEALLOCATE_VAR(b, var) \ | 293 #define HB_BUFFER_ASSERT_VAR(b, var)» » HB_BUFFER_XALLOCATE_VAR (b, asse
rt_var, var ()) |
| 262 » HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var (), #var) | |
| 263 #define HB_BUFFER_ASSERT_VAR(b, var) \ | |
| 264 » HB_BUFFER_XALLOCATE_VAR (b, assert_var, var (), #var) | |
| 265 | 294 |
| 266 | 295 |
| 267 #endif /* HB_BUFFER_PRIVATE_HH */ | 296 #endif /* HB_BUFFER_PRIVATE_HH */ |
| OLD | NEW |