Rename hb_mask_allocator_t to hb_ot_map_t

hb_ot_plan_t may be a better name, donno.
This commit is contained in:
Behdad Esfahbod 2010-10-08 20:20:32 -04:00
parent f5dd3be46b
commit 36925f695d
4 changed files with 27 additions and 32 deletions

View File

@ -41,7 +41,7 @@ HB_BEGIN_DECLS
static const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS}; static const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS};
struct hb_mask_allocator_t { struct hb_ot_map_t {
private: private:
@ -103,7 +103,7 @@ struct hb_mask_allocator_t {
public: public:
hb_mask_allocator_t (void) : feature_count (0) {} hb_ot_map_t (void) : feature_count (0) {}
void add_feature (hb_tag_t tag, void add_feature (hb_tag_t tag,
unsigned int value, unsigned int value,

View File

@ -34,7 +34,7 @@ HB_BEGIN_DECLS
void void
hb_mask_allocator_t::compile (hb_ot_shape_context_t *c) hb_ot_map_t::compile (hb_ot_shape_context_t *c)
{ {
global_mask = 0; global_mask = 0;
lookup_count[0] = lookup_count[1] = 0; lookup_count[0] = lookup_count[1] = 0;

View File

@ -35,7 +35,7 @@
HB_BEGIN_DECLS HB_BEGIN_DECLS
struct hb_mask_allocator_t; struct hb_ot_map_t;
struct hb_ot_shape_context_t struct hb_ot_shape_context_t
{ {
@ -51,7 +51,7 @@ struct hb_ot_shape_context_t
hb_bool_t applied_substitute_complex; hb_bool_t applied_substitute_complex;
hb_bool_t applied_position_complex; hb_bool_t applied_position_complex;
struct hb_mask_allocator_t *allocator; struct hb_ot_map_t *map;
}; };

View File

@ -49,17 +49,16 @@ hb_tag_t default_features[] = {
}; };
static void static void
hb_ot_shape_collect_features (hb_ot_shape_context_t *c, hb_ot_shape_collect_features (hb_ot_shape_context_t *c)
hb_mask_allocator_t *allocator)
{ {
switch (c->original_direction) { switch (c->original_direction) {
case HB_DIRECTION_LTR: case HB_DIRECTION_LTR:
allocator->add_feature (HB_TAG ('l','t','r','a'), 1, true); c->map->add_feature (HB_TAG ('l','t','r','a'), 1, true);
allocator->add_feature (HB_TAG ('l','t','r','m'), 1, true); c->map->add_feature (HB_TAG ('l','t','r','m'), 1, true);
break; break;
case HB_DIRECTION_RTL: case HB_DIRECTION_RTL:
allocator->add_feature (HB_TAG ('r','t','l','a'), 1, true); c->map->add_feature (HB_TAG ('r','t','l','a'), 1, true);
allocator->add_feature (HB_TAG ('r','t','l','m'), 1, false); c->map->add_feature (HB_TAG ('r','t','l','m'), 1, false);
break; break;
case HB_DIRECTION_TTB: case HB_DIRECTION_TTB:
case HB_DIRECTION_BTT: case HB_DIRECTION_BTT:
@ -68,29 +67,28 @@ hb_ot_shape_collect_features (hb_ot_shape_context_t *c,
} }
for (unsigned int i = 0; i < ARRAY_LENGTH (default_features); i++) for (unsigned int i = 0; i < ARRAY_LENGTH (default_features); i++)
allocator->add_feature (default_features[i], 1, true); c->map->add_feature (default_features[i], 1, true);
/* complex */ /* complex */
for (unsigned int i = 0; i < c->num_features; i++) { for (unsigned int i = 0; i < c->num_features; i++) {
const hb_feature_t *feature = &c->features[i]; const hb_feature_t *feature = &c->features[i];
allocator->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1)); c->map->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1));
} }
} }
static void static void
hb_ot_shape_setup_lookups (hb_ot_shape_context_t *c, hb_ot_shape_setup_lookups (hb_ot_shape_context_t *c)
hb_mask_allocator_t *allocator)
{ {
hb_ot_shape_collect_features (c, allocator); hb_ot_shape_collect_features (c);
/* Compile features */ /* Compile features */
allocator->compile (c); c->map->compile (c);
/* Set masks in buffer */ /* Set masks in buffer */
hb_mask_t global_mask = allocator->get_global_mask (); hb_mask_t global_mask = c->map->get_global_mask ();
if (global_mask) if (global_mask)
c->buffer->set_masks (global_mask, global_mask, 0, (unsigned int) -1); c->buffer->set_masks (global_mask, global_mask, 0, (unsigned int) -1);
@ -99,7 +97,7 @@ hb_ot_shape_setup_lookups (hb_ot_shape_context_t *c,
hb_feature_t *feature = &c->features[i]; hb_feature_t *feature = &c->features[i];
if (!(feature->start == 0 && feature->end == (unsigned int)-1)) { if (!(feature->start == 0 && feature->end == (unsigned int)-1)) {
unsigned int shift; unsigned int shift;
hb_mask_t mask = allocator->get_mask (feature->tag, &shift); hb_mask_t mask = c->map->get_mask (feature->tag, &shift);
c->buffer->set_masks (feature->value << shift, mask, feature->start, feature->end); c->buffer->set_masks (feature->value << shift, mask, feature->start, feature->end);
} }
} }
@ -109,27 +107,25 @@ hb_ot_shape_setup_lookups (hb_ot_shape_context_t *c,
static void static void
hb_ot_substitute_complex (hb_ot_shape_context_t *c, hb_ot_substitute_complex (hb_ot_shape_context_t *c)
const hb_mask_allocator_t *allocator)
{ {
if (!hb_ot_layout_has_substitution (c->face)) if (!hb_ot_layout_has_substitution (c->face))
return; return;
allocator->substitute (c); c->map->substitute (c);
c->applied_substitute_complex = TRUE; c->applied_substitute_complex = TRUE;
return; return;
} }
static void static void
hb_ot_position_complex (hb_ot_shape_context_t *c, hb_ot_position_complex (hb_ot_shape_context_t *c)
const hb_mask_allocator_t *allocator)
{ {
if (!hb_ot_layout_has_positioning (c->face)) if (!hb_ot_layout_has_positioning (c->face))
return; return;
allocator->position (c); c->map->position (c);
hb_ot_layout_position_finish (c->font, c->face, c->buffer); hb_ot_layout_position_finish (c->font, c->face, c->buffer);
@ -184,7 +180,7 @@ hb_mirror_chars (hb_buffer_t *buffer)
if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) if (HB_DIRECTION_IS_FORWARD (buffer->props.direction))
return; return;
// map = allocator.find_feature (HB_TAG ('r','t','l','m')); // map = c->map.find_feature (HB_TAG ('r','t','l','m'));
unsigned int count = buffer->len; unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++) { for (unsigned int i = 0; i < count; i++) {
@ -282,10 +278,7 @@ hb_position_complex_fallback_visual (hb_ot_shape_context_t *c)
static void static void
hb_ot_shape_internal (hb_ot_shape_context_t *c) hb_ot_shape_internal (hb_ot_shape_context_t *c)
{ {
hb_mask_allocator_t allocator; hb_ot_shape_setup_lookups (c);
hb_ot_shape_setup_lookups (c, &allocator);
hb_form_clusters (c->buffer); hb_form_clusters (c->buffer);
@ -300,7 +293,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
hb_substitute_default (c); hb_substitute_default (c);
hb_ot_substitute_complex (c, &allocator); hb_ot_substitute_complex (c);
if (!c->applied_substitute_complex) if (!c->applied_substitute_complex)
hb_substitute_complex_fallback (c); hb_substitute_complex_fallback (c);
@ -312,7 +305,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
hb_position_default (c); hb_position_default (c);
hb_ot_position_complex (c, &allocator); hb_ot_position_complex (c);
hb_bool_t position_fallback = !c->applied_position_complex; hb_bool_t position_fallback = !c->applied_position_complex;
if (position_fallback) if (position_fallback)
@ -336,9 +329,11 @@ hb_ot_shape (hb_font_t *font,
unsigned int num_features) unsigned int num_features)
{ {
hb_ot_shape_context_t c = {font, face, buffer, features, num_features}; hb_ot_shape_context_t c = {font, face, buffer, features, num_features};
hb_ot_map_t map;
/* Setup transient context members */ /* Setup transient context members */
c.original_direction = buffer->props.direction; c.original_direction = buffer->props.direction;
c.map = &map;
hb_ot_shape_internal (&c); hb_ot_shape_internal (&c);
} }