[layout] Keep digest updated in the context
Don't recompute digest after every (applied) GSUB lookup.
This commit is contained in:
parent
a5964a2d2a
commit
8b2a211123
|
@ -686,6 +686,7 @@ struct hb_ot_apply_context_t :
|
|||
bool random = false;
|
||||
uint32_t random_state = 1;
|
||||
unsigned new_syllables = (unsigned) -1;
|
||||
hb_set_digest_t digest;
|
||||
|
||||
hb_ot_apply_context_t (unsigned int table_index_,
|
||||
hb_font_t *font_,
|
||||
|
@ -708,7 +709,8 @@ struct hb_ot_apply_context_t :
|
|||
#endif
|
||||
),
|
||||
direction (buffer_->props.direction),
|
||||
has_glyph_classes (gdef.has_glyph_classes ())
|
||||
has_glyph_classes (gdef.has_glyph_classes ()),
|
||||
digest (buffer_->digest ())
|
||||
{ init_iters (); }
|
||||
|
||||
~hb_ot_apply_context_t ()
|
||||
|
@ -781,8 +783,10 @@ struct hb_ot_apply_context_t :
|
|||
void _set_glyph_class (hb_codepoint_t glyph_index,
|
||||
unsigned int class_guess = 0,
|
||||
bool ligature = false,
|
||||
bool component = false) const
|
||||
bool component = false)
|
||||
{
|
||||
digest.add (glyph_index);
|
||||
|
||||
if (new_syllables != (unsigned) -1)
|
||||
buffer->cur().syllable() = new_syllables;
|
||||
|
||||
|
@ -815,24 +819,24 @@ struct hb_ot_apply_context_t :
|
|||
_hb_glyph_info_set_glyph_props (&buffer->cur(), props);
|
||||
}
|
||||
|
||||
void replace_glyph (hb_codepoint_t glyph_index) const
|
||||
void replace_glyph (hb_codepoint_t glyph_index)
|
||||
{
|
||||
_set_glyph_class (glyph_index);
|
||||
(void) buffer->replace_glyph (glyph_index);
|
||||
}
|
||||
void replace_glyph_inplace (hb_codepoint_t glyph_index) const
|
||||
void replace_glyph_inplace (hb_codepoint_t glyph_index)
|
||||
{
|
||||
_set_glyph_class (glyph_index);
|
||||
buffer->cur().codepoint = glyph_index;
|
||||
}
|
||||
void replace_glyph_with_ligature (hb_codepoint_t glyph_index,
|
||||
unsigned int class_guess) const
|
||||
unsigned int class_guess)
|
||||
{
|
||||
_set_glyph_class (glyph_index, class_guess, true);
|
||||
(void) buffer->replace_glyph (glyph_index);
|
||||
}
|
||||
void output_glyph_for_component (hb_codepoint_t glyph_index,
|
||||
unsigned int class_guess) const
|
||||
unsigned int class_guess)
|
||||
{
|
||||
_set_glyph_class (glyph_index, class_guess, false, true);
|
||||
(void) buffer->output_glyph (glyph_index);
|
||||
|
|
|
@ -1955,8 +1955,6 @@ inline void hb_ot_map_t::apply (const Proxy &proxy,
|
|||
OT::hb_ot_apply_context_t c (table_index, font, buffer);
|
||||
c.set_recurse_func (Proxy::Lookup::template dispatch_recurse_func<OT::hb_ot_apply_context_t>);
|
||||
|
||||
hb_set_digest_t digest = buffer->digest ();
|
||||
|
||||
for (unsigned int stage_index = 0; stage_index < stages[table_index].length; stage_index++)
|
||||
{
|
||||
const stage_map_t *stage = &stages[table_index][stage_index];
|
||||
|
@ -1967,7 +1965,7 @@ inline void hb_ot_map_t::apply (const Proxy &proxy,
|
|||
unsigned int lookup_index = lookup.index;
|
||||
if (!buffer->message (font, "start lookup %d", lookup_index)) continue;
|
||||
|
||||
if (proxy.accels[lookup_index].digest.may_have (digest))
|
||||
if (proxy.accels[lookup_index].digest.may_have (c.digest))
|
||||
{
|
||||
c.set_lookup_index (lookup_index);
|
||||
c.set_lookup_mask (lookup.mask);
|
||||
|
@ -1976,13 +1974,9 @@ inline void hb_ot_map_t::apply (const Proxy &proxy,
|
|||
c.set_random (lookup.random);
|
||||
c.set_per_syllable (lookup.per_syllable);
|
||||
|
||||
if (apply_string<Proxy> (&c,
|
||||
proxy.table.get_lookup (lookup_index),
|
||||
proxy.accels[lookup_index]) &&
|
||||
table_index == 0)
|
||||
{
|
||||
digest = buffer->digest ();
|
||||
}
|
||||
apply_string<Proxy> (&c,
|
||||
proxy.table.get_lookup (lookup_index),
|
||||
proxy.accels[lookup_index]);
|
||||
}
|
||||
else
|
||||
(void) buffer->message (font, "skipped lookup %d because no glyph matches", lookup_index);
|
||||
|
@ -1991,7 +1985,12 @@ inline void hb_ot_map_t::apply (const Proxy &proxy,
|
|||
}
|
||||
|
||||
if (stage->pause_func)
|
||||
{
|
||||
stage->pause_func (plan, font, buffer);
|
||||
/* Refresh working buffer digest since buffer content
|
||||
* might have changed. */
|
||||
c.digest = buffer->digest ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue