#include "inc/Main.h"
#include "inc/debug.h"
#include "inc/Endian.h"
#include "inc/Pass.h"
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include "inc/Segment.h"
#include "inc/Code.h"
#include "inc/Rule.h"
#include "inc/Error.h"
#include "inc/Collider.h"
usingnamespacegraphite2;
Machine;
Code;
enum KernCollison
{ … };
Pass::Pass()
: … { … }
Pass::~Pass()
{ … }
bool Pass::readPass(const byte * const pass_start, size_t pass_length, size_t subtable_base,
GR_MAYBE_UNUSED Face & face, passtype pt, GR_MAYBE_UNUSED uint32 version, Error &e)
{ … }
bool Pass::readRules(const byte * rule_map, const size_t num_entries,
const byte *precontext, const uint16 * sort_key,
const uint16 * o_constraint, const byte *rc_data,
const uint16 * o_action, const byte * ac_data,
Face & face, passtype pt, Error &e)
{ … }
static int cmpRuleEntry(const void *a, const void *b) { … }
bool Pass::readStates(const byte * starts, const byte *states, const byte * o_rule_map, GR_MAYBE_UNUSED Face & face, Error &e)
{ … }
bool Pass::readRanges(const byte * ranges, size_t num_ranges, Error &e)
{ … }
bool Pass::runGraphite(vm::Machine & m, FiniteStateMachine & fsm, bool reverse) const
{ … }
bool Pass::runFSM(FiniteStateMachine& fsm, Slot * slot) const
{ … }
#if !defined GRAPHITE2_NTRACING
inline
Slot * input_slot(const SlotMap & slots, const int n)
{
Slot * s = slots[slots.context() + n];
if (!s->isCopied()) return s;
return s->prev() ? s->prev()->next() : (s->next() ? s->next()->prev() : slots.segment.last());
}
inline
Slot * output_slot(const SlotMap & slots, const int n)
{
Slot * s = slots[slots.context() + n - 1];
return s ? s->next() : slots.segment.first();
}
#endif
void Pass::findNDoRule(Slot * & slot, Machine &m, FiniteStateMachine & fsm) const
{ … }
#if !defined GRAPHITE2_NTRACING
void Pass::dumpRuleEventConsidered(const FiniteStateMachine & fsm, const RuleEntry & re) const
{
*fsm.dbgout << "considered" << json::array;
for (const RuleEntry *r = fsm.rules.begin(); r != &re; ++r)
{
if (r->rule->preContext > fsm.slots.context())
continue;
*fsm.dbgout << json::flat << json::object
<< "id" << r->rule - m_rules
<< "failed" << true
<< "input" << json::flat << json::object
<< "start" << objectid(dslot(&fsm.slots.segment, input_slot(fsm.slots, -r->rule->preContext)))
<< "length" << r->rule->sort
<< json::close
<< json::close;
}
}
void Pass::dumpRuleEventOutput(const FiniteStateMachine & fsm, const Rule & r, Slot * const last_slot) const
{
*fsm.dbgout << json::item << json::flat << json::object
<< "id" << &r - m_rules
<< "failed" << false
<< "input" << json::flat << json::object
<< "start" << objectid(dslot(&fsm.slots.segment, input_slot(fsm.slots, 0)))
<< "length" << r.sort - r.preContext
<< json::close
<< json::close
<< json::close
<< "output" << json::object
<< "range" << json::flat << json::object
<< "start" << objectid(dslot(&fsm.slots.segment, input_slot(fsm.slots, 0)))
<< "end" << objectid(dslot(&fsm.slots.segment, last_slot))
<< json::close
<< "slots" << json::array;
const Position rsb_prepos = last_slot ? last_slot->origin() : fsm.slots.segment.advance();
fsm.slots.segment.positionSlots(0, 0, 0, fsm.slots.segment.currdir());
for(Slot * slot = output_slot(fsm.slots, 0); slot != last_slot; slot = slot->next())
*fsm.dbgout << dslot(&fsm.slots.segment, slot);
*fsm.dbgout << json::close
<< "postshift" << (last_slot ? last_slot->origin() : fsm.slots.segment.advance()) - rsb_prepos
<< json::close;
}
#endif
inline
bool Pass::testPassConstraint(Machine & m) const
{ … }
bool Pass::testConstraint(const Rule & r, Machine & m) const
{ … }
void SlotMap::collectGarbage(Slot * &aSlot)
{ … }
int Pass::doAction(const Code *codeptr, Slot * & slot_out, vm::Machine & m) const
{ … }
void Pass::adjustSlot(int delta, Slot * & slot_out, SlotMap & smap) const
{ … }
bool Pass::collisionShift(Segment *seg, int dir, json * const dbgout) const
{ … }
bool Pass::collisionKern(Segment *seg, int dir, json * const dbgout) const
{ … }
bool Pass::collisionFinish(Segment *seg, GR_MAYBE_UNUSED json * const dbgout) const
{ … }
static bool inKernCluster(Segment *seg, Slot *s)
{ … }
bool Pass::resolveCollisions(Segment *seg, Slot *slotFix, Slot *start,
ShiftCollider &coll, GR_MAYBE_UNUSED bool isRev, int dir, bool &moved, bool &hasCol,
json * const dbgout) const
{ … }
float Pass::resolveKern(Segment *seg, Slot *slotFix, GR_MAYBE_UNUSED Slot *start, int dir,
float &ymin, float &ymax, json *const dbgout) const
{ … }