[aat] Move is_actionable outside of the driver_context

pull/5041/head
Behdad Esfahbod 1 week ago
parent 5ade5bab01
commit d9e99baa9a
  1. 8
      src/hb-aat-layout-common.hh
  2. 24
      src/hb-aat-layout-kerx-table.hh
  3. 60
      src/hb-aat-layout-morx-table.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)

@ -228,6 +228,9 @@ struct KerxSubTableFormat1
DontAdvance = Format1EntryT::DontAdvance,
};
bool is_actionable (const Entry<EntryData> &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<EntryData> &entry)
{ return Format1EntryT::performAction (entry); }
void transition (hb_buffer_t *buffer,
StateTableDriver<Types, EntryData, Flags> *driver,
const Entry<EntryData> &entry)
@ -346,9 +347,10 @@ struct KerxSubTableFormat1
}
}
private:
public:
hb_aat_apply_context_t *c;
const KerxSubTableFormat1 *table;
private:
const UnsizedArrayOf<FWORD> &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<EntryData> &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<EntryData> &entry)
{ return entry.data.ankrActionIndex != 0xFFFF; }
void transition (hb_buffer_t *buffer,
StateTableDriver<Types, EntryData, Flags> *driver,
const Entry<EntryData> &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;

@ -67,18 +67,20 @@ struct RearrangementSubtable
Verb = 0x000F, /* The type of rearrangement specified. */
};
bool is_actionable (const Entry<EntryData> &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<EntryData> &entry) const
{
return (entry.flags & Verb) && start < end;
}
void transition (hb_buffer_t *buffer,
StateTableDriver<Types, EntryData, Flags> *driver,
const Entry<EntryData> &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<EntryData> &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<EntryData> &entry) const
{
return entry.data.markIndex != 0xFFFF || entry.data.currentIndex != 0xFFFF;
}
void transition (hb_buffer_t *buffer,
StateTableDriver<Types, EntryData, Flags> *driver,
const Entry<EntryData> &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<Lookup<HBGlyphID16>, HBUINT, void, false> &subs;
};
@ -456,6 +460,11 @@ struct LigatureSubtable
DontAdvance = LigatureEntryT::DontAdvance,
};
bool is_actionable (const Entry<EntryData> &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<EntryData> &entry) const
{
return LigatureEntryT::performAction (entry);
}
void transition (hb_buffer_t *buffer,
StateTableDriver<Types, EntryData, Flags> *driver,
const Entry<EntryData> &entry)
@ -584,9 +589,9 @@ struct LigatureSubtable
public:
bool ret;
private:
hb_aat_apply_context_t *c;
const LigatureSubtable *table;
private:
const UnsizedArrayOf<HBUINT32> &ligAction;
const UnsizedArrayOf<HBUINT16> &component;
const UnsizedArrayOf<HBGlyphID16> &ligature;
@ -779,22 +784,24 @@ struct InsertionSubtable
* marked location is 31 glyphs. */
};
bool is_actionable (const Entry<EntryData> &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<EntryData> &entry) const
{
return (entry.flags & (CurrentInsertCount | MarkedInsertCount)) &&
(entry.data.currentInsertIndex != 0xFFFF ||entry.data.markedInsertIndex != 0xFFFF);
}
void transition (hb_buffer_t *buffer,
StateTableDriver<Types, EntryData, Flags> *driver,
const Entry<EntryData> &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<HBGlyphID16> &insertionAction;
};

Loading…
Cancel
Save