From d9e99baa9aa2d8ae96e455c955795805a0b277af Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 5 Feb 2025 02:06:59 +0000 Subject: [PATCH] [aat] Move is_actionable outside of the driver_context --- src/hb-aat-layout-common.hh | 8 ++--- src/hb-aat-layout-kerx-table.hh | 24 ++++++++----- src/hb-aat-layout-morx-table.hh | 60 +++++++++++++++++++-------------- 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 2a1386e87..bb24b6437 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -939,7 +939,7 @@ struct StateTableDriver bool is_idempotent_on_all_out_of_bounds (context_t *c, hb_aat_apply_context_t *ac) { const auto entry = machine.get_entry (StateTableT::STATE_START_OF_TEXT, CLASS_OUT_OF_BOUNDS); - return !c->is_actionable (entry) && + return !c->table->is_actionable (entry) && machine.new_state (entry.newState) == StateTableT::STATE_START_OF_TEXT; } @@ -1021,7 +1021,7 @@ struct StateTableDriver bool is_safe_to_break = ( /* 1. */ - !c->is_actionable (entry) && + !c->table->is_actionable (entry) && /* 2. */ // This one is meh, I know... @@ -1033,7 +1033,7 @@ struct StateTableDriver wouldbe_entry = &machine.get_entry(StateTableT::STATE_START_OF_TEXT, klass) , /* 2c'. */ - !c->is_actionable (*wouldbe_entry) && + !c->table->is_actionable (*wouldbe_entry) && /* 2c". */ ( next_state == machine.new_state(wouldbe_entry->newState) && @@ -1043,7 +1043,7 @@ struct StateTableDriver ) && /* 3. */ - !c->is_actionable (machine.get_entry (state, CLASS_END_OF_TEXT)) + !c->table->is_actionable (machine.get_entry (state, CLASS_END_OF_TEXT)) ); if (!is_safe_to_break && buffer->backtrack_len () && buffer->idx < buffer->len) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index d15355f13..cc9e9bf6e 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -228,6 +228,9 @@ struct KerxSubTableFormat1 DontAdvance = Format1EntryT::DontAdvance, }; + bool is_actionable (const Entry &entry) const + { return Format1EntryT::performAction (entry); } + struct driver_context_t { static constexpr bool in_place = true; @@ -243,8 +246,6 @@ struct KerxSubTableFormat1 depth (0), crossStream (table->header.coverage & table->header.CrossStream) {} - bool is_actionable (const Entry &entry) - { return Format1EntryT::performAction (entry); } void transition (hb_buffer_t *buffer, StateTableDriver *driver, const Entry &entry) @@ -346,9 +347,10 @@ struct KerxSubTableFormat1 } } - private: + public: hb_aat_apply_context_t *c; const KerxSubTableFormat1 *table; + private: const UnsizedArrayOf &kernAction; unsigned int stack[8]; unsigned int depth; @@ -502,11 +504,14 @@ struct KerxSubTableFormat4 enum Flags { Mark = 0x8000, /* If set, remember this glyph as the marked glyph. */ - DontAdvance = 0x4000, /* If set, don't advance to the next glyph before - * going to the new state. */ + DontAdvance = 0x4000, /* If set, don't advance to the next glyph before + * going to the new state. */ Reserved = 0x3FFF, /* Not used; set to 0. */ }; + bool is_actionable (const Entry &entry) const + { return entry.data.ankrActionIndex != 0xFFFF; } + struct driver_context_t { static constexpr bool in_place = true; @@ -519,16 +524,15 @@ struct KerxSubTableFormat4 * point table. */ }; - driver_context_t (const KerxSubTableFormat4 *table, + driver_context_t (const KerxSubTableFormat4 *table_, hb_aat_apply_context_t *c_) : c (c_), + table (table_), action_type ((table->flags & ActionType) >> 30), ankrData ((HBUINT16 *) ((const char *) &table->machine + (table->flags & Offset))), mark_set (false), mark (0) {} - bool is_actionable (const Entry &entry) - { return entry.data.ankrActionIndex != 0xFFFF; } void transition (hb_buffer_t *buffer, StateTableDriver *driver, const Entry &entry) @@ -618,8 +622,10 @@ struct KerxSubTableFormat4 } } - private: + public: hb_aat_apply_context_t *c; + const KerxSubTableFormat4 *table; + private: unsigned int action_type; const HBUINT16 *ankrData; bool mark_set; diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index a351de7b3..21ec7f305 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -67,18 +67,20 @@ struct RearrangementSubtable Verb = 0x000F, /* The type of rearrangement specified. */ }; + bool is_actionable (const Entry &entry) const + { + return (entry.flags & Verb); // && start < end; + } + struct driver_context_t { static constexpr bool in_place = true; - driver_context_t (const RearrangementSubtable *table HB_UNUSED) : + driver_context_t (const RearrangementSubtable *table_) : ret (false), + table (table_), start (0), end (0) {} - bool is_actionable (const Entry &entry) const - { - return (entry.flags & Verb) && start < end; - } void transition (hb_buffer_t *buffer, StateTableDriver *driver, const Entry &entry) @@ -157,6 +159,7 @@ struct RearrangementSubtable public: bool ret; + const RearrangementSubtable *table; private: unsigned int start; unsigned int end; @@ -212,11 +215,16 @@ struct ContextualSubtable enum Flags { SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */ - DontAdvance = 0x4000, /* If set, don't advance to the next glyph before - * going to the new state. */ + DontAdvance = 0x4000, /* If set, don't advance to the next glyph before + * going to the new state. */ Reserved = 0x3FFF, /* These bits are reserved and should be set to 0. */ }; + bool is_actionable (const Entry &entry) const + { + return entry.data.markIndex != 0xFFFF || entry.data.currentIndex != 0xFFFF; + } + struct driver_context_t { static constexpr bool in_place = true; @@ -225,17 +233,13 @@ struct ContextualSubtable hb_aat_apply_context_t *c_) : ret (false), c (c_), + table (table_), gdef (*c->gdef_table), mark_set (false), has_glyph_classes (gdef.has_glyph_classes ()), mark (0), - table (table_), subs (table+table->substitutionTables) {} - bool is_actionable (const Entry &entry) const - { - return entry.data.markIndex != 0xFFFF || entry.data.currentIndex != 0xFFFF; - } void transition (hb_buffer_t *buffer, StateTableDriver *driver, const Entry &entry) @@ -318,13 +322,13 @@ struct ContextualSubtable public: bool ret; - private: hb_aat_apply_context_t *c; + const ContextualSubtable *table; + private: const OT::GDEF &gdef; bool mark_set; bool has_glyph_classes; unsigned int mark; - const ContextualSubtable *table; const UnsizedListOfOffset16To, HBUINT, void, false> &subs; }; @@ -456,6 +460,11 @@ struct LigatureSubtable DontAdvance = LigatureEntryT::DontAdvance, }; + bool is_actionable (const Entry &entry) const + { + return LigatureEntryT::performAction (entry); + } + struct driver_context_t { static constexpr bool in_place = false; @@ -481,10 +490,6 @@ struct LigatureSubtable ligature (table+table->ligature), match_length (0) {} - bool is_actionable (const Entry &entry) const - { - return LigatureEntryT::performAction (entry); - } void transition (hb_buffer_t *buffer, StateTableDriver *driver, const Entry &entry) @@ -584,9 +589,9 @@ struct LigatureSubtable public: bool ret; - private: hb_aat_apply_context_t *c; const LigatureSubtable *table; + private: const UnsizedArrayOf &ligAction; const UnsizedArrayOf &component; const UnsizedArrayOf &ligature; @@ -779,22 +784,24 @@ struct InsertionSubtable * marked location is 31 glyphs. */ }; + bool is_actionable (const Entry &entry) const + { + return (entry.flags & (CurrentInsertCount | MarkedInsertCount)) && + (entry.data.currentInsertIndex != 0xFFFF ||entry.data.markedInsertIndex != 0xFFFF); + } + struct driver_context_t { static constexpr bool in_place = false; - driver_context_t (const InsertionSubtable *table, + driver_context_t (const InsertionSubtable *table_, hb_aat_apply_context_t *c_) : ret (false), c (c_), + table (table_), mark (0), insertionAction (table+table->insertionAction) {} - bool is_actionable (const Entry &entry) const - { - return (entry.flags & (CurrentInsertCount | MarkedInsertCount)) && - (entry.data.currentInsertIndex != 0xFFFF ||entry.data.markedInsertIndex != 0xFFFF); - } void transition (hb_buffer_t *buffer, StateTableDriver *driver, const Entry &entry) @@ -876,8 +883,9 @@ struct InsertionSubtable public: bool ret; - private: hb_aat_apply_context_t *c; + const InsertionSubtable *table; + private: unsigned int mark; const UnsizedArrayOf &insertionAction; };