From 9b34677f362fb0ef5a7cb8a284a9e06d1a4cc03b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 23 Nov 2012 17:55:40 -0500 Subject: [PATCH] [OTLayout] Clean up closure() a bit --- src/hb-ot-layout-gsub-table.hh | 29 ++++++++++++++-------------- src/hb-ot-layout-gsubgpos-private.hh | 7 ++++--- src/hb-ot-layout.cc | 6 +++++- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 201ca2780..0679dc132 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1141,6 +1141,13 @@ struct SubstLookup : Lookup return TRACE_RETURN (c->default_return_value ()); } + static inline void_t closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index); + inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const + { + c->set_recurse_func (closure_recurse_func); + return process (c); + } + template inline void add_coverage (set_t *glyphs) const { @@ -1173,7 +1180,6 @@ struct SubstLookup : Lookup } static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index); - inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const { bool ret = false; @@ -1323,20 +1329,6 @@ struct GSUB : GSUBGPOS static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer); static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer); - static inline void_t closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index) - { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); - const SubstLookup &l = gsub.get_lookup (lookup_index); - return l.process (c); - } - inline hb_closure_context_t::return_t closure_lookup (hb_face_t *face, - hb_set_t *glyphs, - unsigned int lookup_index) const - { - hb_closure_context_t c (face, glyphs, closure_recurse_func); - return get_lookup (lookup_index).process (&c); - } - #if 0 inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect_glyphs_context_t *c, unsigned int lookup_index) const @@ -1385,6 +1377,13 @@ inline bool ExtensionSubst::is_reverse (void) const return SubstLookup::lookup_type_is_reverse (type); } +inline void_t SubstLookup::closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index) +{ + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const SubstLookup &l = gsub.get_lookup (lookup_index); + return l.process (c); +} + inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index) { const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index f47f80be2..93b14e9d3 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -65,7 +65,7 @@ struct hb_closure_context_t bool stop_sublookup_iteration (const return_t r) const { return false; } return_t recurse (unsigned int lookup_index) { - if (unlikely (nesting_level_left == 0)) + if (unlikely (nesting_level_left == 0 || !recurse_func)) return default_return_value (); nesting_level_left--; @@ -82,13 +82,14 @@ struct hb_closure_context_t hb_closure_context_t (hb_face_t *face_, hb_set_t *glyphs_, - recurse_func_t recurse_func_, unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) : face (face_), glyphs (glyphs_), - recurse_func (recurse_func_), + recurse_func (NULL), nesting_level_left (nesting_level_left_), debug_depth (0) {} + + void set_recurse_func (recurse_func_t func) { recurse_func = func; } }; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 7af75c089..d345ba6b6 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -498,7 +498,11 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face, unsigned int lookup_index, hb_set_t *glyphs) { - _get_gsub (face).closure_lookup (face, glyphs, lookup_index); + OT::hb_closure_context_t c (face, glyphs); + + const OT::SubstLookup& l = _get_gsub (face).get_lookup (lookup_index); + + l.closure (&c); } /*