From: Behdad Esfahbod Date: Thu, 11 Apr 2013 20:31:01 +0000 (-0400) Subject: [util] Add --num-iterations X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50067e280f381918b8e90b26df9e7bf20f98f0bd;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [util] Add --num-iterations Useful for profiling shapers. --- diff --git a/util/options.cc b/util/options.cc index 5e57548..66b5e15 100644 --- a/util/options.cc +++ b/util/options.cc @@ -276,6 +276,7 @@ shape_options_t::add_options (option_parser_t *parser) {"preserve-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->preserve_default_ignorables, "Preserve Default-Ignorable characters", NULL}, {"utf8-clusters", 0, 0, G_OPTION_ARG_NONE, &this->utf8_clusters, "Use UTF8 byte indices, not char indices", NULL}, {"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", NULL}, + {"num-iterations", 0, 0, G_OPTION_ARG_INT, &this->num_iterations, "Run shaper N times (default: 1)", "N"}, {NULL} }; parser->add_group (entries, diff --git a/util/options.hh b/util/options.hh index 35ea0bc..9302427 100644 --- a/util/options.hh +++ b/util/options.hh @@ -150,6 +150,7 @@ struct shape_options_t : option_group_t shapers = NULL; utf8_clusters = false; normalize_glyphs = false; + num_iterations = 1; add_options (parser); } @@ -234,6 +235,7 @@ struct shape_options_t : option_group_t char **shapers; hb_bool_t utf8_clusters; hb_bool_t normalize_glyphs; + unsigned int num_iterations; }; diff --git a/util/shape-consumer.hh b/util/shape-consumer.hh index bf1a22d..2b86a3c 100644 --- a/util/shape-consumer.hh +++ b/util/shape-consumer.hh @@ -51,14 +51,17 @@ struct shape_consumer_t { output.new_line (); - shaper.populate_buffer (buffer, text, text_len, text_before, text_after); output.consume_text (buffer, text, text_len, shaper.utf8_clusters); - if (!shaper.shape (font, buffer)) { - failed = true; - hb_buffer_set_length (buffer, 0); - output.shape_failed (buffer, text, text_len, shaper.utf8_clusters); - return; + for (unsigned int n = shaper.num_iterations; n; n--) + { + shaper.populate_buffer (buffer, text, text_len, text_before, text_after); + if (!shaper.shape (font, buffer)) { + failed = true; + hb_buffer_set_length (buffer, 0); + output.shape_failed (buffer, text, text_len, shaper.utf8_clusters); + return; + } } output.consume_glyphs (buffer, text, text_len, shaper.utf8_clusters);