Save general category and combining class in the buffer for reuse

This commit is contained in:
Behdad Esfahbod 2010-11-03 16:37:24 -04:00
parent a5ab682b9b
commit 3a852ae7fe
4 changed files with 39 additions and 12 deletions

View File

@ -39,9 +39,10 @@ HB_BEGIN_DECLS
/* buffer var allocations */
#define props_cache() var1.u16[0] /* glyph_props cache */
#define props_cache() var1.u16[1] /* glyph_props cache */
/* XXX cleanup */
typedef enum {
HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0001,
HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 0x0002,

View File

@ -28,6 +28,11 @@
HB_BEGIN_DECLS
/* buffer var allocations */
#define arabic_shaping_action() var2.u32 /* arabic shaping action */
/*
* Bits used in the joining tables
*/
@ -686,20 +691,19 @@ _hb_ot_shape_complex_setup_masks_arabic (hb_ot_shape_context_t *c)
for (unsigned int i = 0; i < count; i++)
{
unsigned int this_type = get_joining_type (c->buffer->info[i].codepoint, c->buffer->unicode->v.get_general_category (c->buffer->info[i].codepoint));
unsigned int this_type = get_joining_type (c->buffer->info[i].codepoint, (hb_category_t) c->buffer->info[i].general_category());
if (unlikely (this_type == JOINING_TYPE_T)) {
c->buffer->info[i].var2.u32 = NONE;
c->buffer->info[i].arabic_shaping_action() = NONE;
continue;
}
const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
if (entry->prev_action != NONE)
c->buffer->info[prev].var2.u32 = entry->prev_action;
c->buffer->info[prev].arabic_shaping_action() = entry->prev_action;
c->buffer->info[i].var2.u32 = entry->curr_action;
c->buffer->info[i].arabic_shaping_action() = entry->curr_action;
prev = i;
state = entry->next_state;
@ -711,7 +715,7 @@ _hb_ot_shape_complex_setup_masks_arabic (hb_ot_shape_context_t *c)
mask_array[i] = c->plan->map.get_1_mask (arabic_syriac_features[i]);
for (unsigned int i = 0; i < count; i++)
c->buffer->info[i].mask |= mask_array[c->buffer->info[i].var2.u32];
c->buffer->info[i].mask |= mask_array[c->buffer->info[i].arabic_shaping_action()];
}

View File

@ -35,6 +35,12 @@
HB_BEGIN_DECLS
/* buffer var allocations */
#define general_category() var1.u8[0] /* unicode general_category (hb_category_t) */
#define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */
enum hb_ot_complex_shaper_t {
hb_ot_complex_shaper_none,
hb_ot_complex_shaper_arabic

View File

@ -86,7 +86,7 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
hb_mask_t global_mask = c->plan->map.get_global_mask ();
c->buffer->reset_masks (global_mask);
hb_ot_shape_complex_setup_masks (c);
hb_ot_shape_complex_setup_masks (c); /* BUFFER: Clobbers var2 */
for (unsigned int i = 0; i < c->num_user_features; i++)
{
@ -140,12 +140,26 @@ is_variation_selector (hb_codepoint_t unicode)
(unicode >= 0xE0100 && unicode <= 0xE01EF)); /* VARIATION SELECTOR-17..256 */
}
static void
hb_set_unicode_props (hb_ot_shape_context_t *c)
{
hb_unicode_get_general_category_func_t get_general_category = c->buffer->unicode->v.get_general_category;
hb_unicode_get_combining_class_func_t get_combining_class = c->buffer->unicode->v.get_combining_class;
hb_glyph_info_t *info = c->buffer->info;
unsigned int count = c->buffer->len;
for (unsigned int i = 1; i < count; i++) {
info[i].general_category() = get_general_category (info[i].codepoint);
info[i].combining_class() = get_combining_class (info[i].codepoint);
}
}
static void
hb_form_clusters (hb_ot_shape_context_t *c)
{
unsigned int count = c->buffer->len;
for (unsigned int i = 1; i < count; i++)
if (c->buffer->unicode->v.get_general_category (c->buffer->info[i].codepoint) == HB_CATEGORY_NON_SPACING_MARK)
if (c->buffer->info[i].general_category() == HB_CATEGORY_NON_SPACING_MARK)
c->buffer->info[i].cluster = c->buffer->info[i - 1].cluster;
}
@ -282,11 +296,13 @@ hb_ot_shape_execute_internal (hb_ot_shape_context_t *c)
/* Save the original direction, we use it later. */
c->original_direction = c->buffer->props.direction;
hb_reset_glyph_infos (c); /* BUFFER: Clear buffer var1 and var2 */
hb_set_unicode_props (c); /* BUFFER: Set general_category and combining_class in var1 */
hb_form_clusters (c);
hb_ot_shape_setup_masks (c);
hb_reset_glyph_infos (c);
hb_ot_shape_setup_masks (c); /* BUFFER: Clobbers var2 */
/* SUBSTITUTE */
{