From 16c6a27b4bffc19026944c7bea9cf0a3a8ff1d8f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 Aug 2012 09:38:28 -0400 Subject: [PATCH] [OT] Port complex_shaper to planner/plan --- src/hb-ot-shape-complex-arabic.cc | 17 ++++++++-------- src/hb-ot-shape-complex-indic.cc | 19 ++++++++---------- src/hb-ot-shape-complex-misc.cc | 20 ++++++++----------- src/hb-ot-shape-complex-private.hh | 32 ++++++++++-------------------- src/hb-ot-shape-private.hh | 14 ++++++++++--- src/hb-ot-shape.cc | 9 +++++---- 6 files changed, 51 insertions(+), 60 deletions(-) diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 4ce09a84d..3290ee1a1 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -165,10 +165,10 @@ static const struct arabic_state_table_entry { static void -collect_features_arabic (const hb_ot_complex_shaper_t *shaper, - hb_ot_map_builder_t *map, - const hb_segment_properties_t *props) +collect_features_arabic (hb_ot_shape_planner_t *plan) { + hb_ot_map_builder_t *map = &plan->map; + /* For Language forms (in ArabicOT speak), we do the iso/fina/medi/init together, * then rlig and calt each in their own stage. This makes IranNastaliq's ALLAH * ligature work correctly. It's unfortunate though... @@ -184,7 +184,7 @@ collect_features_arabic (const hb_ot_complex_shaper_t *shaper, map->add_gsub_pause (NULL, NULL); - unsigned int num_features = props->script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES; + unsigned int num_features = plan->props.script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES; for (unsigned int i = 0; i < num_features; i++) map->add_bool_feature (arabic_syriac_features[i], false); @@ -236,10 +236,9 @@ arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer) } static void -setup_masks_arabic (const hb_ot_complex_shaper_t *shaper, - const hb_ot_map_t *map, - hb_buffer_t *buffer, - hb_font_t *font) +setup_masks_arabic (const hb_ot_shape_plan_t *plan, + hb_buffer_t *buffer, + hb_font_t *font) { unsigned int count = buffer->len; unsigned int prev = 0, state = 0; @@ -270,7 +269,7 @@ setup_masks_arabic (const hb_ot_complex_shaper_t *shaper, hb_mask_t total_masks = 0; unsigned int num_masks = buffer->props.script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES; for (unsigned int i = 0; i < num_masks; i++) { - mask_array[i] = map->get_1_mask (arabic_syriac_features[i]); + mask_array[i] = plan->map.get_1_mask (arabic_syriac_features[i]); total_masks |= mask_array[i]; } diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 19ff048cc..652e4e6a3 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -203,10 +203,10 @@ final_reordering (const hb_ot_map_t *map, void *user_data HB_UNUSED); static void -collect_features_indic (const hb_ot_complex_shaper_t *shaper, - hb_ot_map_builder_t *map, - const hb_segment_properties_t *props) +collect_features_indic (hb_ot_shape_planner_t *plan) { + hb_ot_map_builder_t *map = &plan->map; + map->add_bool_feature (HB_TAG('l','o','c','l')); /* The Indic specs do not require ccmp, but we apply it here since if * there is a use of it, it's typically at the beginning. */ @@ -226,21 +226,18 @@ collect_features_indic (const hb_ot_complex_shaper_t *shaper, } static void -override_features_indic (const hb_ot_complex_shaper_t *shaper, - hb_ot_map_builder_t *map, - const hb_segment_properties_t *props) +override_features_indic (hb_ot_shape_planner_t *plan) { /* Uniscribe does not apply 'kern'. */ if (indic_options ().uniscribe_bug_compatible) - map->add_feature (HB_TAG('k','e','r','n'), 0, true); + plan->map.add_feature (HB_TAG('k','e','r','n'), 0, true); } static void -setup_masks_indic (const hb_ot_complex_shaper_t *shaper, - const hb_ot_map_t *map, - hb_buffer_t *buffer, - hb_font_t *font HB_UNUSED) +setup_masks_indic (const hb_ot_shape_plan_t *plan HB_UNUSED, + hb_buffer_t *buffer, + hb_font_t *font HB_UNUSED) { HB_BUFFER_ALLOCATE_VAR (buffer, indic_category); HB_BUFFER_ALLOCATE_VAR (buffer, indic_position); diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc index 06b873a1a..6ae9f5050 100644 --- a/src/hb-ot-shape-complex-misc.cc +++ b/src/hb-ot-shape-complex-misc.cc @@ -50,13 +50,11 @@ static const hb_tag_t tibetan_features[] = }; static void -collect_features_default (const hb_ot_complex_shaper_t *shaper, - hb_ot_map_builder_t *map, - const hb_segment_properties_t *props) +collect_features_default (hb_ot_shape_planner_t *plan) { const hb_tag_t *script_features = NULL; - switch ((hb_tag_t) props->script) + switch ((hb_tag_t) plan->props.script) { /* Unicode-1.1 additions */ case HB_SCRIPT_HANGUL: @@ -70,14 +68,13 @@ collect_features_default (const hb_ot_complex_shaper_t *shaper, } for (; script_features && *script_features; script_features++) - map->add_bool_feature (*script_features); + plan->map.add_bool_feature (*script_features); } static hb_ot_shape_normalization_mode_t -normalization_preference_default (const hb_ot_complex_shaper_t *shaper, - const hb_segment_properties_t *props) +normalization_preference_default (const hb_ot_shape_plan_t *plan) { - switch ((hb_tag_t) props->script) + switch ((hb_tag_t) plan->props.script) { /* Unicode-1.1 additions */ case HB_SCRIPT_HANGUL: @@ -100,10 +97,9 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default = /* Thai / Lao shaper */ static void -setup_masks_thai (const hb_ot_complex_shaper_t *shaper, - const hb_ot_map_t *map, - hb_buffer_t *buffer, - hb_font_t *font) +setup_masks_thai (const hb_ot_shape_plan_t *plan HB_UNUSED, + hb_buffer_t *buffer, + hb_font_t *font HB_UNUSED) { /* The following is NOT specified in the MS OT Thai spec, however, it seems * to be what Uniscribe and other engines implement. According to Eric Muller: diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh index 9cdafff25..e7f96976f 100644 --- a/src/hb-ot-shape-complex-private.hh +++ b/src/hb-ot-shape-complex-private.hh @@ -29,15 +29,11 @@ #include "hb-private.hh" -#include "hb-ot-map-private.hh" +#include "hb-ot-shape-private.hh" #include "hb-ot-shape-normalize-private.hh" -/* buffer var allocations, used during the entire shaping process */ -#define unicode_props0() var1.u8[0] -#define unicode_props1() var1.u8[1] - /* buffer var allocations, used by complex shapers */ #define complex_var_persistent_u8_0() var2.u8[2] #define complex_var_persistent_u8_1() var2.u8[3] @@ -60,39 +56,33 @@ struct hb_ot_complex_shaper_t /* collect_features() * Called during shape_plan(). - * Shapers should use map to add their features and callbacks. + * Shapers should use plan->map to add their features and callbacks. * May be NULL. */ - void (*collect_features) (const hb_ot_complex_shaper_t *shaper, - hb_ot_map_builder_t *map, - const hb_segment_properties_t *props); + void (*collect_features) (hb_ot_shape_planner_t *plan); /* override_features() * Called during shape_plan(). - * Shapers should use map to override features and add callbacks after + * Shapers should use plan->map to override features and add callbacks after * common features are added. * May be NULL. */ - void (*override_features) (const hb_ot_complex_shaper_t *shaper, - hb_ot_map_builder_t *map, - const hb_segment_properties_t *props); + void (*override_features) (hb_ot_shape_planner_t *plan); /* normalization_preference() - * Called during shape_execute(). + * Called during shape(). */ hb_ot_shape_normalization_mode_t - (*normalization_preference) (const hb_ot_complex_shaper_t *shaper, - const hb_segment_properties_t *props); + (*normalization_preference) (const hb_ot_shape_plan_t *plan); /* setup_masks() - * Called during shape_execute(). + * Called during shape(). * Shapers should use map to get feature masks and set on buffer. */ - void (*setup_masks) (const hb_ot_complex_shaper_t *shaper, - const hb_ot_map_t *map, - hb_buffer_t *buffer, - hb_font_t *font); + void (*setup_masks) (const hb_ot_shape_plan_t *plan, + hb_buffer_t *buffer, + hb_font_t *font); bool zero_width_attached_marks; }; diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index 89f15bef9..0c265280b 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -30,12 +30,19 @@ #include "hb-private.hh" #include "hb-ot-map-private.hh" -#include "hb-ot-shape-complex-private.hh" + + + +/* buffer var allocations, used during the entire shaping process */ +#define unicode_props0() var1.u8[0] +#define unicode_props1() var1.u8[1] + struct hb_ot_shape_plan_t { - const hb_ot_complex_shaper_t *shaper; + hb_segment_properties_t props; + const struct hb_ot_complex_shaper_t *shaper; hb_ot_map_t map; }; @@ -44,7 +51,7 @@ struct hb_ot_shape_planner_t /* In the order that they are filled in. */ hb_face_t *face; hb_segment_properties_t props; - const hb_ot_complex_shaper_t *shaper; + const struct hb_ot_complex_shaper_t *shaper; hb_ot_map_builder_t map; hb_ot_shape_planner_t (const hb_shape_plan_t *master_plan) : @@ -56,6 +63,7 @@ struct hb_ot_shape_planner_t inline void compile (hb_ot_shape_plan_t &plan) { + plan.props = props; plan.shaper = shaper; map.compile (face, &props, plan.map); } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index f6d7a839d..c874fb537 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -33,6 +33,7 @@ #include "hb-ot-shape-private.hh" #include "hb-ot-shape-normalize-private.hh" +#include "hb-ot-shape-complex-private.hh" #include "hb-ot-layout-private.hh" #include "hb-set-private.hh" @@ -99,7 +100,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, } HB_STMT_END if (planner->shaper->collect_features) - planner->shaper->collect_features (planner->shaper, &planner->map, props); + planner->shaper->collect_features (planner); ADD_FEATURES (common_features); @@ -109,7 +110,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, ADD_FEATURES (vertical_features); if (planner->shaper->override_features) - planner->shaper->override_features (planner->shaper, &planner->map, props); + planner->shaper->override_features (planner); #undef ADD_FEATURES @@ -214,7 +215,7 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c) c->buffer->reset_masks (global_mask); if (c->plan->shaper->setup_masks) - c->plan->shaper->setup_masks (c->plan->shaper, &c->plan->map, c->buffer, c->font); + c->plan->shaper->setup_masks (c->plan, c->buffer, c->font); for (unsigned int i = 0; i < c->num_user_features; i++) { @@ -503,7 +504,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) _hb_ot_shape_normalize (c->font, c->buffer, c->plan->shaper->normalization_preference ? - c->plan->shaper->normalization_preference (c->plan->shaper, &c->buffer->props) : + c->plan->shaper->normalization_preference (c->plan) : HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT); hb_ot_shape_setup_masks (c);