From 3a852ae7fe6edfaadd75625d27515a3689503395 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 3 Nov 2010 16:37:24 -0400 Subject: [PATCH] Save general category and combining class in the buffer for reuse --- src/hb-ot-layout-private.hh | 3 ++- src/hb-ot-shape-complex-arabic.cc | 16 ++++++++++------ src/hb-ot-shape-private.hh | 6 ++++++ src/hb-ot-shape.cc | 26 +++++++++++++++++++++----- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 4d8a855..b0088fb 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -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, diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 2401c36..a63060c 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -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()]; } diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index 0794fbf..6197406 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -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 diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index a4e568d..346cb37 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -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++) { @@ -141,11 +141,25 @@ is_variation_selector (hb_codepoint_t unicode) } 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_form_clusters (c); + hb_reset_glyph_infos (c); /* BUFFER: Clear buffer var1 and var2 */ - hb_ot_shape_setup_masks (c); + hb_set_unicode_props (c); /* BUFFER: Set general_category and combining_class in var1 */ + + hb_form_clusters (c); - hb_reset_glyph_infos (c); + hb_ot_shape_setup_masks (c); /* BUFFER: Clobbers var2 */ /* SUBSTITUTE */ { -- 2.7.4