[aat] Remove set-digest

Now that we have a class cache, this was just speeding things down.
pull/5031/head
Behdad Esfahbod 2 weeks ago
parent 0e13e78153
commit 832f199607
  1. 9
      src/hb-aat-layout-common.hh
  2. 31
      src/hb-aat-layout-morx-table.hh

@ -65,7 +65,6 @@ struct hb_aat_apply_context_t :
const OT::GDEF *gdef_table;
const hb_sorted_vector_t<hb_aat_map_t::range_flags_t> *range_flags = nullptr;
hb_set_digest_t buffer_digest = hb_set_digest_t::full ();
hb_set_digest_t machine_glyph_set = hb_set_digest_t::full ();
hb_set_digest_t left_set = hb_set_digest_t::full ();
hb_set_digest_t right_set = hb_set_digest_t::full ();
hb_aat_class_cache_t *machine_class_cache = nullptr;
@ -640,14 +639,12 @@ struct StateTable
int new_state (unsigned int newState) const
{ return Types::extended ? newState : ((int) newState - (int) stateArrayTable) / (int) nClasses; }
template <typename set_t, typename cache_t>
template <typename cache_t>
unsigned int get_class (hb_codepoint_t glyph_id,
unsigned int num_glyphs,
const set_t &glyphs,
cache_t *cache) const
{
if (unlikely (glyph_id == DELETED_GLYPH)) return CLASS_DELETED_GLYPH;
if (!glyphs[glyph_id]) return CLASS_OUT_OF_BOUNDS;
if (cache)
{
unsigned int klass;
@ -948,7 +945,7 @@ struct StateTableDriver
{
const auto entry = machine.get_entry (StateTableT::STATE_START_OF_TEXT, CLASS_OUT_OF_BOUNDS);
return !c->is_actionable (ac->buffer, this, entry) &&
machine.new_state (entry.newState) == StateTableT::STATE_START_OF_TEXT;
machine.new_state (entry.newState) == StateTableT::STATE_START_OF_TEXT;
}
template <typename context_t>
@ -991,7 +988,7 @@ struct StateTableDriver
}
unsigned int klass = likely (buffer->idx < buffer->len) ?
machine.get_class (buffer->cur().codepoint, num_glyphs, ac->machine_glyph_set, ac->machine_class_cache) :
machine.get_class (buffer->cur().codepoint, num_glyphs, ac->machine_class_cache) :
(unsigned) CLASS_END_OF_TEXT;
DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
const EntryT &entry = machine.get_entry (state, klass);

@ -171,10 +171,6 @@ struct RearrangementSubtable
StateTableDriver<Types, EntryData> driver (machine, c->face);
if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) &&
!c->buffer_digest.may_have (c->machine_glyph_set))
return_trace (false);
driver.drive (&dc, c);
return_trace (dc.ret);
@ -336,10 +332,6 @@ struct ContextualSubtable
StateTableDriver<Types, EntryData> driver (machine, c->face);
if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) &&
!c->buffer_digest.may_have (c->machine_glyph_set))
return_trace (false);
driver.drive (&dc, c);
return_trace (dc.ret);
@ -599,10 +591,6 @@ struct LigatureSubtable
StateTableDriver<Types, EntryData> driver (machine, c->face);
if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) &&
!c->buffer_digest.may_have (c->machine_glyph_set))
return_trace (false);
driver.drive (&dc, c);
return_trace (dc.ret);
@ -875,10 +863,6 @@ struct InsertionSubtable
StateTableDriver<Types, EntryData> driver (machine, c->face);
if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) &&
!c->buffer_digest.may_have (c->machine_glyph_set))
return_trace (false);
driver.drive (&dc, c);
return_trace (dc.ret);
@ -935,25 +919,11 @@ struct hb_accelerate_subtables_context_t :
friend struct hb_aat_layout_lookup_accelerator_t;
public:
hb_set_digest_t digest;
hb_aat_class_cache_t *class_cache;
template <typename T>
auto init_ (const T &obj_, unsigned num_glyphs, hb_priority<1>) HB_AUTO_RETURN
(
obj_.machine.collect_glyphs (this->digest, num_glyphs)
)
template <typename T>
void init_ (const T &obj_, unsigned num_glyphs, hb_priority<0>)
{
digest = digest.full ();
}
template <typename T>
void init (const T &obj_, unsigned num_glyphs)
{
init_ (obj_, num_glyphs, hb_prioritize);
class_cache = (hb_aat_class_cache_t *) malloc (sizeof (hb_aat_class_cache_t));
if (class_cache)
class_cache->clear ();
@ -1175,7 +1145,6 @@ struct Chain
hb_map ([&subtable] (const hb_aat_map_t::range_flags_t _) -> bool { return subtable->subFeatureFlags & (_.flags); })))
goto skip;
c->subtable_flags = subtable->subFeatureFlags;
c->machine_glyph_set = accel ? accel->subtables[i].digest : hb_set_digest_t::full ();
c->machine_class_cache = accel ? accel->subtables[i].class_cache : nullptr;
if (!(subtable->get_coverage() & ChainSubtable<Types>::AllDirections) &&

Loading…
Cancel
Save