Move more code around
Buffer var allocation coming into shape
This commit is contained in:
parent
cc06c243d8
commit
a9ad3d3460
|
@ -87,6 +87,7 @@ struct _hb_buffer_t {
|
|||
|
||||
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);
|
||||
HB_INTERNAL void deallocate_var_all (void);
|
||||
|
||||
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); }
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
#ifndef HB_DEBUG_BUFFER
|
||||
#define HB_DEBUG_BUFFER (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
|
||||
static hb_buffer_t _hb_buffer_nil = {
|
||||
HB_OBJECT_HEADER_STATIC,
|
||||
|
||||
|
@ -388,10 +393,28 @@ hb_buffer_t::reverse_clusters (void)
|
|||
reverse_range (start, i);
|
||||
}
|
||||
|
||||
static inline void
|
||||
dump_var_allocation (const hb_buffer_t *buffer)
|
||||
{
|
||||
char buf[80];
|
||||
for (unsigned int i = 0; i < 8; i++)
|
||||
buf[i] = '0' + buffer->allocated_var_bytes[i];
|
||||
buf[8] = '\0';
|
||||
DEBUG_MSG (BUFFER, buffer,
|
||||
"Current var allocation: %s",
|
||||
buf);
|
||||
}
|
||||
|
||||
void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner)
|
||||
{
|
||||
assert (byte_i < 8 && byte_i + count < 8);
|
||||
|
||||
if (DEBUG (BUFFER))
|
||||
dump_var_allocation (this);
|
||||
DEBUG_MSG (BUFFER, this,
|
||||
"Allocating var bytes %d..%d for %s",
|
||||
byte_i, byte_i + count - 1, owner);
|
||||
|
||||
for (unsigned int i = byte_i; i < byte_i + count; i++) {
|
||||
assert (!allocated_var_bytes[i]);
|
||||
allocated_var_bytes[i]++;
|
||||
|
@ -401,13 +424,25 @@ void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const c
|
|||
|
||||
void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner)
|
||||
{
|
||||
DEBUG_MSG (BUFFER, this,
|
||||
"Deallocating var bytes %d..%d for %s",
|
||||
byte_i, byte_i + count - 1, 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]--;
|
||||
}
|
||||
|
||||
if (DEBUG (BUFFER))
|
||||
dump_var_allocation (this);
|
||||
}
|
||||
|
||||
void hb_buffer_t::deallocate_var_all (void)
|
||||
{
|
||||
memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes));
|
||||
memset (allocated_var_owner, 0, sizeof (allocated_var_owner));
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
|
||||
|
|
|
@ -1507,6 +1507,7 @@ struct GPOS : GSUBGPOS
|
|||
hb_mask_t mask) const
|
||||
{ return get_lookup (lookup_index).apply_string (font, buffer, mask); }
|
||||
|
||||
static inline void position_start (hb_buffer_t *buffer);
|
||||
static inline void position_finish (hb_buffer_t *buffer);
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||
|
@ -1564,6 +1565,12 @@ fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t di
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
GPOS::position_start (hb_buffer_t *buffer)
|
||||
{
|
||||
buffer->clear_positions ();
|
||||
}
|
||||
|
||||
void
|
||||
GPOS::position_finish (hb_buffer_t *buffer)
|
||||
{
|
||||
|
|
|
@ -870,6 +870,9 @@ struct GSUB : GSUBGPOS
|
|||
hb_mask_t mask) const
|
||||
{ return get_lookup (lookup_index).apply_string (face, buffer, mask); }
|
||||
|
||||
static inline void substitute_start (hb_buffer_t *buffer);
|
||||
static inline void substitute_finish (hb_buffer_t *buffer);
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||
TRACE_SANITIZE ();
|
||||
if (unlikely (!GSUBGPOS::sanitize (c))) return false;
|
||||
|
@ -881,6 +884,21 @@ struct GSUB : GSUBGPOS
|
|||
};
|
||||
|
||||
|
||||
void
|
||||
GSUB::substitute_start (hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
/* XXX */
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
buffer->info[i].var1.u32 = buffer->info[i].var2.u32 = 0;
|
||||
}
|
||||
|
||||
void
|
||||
GSUB::substitute_finish (hb_buffer_t *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* Out-of-class implementation for methods recursing */
|
||||
|
||||
inline bool ExtensionSubst::apply (hb_apply_context_t *c) const
|
||||
|
|
|
@ -443,10 +443,7 @@ hb_ot_layout_has_substitution (hb_face_t *face)
|
|||
void
|
||||
hb_ot_layout_substitute_start (hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
/* XXX */
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
buffer->info[i].var1.u32 = buffer->info[i].var2.u32 = 0;
|
||||
GSUB::substitute_start (buffer);
|
||||
}
|
||||
|
||||
hb_bool_t
|
||||
|
@ -461,6 +458,7 @@ hb_ot_layout_substitute_lookup (hb_face_t *face,
|
|||
void
|
||||
hb_ot_layout_substitute_finish (hb_buffer_t *buffer HB_UNUSED)
|
||||
{
|
||||
GSUB::substitute_finish (buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -477,7 +475,7 @@ hb_ot_layout_has_positioning (hb_face_t *face)
|
|||
void
|
||||
hb_ot_layout_position_start (hb_buffer_t *buffer)
|
||||
{
|
||||
buffer->clear_positions ();
|
||||
GPOS::position_start (buffer);
|
||||
}
|
||||
|
||||
hb_bool_t
|
||||
|
|
Loading…
Reference in New Issue