[HB] Cleanup public buffer structs

This commit is contained in:
Behdad Esfahbod 2009-08-01 22:53:04 -04:00
parent 6d5bb18e93
commit f1322e52d5
6 changed files with 97 additions and 66 deletions

View File

@ -36,6 +36,36 @@ HB_BEGIN_DECLS
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF #define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
typedef struct _hb_internal_glyph_info_t {
hb_codepoint_t codepoint;
uint32_t properties;
uint32_t cluster;
uint16_t component;
uint16_t lig_id;
uint32_t gproperty;
} hb_internal_glyph_info_t;
typedef struct _hb_internal_glyph_position_t {
hb_position_t x_pos;
hb_position_t y_pos;
hb_position_t x_advance;
hb_position_t y_advance;
hb_bool_t new_advance :1; /* if set, the advance width values are
absolute, i.e., they won't be
added to the original glyph's value
but rather replace them */
unsigned short back : 15; /* number of glyphs to go back
for drawing current glyph */
short cursive_chain : 16; /* character to which this connects,
may be positive or negative; used
only internally */
} hb_internal_glyph_position_t;
ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
struct _hb_buffer_t { struct _hb_buffer_t {
hb_reference_count_t ref_count; hb_reference_count_t ref_count;
@ -46,10 +76,10 @@ struct _hb_buffer_t {
unsigned int in_pos; unsigned int in_pos;
unsigned int out_pos; unsigned int out_pos;
hb_glyph_info_t *in_string; hb_internal_glyph_info_t *in_string;
hb_glyph_info_t *out_string; hb_internal_glyph_info_t *out_string;
hb_glyph_info_t *alt_string; hb_internal_glyph_info_t *alt_string;
hb_glyph_position_t *positions; hb_internal_glyph_position_t *positions;
hb_direction_t direction; hb_direction_t direction;
unsigned int max_lig_id; unsigned int max_lig_id;
@ -88,16 +118,16 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
/* convenience macros */ /* convenience macros */
#define IN_GLYPH(pos) (buffer->in_string[(pos)].gindex) #define IN_GLYPH(pos) (buffer->in_string[(pos)].codepoint)
#define IN_INFO(pos) (&buffer->in_string[(pos)]) #define IN_INFO(pos) (&buffer->in_string[(pos)])
#define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].gindex) #define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].codepoint)
#define IN_CURINFO() (&buffer->in_string[buffer->in_pos]) #define IN_CURINFO() (&buffer->in_string[buffer->in_pos])
#define IN_PROPERTIES(pos) (buffer->in_string[(pos)].properties) #define IN_PROPERTIES(pos) (buffer->in_string[(pos)].properties)
#define IN_LIGID(pos) (buffer->in_string[(pos)].ligID) #define IN_LIGID(pos) (buffer->in_string[(pos)].lig_id)
#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component) #define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
#define POSITION(pos) (&buffer->positions[(pos)]) #define POSITION(pos) (&buffer->positions[(pos)])
#define CURPOSITION() (&buffer->positions[buffer->in_pos]) #define CURPOSITION() (&buffer->positions[buffer->in_pos])
#define OUT_GLYPH(pos) (buffer->out_string[(pos)].gindex) #define OUT_GLYPH(pos) (buffer->out_string[(pos)].codepoint)
#define OUT_INFO(pos) (&buffer->out_string[(pos)]) #define OUT_INFO(pos) (&buffer->out_string[(pos)])
HB_END_DECLS HB_END_DECLS

View File

@ -29,6 +29,7 @@
#include <string.h> #include <string.h>
static hb_buffer_t _hb_buffer_nil = { static hb_buffer_t _hb_buffer_nil = {
HB_REFERENCE_COUNT_INVALID /* ref_count */ HB_REFERENCE_COUNT_INVALID /* ref_count */
}; };
@ -158,21 +159,21 @@ hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
void void
hb_buffer_add_glyph (hb_buffer_t *buffer, hb_buffer_add_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index, hb_codepoint_t codepoint,
unsigned int properties, unsigned int properties,
unsigned int cluster) unsigned int cluster)
{ {
hb_glyph_info_t *glyph; hb_internal_glyph_info_t *glyph;
hb_buffer_ensure (buffer, buffer->in_length + 1); hb_buffer_ensure (buffer, buffer->in_length + 1);
glyph = &buffer->in_string[buffer->in_length]; glyph = &buffer->in_string[buffer->in_length];
glyph->gindex = glyph_index; glyph->codepoint = codepoint;
glyph->properties = properties; glyph->properties = properties;
glyph->cluster = cluster; glyph->cluster = cluster;
glyph->component = 0; glyph->component = 0;
glyph->ligID = 0; glyph->lig_id = 0;
glyph->internal = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; glyph->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_length++; buffer->in_length++;
} }
@ -217,7 +218,7 @@ _hb_buffer_swap (hb_buffer_t *buffer)
if (buffer->out_string != buffer->in_string) if (buffer->out_string != buffer->in_string)
{ {
hb_glyph_info_t *tmp_string; hb_internal_glyph_info_t *tmp_string;
tmp_string = buffer->in_string; tmp_string = buffer->in_string;
buffer->in_string = buffer->out_string; buffer->in_string = buffer->out_string;
buffer->out_string = tmp_string; buffer->out_string = tmp_string;
@ -243,9 +244,9 @@ _hb_buffer_swap (hb_buffer_t *buffer)
will copied `num_out' times, otherwise `component' itself will will copied `num_out' times, otherwise `component' itself will
be used to fill the `component' fields. be used to fill the `component' fields.
If `ligID' is 0xFFFF, the ligID value from buffer->in_pos If `lig_id' is 0xFFFF, the lig_id value from buffer->in_pos
will copied `num_out' times, otherwise `ligID' itself will will copied `num_out' times, otherwise `lig_id' itself will
be used to fill the `ligID' fields. be used to fill the `lig_id' fields.
The properties for all replacement glyphs are taken The properties for all replacement glyphs are taken
from the glyph at position `buffer->in_pos'. from the glyph at position `buffer->in_pos'.
@ -258,7 +259,7 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
unsigned int num_out, unsigned int num_out,
const uint16_t *glyph_data_be, const uint16_t *glyph_data_be,
unsigned short component, unsigned short component,
unsigned short ligID) unsigned short lig_id)
{ {
unsigned int i; unsigned int i;
unsigned int properties; unsigned int properties;
@ -274,18 +275,18 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
cluster = buffer->in_string[buffer->in_pos].cluster; cluster = buffer->in_string[buffer->in_pos].cluster;
if (component == 0xFFFF) if (component == 0xFFFF)
component = buffer->in_string[buffer->in_pos].component; component = buffer->in_string[buffer->in_pos].component;
if (ligID == 0xFFFF) if (lig_id == 0xFFFF)
ligID = buffer->in_string[buffer->in_pos].ligID; lig_id = buffer->in_string[buffer->in_pos].lig_id;
for (i = 0; i < num_out; i++) for (i = 0; i < num_out; i++)
{ {
hb_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i]; hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i];
info->gindex = hb_be_uint16 (glyph_data_be[i]); info->codepoint = hb_be_uint16 (glyph_data_be[i]);
info->properties = properties; info->properties = properties;
info->cluster = cluster; info->cluster = cluster;
info->component = component; info->component = component;
info->ligID = ligID; info->lig_id = lig_id;
info->internal = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
} }
buffer->in_pos += num_in; buffer->in_pos += num_in;
@ -298,9 +299,9 @@ HB_INTERNAL void
_hb_buffer_add_output_glyph (hb_buffer_t *buffer, _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index, hb_codepoint_t glyph_index,
unsigned short component, unsigned short component,
unsigned short ligID) unsigned short lig_id)
{ {
hb_glyph_info_t *info; hb_internal_glyph_info_t *info;
if (buffer->out_string != buffer->in_string) if (buffer->out_string != buffer->in_string)
{ {
@ -311,12 +312,12 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
info = &buffer->out_string[buffer->out_pos]; info = &buffer->out_string[buffer->out_pos];
info->gindex = glyph_index; info->codepoint = glyph_index;
if (component != 0xFFFF) if (component != 0xFFFF)
info->component = component; info->component = component;
if (ligID != 0xFFFF) if (lig_id != 0xFFFF)
info->ligID = ligID; info->lig_id = lig_id;
info->internal = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_pos++; buffer->in_pos++;
buffer->out_pos++; buffer->out_pos++;
@ -363,7 +364,7 @@ hb_buffer_get_len (hb_buffer_t *buffer)
hb_glyph_info_t * hb_glyph_info_t *
hb_buffer_get_glyph_infos (hb_buffer_t *buffer) hb_buffer_get_glyph_infos (hb_buffer_t *buffer)
{ {
return buffer->in_string; return (hb_glyph_info_t *) buffer->in_string;
} }
/* Return value valid as long as buffer not modified */ /* Return value valid as long as buffer not modified */
@ -373,5 +374,5 @@ hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
if (buffer->in_length && !buffer->positions) if (buffer->in_length && !buffer->positions)
hb_buffer_clear_positions (buffer); hb_buffer_clear_positions (buffer);
return buffer->positions; return (hb_glyph_position_t *) buffer->positions;
} }

View File

@ -41,15 +41,13 @@ typedef enum _hb_direction_t {
HB_DIRECTION_BTT HB_DIRECTION_BTT
} hb_direction_t; } hb_direction_t;
/* XXX these structs need review before we can commit to them */
typedef struct _hb_glyph_info_t { typedef struct _hb_glyph_info_t {
hb_codepoint_t gindex; hb_codepoint_t codepoint;
unsigned int properties; uint32_t properties;
unsigned int cluster; uint32_t cluster;
unsigned short component; uint16_t component;
unsigned short ligID; uint16_t lig_id;
unsigned int internal; uint32_t internal;
} hb_glyph_info_t; } hb_glyph_info_t;
typedef struct _hb_glyph_position_t { typedef struct _hb_glyph_position_t {
@ -57,13 +55,14 @@ typedef struct _hb_glyph_position_t {
hb_position_t y_pos; hb_position_t y_pos;
hb_position_t x_advance; hb_position_t x_advance;
hb_position_t y_advance; hb_position_t y_advance;
unsigned short back; /* number of glyphs to go back /* XXX these should all be replaced by "uint32_t internal" */
for drawing current glyph */ hb_bool_t new_advance :1; /* if set, the advance width values are
hb_bool_t new_advance; /* if set, the advance width values are
absolute, i.e., they won't be absolute, i.e., they won't be
added to the original glyph's value added to the original glyph's value
but rather replace them */ but rather replace them */
short cursive_chain; /* character to which this connects, unsigned short back : 15; /* number of glyphs to go back
for drawing current glyph */
short cursive_chain : 16; /* character to which this connects,
may be positive or negative; used may be positive or negative; used
only internally */ only internally */
} hb_glyph_position_t; } hb_glyph_position_t;
@ -103,7 +102,7 @@ hb_buffer_ensure (hb_buffer_t *buffer,
void void
hb_buffer_add_glyph (hb_buffer_t *buffer, hb_buffer_add_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index, hb_codepoint_t codepoint,
unsigned int properties, unsigned int properties,
unsigned int cluster); unsigned int cluster);

View File

@ -58,7 +58,7 @@ struct ValueFormat : USHORT
const void apply_value (hb_ot_layout_t *layout, const void apply_value (hb_ot_layout_t *layout,
const char *base, const char *base,
const Value *values, const Value *values,
hb_glyph_position_t *glyph_pos) const hb_internal_glyph_position_t *glyph_pos) const
{ {
unsigned int x_ppem, y_ppem; unsigned int x_ppem, y_ppem;
hb_16dot16_t x_scale, y_scale; hb_16dot16_t x_scale, y_scale;
@ -825,7 +825,7 @@ struct MarkBasePosFormat1
unsigned int index = base_index * classCount + mark_class; unsigned int index = base_index * classCount + mark_class;
(&base_array+base_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &base_x, &base_y); (&base_array+base_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &base_x, &base_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos); hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = base_x - mark_x; o->x_pos = base_x - mark_x;
o->y_pos = base_y - mark_y; o->y_pos = base_y - mark_y;
o->x_advance = 0; o->x_advance = 0;
@ -962,7 +962,7 @@ struct MarkLigPosFormat1
unsigned int index = comp_index * classCount + mark_class; unsigned int index = comp_index * classCount + mark_class;
(&lig_attach+lig_attach.matrix[index]).get_anchor (layout, IN_GLYPH (j), &lig_x, &lig_y); (&lig_attach+lig_attach.matrix[index]).get_anchor (layout, IN_GLYPH (j), &lig_x, &lig_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos); hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = lig_x - mark_x; o->x_pos = lig_x - mark_x;
o->y_pos = lig_y - mark_y; o->y_pos = lig_y - mark_y;
o->x_advance = 0; o->x_advance = 0;
@ -1077,7 +1077,7 @@ struct MarkMarkPosFormat1
unsigned int index = mark2_index * classCount + mark1_class; unsigned int index = mark2_index * classCount + mark1_class;
(&mark2_array+mark2_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &mark2_x, &mark2_y); (&mark2_array+mark2_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &mark2_x, &mark2_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos); hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = mark2_x - mark1_x; o->x_pos = mark2_x - mark1_x;
o->y_pos = mark2_y - mark1_y; o->y_pos = mark2_y - mark1_y;
o->x_advance = 0; o->x_advance = 0;

View File

@ -29,6 +29,7 @@
#include "hb-private.h" #include "hb-private.h"
#include "hb-ot-layout.h" #include "hb-ot-layout.h"
#include "hb-buffer-private.h"
typedef unsigned int hb_ot_layout_class_t; typedef unsigned int hb_ot_layout_class_t;
@ -78,13 +79,13 @@ _hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout,
HB_INTERNAL hb_bool_t HB_INTERNAL hb_bool_t
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout, _hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo, hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags, unsigned int lookup_flags,
unsigned int *property); unsigned int *property);
HB_INTERNAL hb_bool_t HB_INTERNAL hb_bool_t
_hb_ot_layout_skip_mark (hb_ot_layout_t *layout, _hb_ot_layout_skip_mark (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo, hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags, unsigned int lookup_flags,
unsigned int *property); unsigned int *property);

View File

@ -176,15 +176,15 @@ _hb_ot_layout_get_glyph_property (hb_ot_layout_t *layout,
HB_INTERNAL hb_bool_t HB_INTERNAL hb_bool_t
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout, _hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo, hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags, unsigned int lookup_flags,
unsigned int *property_out) unsigned int *property_out)
{ {
unsigned int property; unsigned int property;
if (ginfo->internal == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
ginfo->internal = _hb_ot_layout_get_glyph_property (layout, ginfo->gindex); ginfo->gproperty = _hb_ot_layout_get_glyph_property (layout, ginfo->codepoint);
property = ginfo->internal; property = ginfo->gproperty;
if (property_out) if (property_out)
*property_out = property; *property_out = property;
@ -200,7 +200,7 @@ _hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
* lookup_flags has the set index. * lookup_flags has the set index.
*/ */
if (lookup_flags & LookupFlag::UseMarkFilteringSet) if (lookup_flags & LookupFlag::UseMarkFilteringSet)
return layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->gindex); return layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->codepoint);
/* The second byte of lookup_flags has the meaning /* The second byte of lookup_flags has the meaning
* "ignore marks of attachment type different than * "ignore marks of attachment type different than
@ -215,15 +215,15 @@ _hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
HB_INTERNAL hb_bool_t HB_INTERNAL hb_bool_t
_hb_ot_layout_skip_mark (hb_ot_layout_t *layout, _hb_ot_layout_skip_mark (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo, hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags, unsigned int lookup_flags,
unsigned int *property_out) unsigned int *property_out)
{ {
unsigned int property; unsigned int property;
if (ginfo->internal == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
ginfo->internal = _hb_ot_layout_get_glyph_property (layout, ginfo->gindex); ginfo->gproperty = _hb_ot_layout_get_glyph_property (layout, ginfo->codepoint);
property = ginfo->internal; property = ginfo->gproperty;
if (property_out) if (property_out)
*property_out = property; *property_out = property;
@ -235,7 +235,7 @@ _hb_ot_layout_skip_mark (hb_ot_layout_t *layout,
/* If using mark filtering sets, the high short of lookup_flags has the set index. */ /* If using mark filtering sets, the high short of lookup_flags has the set index. */
if (lookup_flags & LookupFlag::UseMarkFilteringSet) if (lookup_flags & LookupFlag::UseMarkFilteringSet)
return !layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->gindex); return !layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->codepoint);
/* The second byte of lookup_flags has the meaning "ignore marks of attachment type /* The second byte of lookup_flags has the meaning "ignore marks of attachment type
* different than the attachment type specified." */ * different than the attachment type specified." */