From b50099bff22f9add10e100b6ace5a063a574a066 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 17 Sep 2020 14:25:30 +0100 Subject: [PATCH 1/8] Trace reordering in pause functions --- src/hb-ot-shape-complex-indic.cc | 10 ++++++++-- src/hb-ot-shape-complex-khmer.cc | 10 ++++++---- src/hb-ot-shape-complex-myanmar.cc | 9 ++++++--- src/hb-ot-shape-complex-use.cc | 10 +++++++--- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 34972f81e..1916638c5 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1006,11 +1006,14 @@ initial_reordering_indic (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { + if (!buffer->message (font, "start reordering indic initial")) + return; update_consonant_positions_indic (plan, font, buffer); insert_dotted_circles_indic (plan, font, buffer); foreach_syllable (buffer, start, end) initial_reordering_syllable_indic (plan, font->face, buffer, start, end); + (void)buffer->message (font, "end reordering indic initial"); } static void @@ -1485,8 +1488,11 @@ final_reordering_indic (const hb_ot_shape_plan_t *plan, unsigned int count = buffer->len; if (unlikely (!count)) return; - foreach_syllable (buffer, start, end) - final_reordering_syllable_indic (plan, buffer, start, end); + if (buffer->message (font, "start reordering indic final")) { + foreach_syllable (buffer, start, end) + final_reordering_syllable_indic (plan, buffer, start, end); + buffer->message (font, "end reordering indic final"); + } HB_BUFFER_DEALLOCATE_VAR (buffer, indic_category); HB_BUFFER_DEALLOCATE_VAR (buffer, indic_position); diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc index 3da837489..133e05e96 100644 --- a/src/hb-ot-shape-complex-khmer.cc +++ b/src/hb-ot-shape-complex-khmer.cc @@ -389,11 +389,13 @@ reorder_khmer (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { - insert_dotted_circles_khmer (plan, font, buffer); - - foreach_syllable (buffer, start, end) - reorder_syllable_khmer (plan, font->face, buffer, start, end); + if (buffer->message (font, "start reordering khmer")) { + insert_dotted_circles_khmer (plan, font, buffer); + foreach_syllable (buffer, start, end) + reorder_syllable_khmer (plan, font->face, buffer, start, end); + (void)buffer->message (font, "end reordering khmer"); + } HB_BUFFER_DEALLOCATE_VAR (buffer, khmer_category); } diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index 294ab3412..0ee0d9e4f 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -327,10 +327,13 @@ reorder_myanmar (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { - insert_dotted_circles_myanmar (plan, font, buffer); + if (buffer->message (font, "start reordering myanmar")) { + insert_dotted_circles_myanmar (plan, font, buffer); - foreach_syllable (buffer, start, end) - reorder_syllable_myanmar (plan, font->face, buffer, start, end); + foreach_syllable (buffer, start, end) + reorder_syllable_myanmar (plan, font->face, buffer, start, end); + buffer->message (font, "end reordering myanmar"); + } HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category); HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_position); diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 19a272ce1..6ed16cb34 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -517,10 +517,14 @@ reorder_use (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { - insert_dotted_circles_use (plan, font, buffer); + if (buffer->message (font, "start reordering USE")) { + insert_dotted_circles_use (plan, font, buffer); - foreach_syllable (buffer, start, end) - reorder_syllable_use (buffer, start, end); + foreach_syllable (buffer, start, end) + reorder_syllable_use (buffer, start, end); + + (void)buffer->message (font, "end reordering USE"); + } HB_BUFFER_DEALLOCATE_VAR (buffer, use_category); } From 8b3b835a0aaf7b21825ad87f0e0ab9efbff34dcc Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 17 Sep 2020 14:27:31 +0100 Subject: [PATCH 2/8] Trace normalization and preprocessing stages --- src/hb-ot-shape.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 010a6f2c8..cf8110c09 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -851,7 +851,10 @@ hb_ot_substitute_default (const hb_ot_shape_context_t *c) HB_BUFFER_ALLOCATE_VAR (buffer, glyph_index); - _hb_ot_shape_normalize (c->plan, buffer, c->font); + if (buffer->message(c->font, "begin normalize")) { + _hb_ot_shape_normalize (c->plan, buffer, c->font); + buffer->message(c->font, "end normalize"); + } hb_ot_shape_setup_masks (c); @@ -896,8 +899,11 @@ hb_ot_substitute_post (const hb_ot_shape_context_t *c) hb_aat_layout_remove_deleted_glyphs (c->buffer); #endif - if (c->plan->shaper->postprocess_glyphs) + if (c->plan->shaper->postprocess_glyphs && + c->buffer->message(c->font, "begin postprocess")) { c->plan->shaper->postprocess_glyphs (c->plan, c->buffer, c->font); + (void)c->buffer->message(c->font, "end postprocess"); + } } @@ -1120,8 +1126,11 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) hb_ensure_native_direction (c->buffer); - if (c->plan->shaper->preprocess_text) + if (c->plan->shaper->preprocess_text && + c->buffer->message(c->font, "begin preprocess")) { c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font); + (void)c->buffer->message(c->font, "end preprocess"); + } hb_ot_substitute_pre (c); hb_ot_position (c); From f19018da412cf0949748dc8ba80e1a0a376238af Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 17 Sep 2020 15:08:32 +0100 Subject: [PATCH 3/8] Smaller issues from review --- src/hb-ot-shape-complex-indic.cc | 12 ++++++------ src/hb-ot-shape-complex-myanmar.cc | 2 +- src/hb-ot-shape.cc | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 1916638c5..b9e013903 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1006,8 +1006,8 @@ initial_reordering_indic (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { - if (!buffer->message (font, "start reordering indic initial")) - return; + if (!buffer->message (font, "start reordering indic initial")) + return; update_consonant_positions_indic (plan, font, buffer); insert_dotted_circles_indic (plan, font, buffer); @@ -1488,10 +1488,10 @@ final_reordering_indic (const hb_ot_shape_plan_t *plan, unsigned int count = buffer->len; if (unlikely (!count)) return; - if (buffer->message (font, "start reordering indic final")) { - foreach_syllable (buffer, start, end) - final_reordering_syllable_indic (plan, buffer, start, end); - buffer->message (font, "end reordering indic final"); + if (buffer->message (font, "start reordering indic final")) { + foreach_syllable (buffer, start, end) + final_reordering_syllable_indic (plan, buffer, start, end); + buffer->message (font, "end reordering indic final"); } HB_BUFFER_DEALLOCATE_VAR (buffer, indic_category); diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index 0ee0d9e4f..08050380a 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -332,7 +332,7 @@ reorder_myanmar (const hb_ot_shape_plan_t *plan, foreach_syllable (buffer, start, end) reorder_syllable_myanmar (plan, font->face, buffer, start, end); - buffer->message (font, "end reordering myanmar"); + (void)buffer->message (font, "end reordering myanmar"); } HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category); diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index cf8110c09..ff92d5dfe 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -851,7 +851,7 @@ hb_ot_substitute_default (const hb_ot_shape_context_t *c) HB_BUFFER_ALLOCATE_VAR (buffer, glyph_index); - if (buffer->message(c->font, "begin normalize")) { + if (buffer->message(c->font, "start normalize")) { _hb_ot_shape_normalize (c->plan, buffer, c->font); buffer->message(c->font, "end normalize"); } @@ -900,7 +900,7 @@ hb_ot_substitute_post (const hb_ot_shape_context_t *c) #endif if (c->plan->shaper->postprocess_glyphs && - c->buffer->message(c->font, "begin postprocess")) { + c->buffer->message(c->font, "start postprocess")) { c->plan->shaper->postprocess_glyphs (c->plan, c->buffer, c->font); (void)c->buffer->message(c->font, "end postprocess"); } @@ -1127,7 +1127,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) hb_ensure_native_direction (c->buffer); if (c->plan->shaper->preprocess_text && - c->buffer->message(c->font, "begin preprocess")) { + c->buffer->message(c->font, "start preprocess")) { c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font); (void)c->buffer->message(c->font, "end preprocess"); } From 428c111f1389e3ebf8b694f342ffdc011f2ee043 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Fri, 18 Sep 2020 16:24:47 +0100 Subject: [PATCH 4/8] Fix spacing around casts --- src/hb-ot-layout.cc | 4 ++-- src/hb-ot-shape-complex-indic.cc | 2 +- src/hb-ot-shape-complex-khmer.cc | 2 +- src/hb-ot-shape-complex-myanmar.cc | 2 +- src/hb-ot-shape-complex-use.cc | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 7918f86dd..f25f0f9e2 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1881,7 +1881,7 @@ void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, h GSUBProxy proxy (font->face); if (!buffer->message (font, "start table GSUB")) return; apply (proxy, plan, font, buffer); - (void)buffer->message (font, "end table GSUB"); + (void) buffer->message (font, "end table GSUB"); } void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const @@ -1889,7 +1889,7 @@ void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_ GPOSProxy proxy (font->face); if (!buffer->message (font, "start table GPOS")) return; apply (proxy, plan, font, buffer); - (void)buffer->message (font, "end table GPOS"); + (void) buffer->message (font, "end table GPOS"); } void diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index b9e013903..dde613817 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1013,7 +1013,7 @@ initial_reordering_indic (const hb_ot_shape_plan_t *plan, foreach_syllable (buffer, start, end) initial_reordering_syllable_indic (plan, font->face, buffer, start, end); - (void)buffer->message (font, "end reordering indic initial"); + (void) buffer->message (font, "end reordering indic initial"); } static void diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc index 133e05e96..d6fcd7c81 100644 --- a/src/hb-ot-shape-complex-khmer.cc +++ b/src/hb-ot-shape-complex-khmer.cc @@ -394,7 +394,7 @@ reorder_khmer (const hb_ot_shape_plan_t *plan, foreach_syllable (buffer, start, end) reorder_syllable_khmer (plan, font->face, buffer, start, end); - (void)buffer->message (font, "end reordering khmer"); + (void) buffer->message (font, "end reordering khmer"); } HB_BUFFER_DEALLOCATE_VAR (buffer, khmer_category); } diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index 08050380a..fe096ef28 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -332,7 +332,7 @@ reorder_myanmar (const hb_ot_shape_plan_t *plan, foreach_syllable (buffer, start, end) reorder_syllable_myanmar (plan, font->face, buffer, start, end); - (void)buffer->message (font, "end reordering myanmar"); + (void) buffer->message (font, "end reordering myanmar"); } HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category); diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 6ed16cb34..8ac569d8b 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -523,7 +523,7 @@ reorder_use (const hb_ot_shape_plan_t *plan, foreach_syllable (buffer, start, end) reorder_syllable_use (buffer, start, end); - (void)buffer->message (font, "end reordering USE"); + (void) buffer->message (font, "end reordering USE"); } HB_BUFFER_DEALLOCATE_VAR (buffer, use_category); From 8e1bedc50b13d19e1fb3c0fbb0cfa6d87f042f51 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Fri, 18 Sep 2020 16:25:43 +0100 Subject: [PATCH 5/8] Keep phase names --- src/hb-ot-shape.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index ff92d5dfe..09c47c7de 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -900,9 +900,9 @@ hb_ot_substitute_post (const hb_ot_shape_context_t *c) #endif if (c->plan->shaper->postprocess_glyphs && - c->buffer->message(c->font, "start postprocess")) { + c->buffer->message(c->font, "start postprocess-glyphs")) { c->plan->shaper->postprocess_glyphs (c->plan, c->buffer, c->font); - (void)c->buffer->message(c->font, "end postprocess"); + (void)c->buffer->message(c->font, "end postprocess-glyphs"); } } @@ -1127,9 +1127,9 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) hb_ensure_native_direction (c->buffer); if (c->plan->shaper->preprocess_text && - c->buffer->message(c->font, "start preprocess")) { + c->buffer->message(c->font, "start preprocess-text")) { c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font); - (void)c->buffer->message(c->font, "end preprocess"); + (void)c->buffer->message(c->font, "end preprocess-text"); } hb_ot_substitute_pre (c); From 4bb6d54e3bd16ae42364587f9703128b95de89de Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Fri, 18 Sep 2020 16:26:08 +0100 Subject: [PATCH 6/8] Missing cast --- src/hb-ot-shape-complex-indic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index dde613817..652ef4704 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1491,7 +1491,7 @@ final_reordering_indic (const hb_ot_shape_plan_t *plan, if (buffer->message (font, "start reordering indic final")) { foreach_syllable (buffer, start, end) final_reordering_syllable_indic (plan, buffer, start, end); - buffer->message (font, "end reordering indic final"); + (void) buffer->message (font, "end reordering indic final"); } HB_BUFFER_DEALLOCATE_VAR (buffer, indic_category); From 2e0193d7417d1134e1710bf3fa7690332bc561e0 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Fri, 18 Sep 2020 16:28:29 +0100 Subject: [PATCH 7/8] Add more cast spaces --- src/hb-ot-shape.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 09c47c7de..3ea95ce2d 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -902,7 +902,7 @@ hb_ot_substitute_post (const hb_ot_shape_context_t *c) if (c->plan->shaper->postprocess_glyphs && c->buffer->message(c->font, "start postprocess-glyphs")) { c->plan->shaper->postprocess_glyphs (c->plan, c->buffer, c->font); - (void)c->buffer->message(c->font, "end postprocess-glyphs"); + (void) c->buffer->message(c->font, "end postprocess-glyphs"); } } @@ -1129,7 +1129,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) if (c->plan->shaper->preprocess_text && c->buffer->message(c->font, "start preprocess-text")) { c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font); - (void)c->buffer->message(c->font, "end preprocess-text"); + (void) c->buffer->message(c->font, "end preprocess-text"); } hb_ot_substitute_pre (c); From fd8f4ffcc6851ff9024957779be50411e87724d5 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Fri, 18 Sep 2020 16:37:22 +0100 Subject: [PATCH 8/8] Trace reorder, not normalize --- src/hb-ot-shape-normalize.cc | 3 ++- src/hb-ot-shape.cc | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 9157c066f..3eabae1b4 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -373,7 +373,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, /* Second round, reorder (inplace) */ - if (!all_simple) + if (!all_simple && buffer->message(font, "start reorder")) { count = buffer->len; for (unsigned int i = 0; i < count; i++) @@ -399,6 +399,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, i = end; } + (void) buffer->message(font, "end reorder"); } if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_CGJ) { diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 3ea95ce2d..7d9055845 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -851,10 +851,7 @@ hb_ot_substitute_default (const hb_ot_shape_context_t *c) HB_BUFFER_ALLOCATE_VAR (buffer, glyph_index); - if (buffer->message(c->font, "start normalize")) { - _hb_ot_shape_normalize (c->plan, buffer, c->font); - buffer->message(c->font, "end normalize"); - } + _hb_ot_shape_normalize (c->plan, buffer, c->font); hb_ot_shape_setup_masks (c);