Add internal API for buffer var allocation
This commit is contained in:
parent
651e8dd79e
commit
f4a579bc42
|
@ -66,13 +66,15 @@ struct _hb_buffer_t {
|
||||||
unsigned int len; /* Length of ->info and ->pos arrays */
|
unsigned int len; /* Length of ->info and ->pos arrays */
|
||||||
unsigned int out_len; /* Length of ->out array if have_output */
|
unsigned int out_len; /* Length of ->out array if have_output */
|
||||||
|
|
||||||
unsigned int serial;
|
|
||||||
|
|
||||||
unsigned int allocated; /* Length of allocated arrays */
|
unsigned int allocated; /* Length of allocated arrays */
|
||||||
hb_glyph_info_t *info;
|
hb_glyph_info_t *info;
|
||||||
hb_glyph_info_t *out_info;
|
hb_glyph_info_t *out_info;
|
||||||
hb_glyph_position_t *pos;
|
hb_glyph_position_t *pos;
|
||||||
|
|
||||||
|
unsigned int serial;
|
||||||
|
uint8_t allocated_var_bytes[8];
|
||||||
|
const char *allocated_var_owner[8];
|
||||||
|
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
|
@ -82,6 +84,25 @@ struct _hb_buffer_t {
|
||||||
{ return have_output? out_len : idx; }
|
{ return have_output? out_len : idx; }
|
||||||
inline unsigned int next_serial (void) { return serial++; }
|
inline unsigned int next_serial (void) { return serial++; }
|
||||||
|
|
||||||
|
|
||||||
|
HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const char *owner);
|
||||||
|
HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, const char *owner);
|
||||||
|
|
||||||
|
inline void allocate_var_8 (unsigned int var_num, unsigned int i, const char *owner)
|
||||||
|
{ assert (var_num < 2 && i < 4); allocate_var (var_num * 4 + i, 1, owner); }
|
||||||
|
inline void allocate_var_16 (unsigned int var_num, unsigned int i, const char *owner)
|
||||||
|
{ assert (var_num < 2 && i < 2); allocate_var (var_num * 4 + i * 2, 2, owner); }
|
||||||
|
inline void allocate_var_32 (unsigned int var_num, const char *owner)
|
||||||
|
{ assert (var_num < 2); allocate_var (var_num * 4, 4, owner); }
|
||||||
|
|
||||||
|
inline void deallocate_var_8 (unsigned int var_num, unsigned int i, const char *owner)
|
||||||
|
{ assert (var_num < 2 && i < 4); deallocate_var (var_num * 4 + i, 1, owner); }
|
||||||
|
inline void deallocate_var_16 (unsigned int var_num, unsigned int i, const char *owner)
|
||||||
|
{ assert (var_num < 2 && i < 2); deallocate_var (var_num * 4 + i * 2, 2, owner); }
|
||||||
|
inline void deallocate_var_32 (unsigned int var_num, const char *owner)
|
||||||
|
{ assert (var_num < 2); deallocate_var (var_num * 4, 4, owner); }
|
||||||
|
|
||||||
|
|
||||||
HB_INTERNAL void add (hb_codepoint_t codepoint,
|
HB_INTERNAL void add (hb_codepoint_t codepoint,
|
||||||
hb_mask_t mask,
|
hb_mask_t mask,
|
||||||
unsigned int cluster);
|
unsigned int cluster);
|
||||||
|
|
|
@ -153,6 +153,8 @@ hb_buffer_t::reset (void)
|
||||||
out_len = 0;
|
out_len = 0;
|
||||||
|
|
||||||
serial = 0;
|
serial = 0;
|
||||||
|
memset (allocated_var_bytes, 0, sizeof allocated_var_bytes);
|
||||||
|
memset (allocated_var_owner, 0, sizeof allocated_var_owner);
|
||||||
|
|
||||||
out_info = info;
|
out_info = info;
|
||||||
}
|
}
|
||||||
|
@ -387,6 +389,26 @@ hb_buffer_t::reverse_clusters (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner)
|
||||||
|
{
|
||||||
|
assert (byte_i < 8 && byte_i + count < 8);
|
||||||
|
for (unsigned int i = byte_i; i < byte_i + count; i++) {
|
||||||
|
assert (!allocated_var_bytes[i]);
|
||||||
|
allocated_var_bytes[i]++;
|
||||||
|
allocated_var_owner[i] = owner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner)
|
||||||
|
{
|
||||||
|
assert (byte_i < 8 && byte_i + count < 8);
|
||||||
|
for (unsigned int i = byte_i; i < byte_i + count; i++) {
|
||||||
|
assert (allocated_var_bytes[i] && allocated_var_owner[i] == owner);
|
||||||
|
allocated_var_bytes[i]--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Public API */
|
/* Public API */
|
||||||
|
|
||||||
hb_buffer_t *
|
hb_buffer_t *
|
||||||
|
|
Loading…
Reference in New Issue