[OTLayout] Reuse apply context for recursion

This commit is contained in:
Behdad Esfahbod 2012-11-24 01:13:20 -05:00
parent 53a69f49e5
commit 4c4e8f0e75
3 changed files with 16 additions and 6 deletions

View File

@ -1537,8 +1537,13 @@ inline bool PosLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int l
{
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
const PosLookup &l = gpos.get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_property = c->property;
c->set_lookup (l);
return l.apply_once (c);
bool ret = l.apply_once (c);
c->lookup_props = saved_lookup_props;
c->property = saved_property;
return ret;
}

View File

@ -1402,8 +1402,13 @@ inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_property = c->property;
c->set_lookup (l);
return l.apply_once (c);
bool ret = l.apply_once (c);
c->lookup_props = saved_lookup_props;
c->property = saved_property;
return ret;
}

View File

@ -233,10 +233,10 @@ struct hb_apply_context_t
if (unlikely (nesting_level_left == 0 || !recurse_func))
return default_return_value ();
/* TODO Reuse context. */
hb_apply_context_t new_c (*this);
new_c.nesting_level_left--;
return recurse_func (&new_c, lookup_index);
nesting_level_left--;
recurse_func (this, lookup_index);
nesting_level_left++;
return default_return_value ();
}
hb_font_t *font;